#clojure log - Nov 16 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:05 tonyl: is the :once value in the metadata map used only for delaying the results?

0:05 or what is it used for

0:09 KirinDave: How does one define a method with a void return type using gen-interface?

0:10 tonyl: I think only 1.3 lets you specify a return type

0:10 KirinDave: For gen-interface?

0:10 That's definitely not true.

0:10 tonyl: In general

0:10 I am not sure about gen-interface

0:12 danlarkin: 1.2 (at least, and probably earlier versions) of gen-class let you have a void return value

0:12 I have no experience with gen-interface though, sorry :(

0:13 KirinDave: danlarkin: How do you express it?

0:13 gen-class's format is very similar to gen-interface

0:13 danlarkin: KirinDave: https://github.com/danlarkin/subrosa/blob/master/src/subrosa/observable.clj#L9

0:14 KirinDave: that is, a vector of 3-vectors: method name, vector of arg types and return type

0:15 KirinDave: haha, it's just "void"

0:15 tomoj: wonder why not aleph?


0:15 danlarkin: KirinDave: it's in the documentation :)

0:16 KirinDave: danlarkin: Ahh, it is; albeit obliquely

0:16 "In all subsequent sections taking types, the primitive types can be

0:16 referred to by their Java names (int, float etc)"

0:16 danlarkin: Thank you

0:16 danlarkin: KirinDave: it did take me a few minutes of reading to find it

0:17 tomoj: a few reasons, but /mostly/ because when I started this code there was no aleph

0:17 tomoj: ah

0:17 quizme: i got something like GC memory overhead limit exceeded. how do you increase the memory limit?

0:19 tomoj: do you think you really should need to? maybe you are holding the head somewhere?

0:19 oh, guess that means you have excessive churn?

0:20 danlarkin: the default JVM heap size isn't very large, you almost always need to increase it for serious work

0:20 tomoj: that happened to me when I was creating many many boxed integers and then adding them up and outputting and then throwing away

0:20 danlarkin: quizme: java -Xmx2048m ...

0:21 quizme: danlarkin thanks. i'm doing "lein repl"

0:21 danlarkin: quizme: lein respects JAVA_OPTS

0:21 quizme: ok cool

0:21 thnx

0:22 KirinDave: And :java_opts in the project.clj file.

0:22 quizme: awesome dudes thnx

0:22 tonyl: what is the difference between java -Xmx... and java -Xms....

0:22 danlarkin: tonyl: max and min heap size, respectively

0:22 * tonyl *facepalm*

0:23 tonyl: thanks danlarkin

0:24 quizme: export JAVA_OPTS=-Xmx768m <--- will lein pick that up from env ?

0:24 danlarkin: quizme: yes

0:24 quizme: danlarkin tyu

0:25 LauJensen: Morning all

0:33 quizme: is it possible to do something like preduce on an atom ?

2:06 guppy: hello

2:46 quizme: http://pastie.org/1301932 <--- is there anything obviously wrong with how i'm updating my atom? It didn't change...

2:46 sandGorgon: I have a 3'rd party java lib that has a "main" function - I need to invoke that from clojure. How do I do that ?

2:47 hiredman: you're not using reduce correctly

2:48 quizme: hiredman hmm

2:49 hiredman: it takes 3 arguments (reduce f val coll) isn't that what i'm doing ?

3:08 Chousuke: quizme: I don't think that's a good use of an atom in the first place

3:09 it's not parallel at least :P

3:11 quizme: chousuke doesn't pmap parallelize the reduce processes ?

3:12 oh...

3:12 i think i get it

3:12 i see, thanks....

3:17 Chousuke: the atom's going to block most of the parallelism anyway.

3:17 and for pmap to be worth it, the mapped function must be quite expensive

3:19 and it's not usually a good idea to def lazy seqs, unless you want to keep them in memory forever :)

3:20 you'll probably get more performance if you use a transient.

3:20 (without any atoms)

3:21 though if your data structure is nested, then it becomes somewhat tricky.

4:36 esj: hello eujurians (and Raynes, who sleeps not)

4:53 raek: greetings from the realm of smörgåsbord and IKEA

4:57 esj: raek: :)

5:35 LauJensen: smörgås means 'butter goose' in danish :P

5:39 @ raek

5:39 raek: in swedish too, for some reason

5:40 but it still is the word for "sandwich"

5:40 LauJensen: hehe, swedish sets new standards for silly :)

5:42 esj: LauJensen: not sure on that one - a having "butter goose" as the default for a sandwich sounds pretty awesome where I'm standing

5:43 AWizzArd: How can I go from a symbol to class? (foo 'String) ==> java.lang.String (<-- this is a class)

5:44 resolve?

5:44 LauJensen: esj: Im just telling you the Rules. Our languages stem from our Germanic Roots, Denmark is closets to the roots, more clear and easier to reason about. Norwegian is a little more distorted, but still understandable, especially in writing. Swedish is terrible distorted (I think because of alchohol abuse), so that its difficult to understand. If we go even further north we have Suomi, which is just.. gone

5:44 AWizzArd: Or is there something better?

5:45 imade: LauJensen, what's your take on Estonian, it sounds very similar to Finnish

5:45 LauJensen: imade: I dont know enough about it

5:45 esj: LauJensen: ROTFL. I'll have to teach you some Zulu when we meet. The grammar and syntax are such as to make the each sentance rhyme. Now that is awesome.

5:48 LauJensen: esj: Sounds like a cool challenge, would really take hard work. To learn swedish simply takes a couple of beers

5:49 esj: I have a problem, previously discussed, where a sufficient quantity of beer allows me to understand and speak German fluently, on the basis that if I just slur in Dutch I figure I'll be fine...

5:50 xkb: lol

7:12 AWizzArd: Who has an idea to improve this?

7:12 ,(loop [list [10 20 30 40 50], result []] (if (< (count list) 2) result (recur (rest list) (conj result (take 2 list)))))

7:12 clojurebot: [(10 20) (20 30) (30 40) (40 50)]

7:12 Tordmor: ,(doc partition)

7:12 clojurebot: "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a ...

7:13 Tordmor: ,(let [lst [10 20 30 40 50]] (partition 2 lst 1))

7:13 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

7:13 LauJensen: &(vec (partition 2 1 (range 10 50 10)))

7:13 sexpbot: ⟹ [(10 20) (20 30) (30 40)]

7:15 LauJensen: AWizzArd: Did you catch that buddy ?

7:19 AWizzArd: Ah, partition takes another arg

7:19 good, thanks

7:19 LauJensen: 4 in in total, padding is nice as well

7:19 &(partition 2 2 [0] [1 2 3])

7:19 sexpbot: ⟹ ((1 2) (3 0))

7:20 AWizzArd: nice improvements, I missed those, thx

7:21 LauJensen: np

8:33 cemerick: stuartsierra: ping

8:40 sharat87: Hello, is it ok to use a function with side effects in a call to map?

8:40 I mean, it will be called on the sequence in order right?

8:41 noidi: map is lazy, so you'd better use doseq for side effects

8:41 sharat87: oh ok thanks

8:55 is there a better way to turn a keyword into a string (without the :) than (.substring (str :hella) 1)

8:55 LauJensen: &(name :hello)

8:55 sexpbot: ⟹ "hello"

8:55 sharat87: ah neat, thanks :)

8:55 LauJensen: &(subs (str :hello) 1)

8:55 sexpbot: ⟹ "hello"

8:56 sharat87: where are these functions I don't find it in the data structures page?

8:56 LauJensen: Both are better, prefer the first

8:56 sharat87: ok

8:56 LauJensen: sharat87: try the cheat sheet

8:56 Raynes: Where did subs come from?

8:56 &(doc subs)

8:56 sexpbot: ⟹ "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."

8:56 sharat87: yeah, there too, the keywords section only has keyword and keyword?

8:57 LauJensen: oh

8:57 chouser: Raynes: subs is one of those unexpectedly old ones

8:58 sharat87: LauJensen: heh, a Ctrl-F reveals the name function in Other/Misc :)

8:58 chouser: &(meta #'subs)

8:58 sexpbot: ⟹ {:ns #<Namespace clojure.core>, :name subs, :file "clojure/core.clj", :line 3940, :arglists ([s start] [s start end]), :added "1.0", :doc "Returns the substring of s beginning at start inclusive, and ending\n at end (defaults to length of string), exclusive.", :tag java.lang.String}

8:58 chouser: &(:added (meta #'subs)

8:58 sexpbot: java.lang.Exception: EOF while reading

8:58 chouser: &(:added (meta #'subs))

8:58 sexpbot: ⟹ "1.0"

8:58 Chousuke: I'm pretty sure subs was there before the first public release :P

8:58 chouser: yep

8:58 Raynes: I don't think anybody knows about it.

8:59 cemerick: subs is substituting a type hint for a fn call :-P

8:59 chouser: It's included in one of Rich's early presentations, comparing a Python example to an equivalent Clojure example

9:00 LauJensen: chouser: ah, he put it in there to win the spelling corrector test? :)

9:00 cemerick: Trying to make things look less hosty, I guess?

9:00 chouser: I think you're both right. :-)

9:00 stuartsierra: I think it even predates the (.method obj. ..) sintax

9:00 *syntax

9:01 cemerick: Raynes: Dude, subs couldn't *exist* w/o .substring :-P

9:01 LauJensen: subs is actually the first building block of clojure, even precedes functions themselves

9:01 :)

9:01 cemerick: ha :-)

9:01 Raynes: cemerick: You have a thing about backends, don't you?

9:01 chouser: (.method obj) is now so clearly better, it's hard to believe people weren't sure at first

9:02 Raynes: cemerick: Just like project.clj, it's shorter and does everything that I need at the moment, so why would I ever want to use .substring? ;P

9:02 cemerick: Raynes: I'm an ass about making sure people don't forget the stature of the giants we sit upon.

9:02 chouser: Raynes: because if you know about .substring, finding .split is a natural progression

9:02 Raynes: if you only know about subs, good luck finding .split or clojure.string/split

9:02 cemerick: Raynes: The project.clj thing is totally orthogonal, far more meta, and not worth getting into. :-)

9:03 Raynes: chouser: I'm sure I would have managed.

9:03 java.lang.String is not too far away.

9:03 chouser: Nonetheless, shouldn't subs be in clojure.string?

9:03 chouser: I mean, I'm exaggerating, but there's a point there.

9:04 Raynes: if anywhere, yeah. But is it worth a breaking change to move it?

9:04 cemerick: chouser: I got your back, man. Exaggerate and hyperbolize away.

9:04 Raynes: chouser: Sure it is. There can't be more than 3 people using it in practice.

9:05 clojure.string should really be called clojure.redundancy though.

9:06 stuartsierra: hey

9:08 Raynes: $seen mmarczyk

9:08 sexpbot: I have never seen mmarczyk.

9:09 Raynes: I haven't seen ol' Michal in quite a while.

9:09 LauJensen: :(

9:09 Raynes: He must be lurking. He's definitely around, since he watched clojail yesterday.

9:45 fliebel: morning

9:46 LauJensen: Morning :)

9:49 fliebel: Are there any (>= Clojure 50%) companies in Europe?

9:51 AWizzArd: fliebel: do you mean 50% or 0%?

9:51 Any sounds like: (< 0% Clojure)

9:51 fliebel: AWizzArd: Well, at least anything where some serious Clojure work is happening :)

9:54 dakrone: fliebel: Forward was one of the conj sponsors, they're out of London I think

9:55 fliebel: dakrone: I'm googling for them :)

9:55 dakrone: fliebel: forward.co.uk

10:23 AWizzArd: fliebel: yes, some companies use Clojure seriously.

10:24 fliebel: AWizzArd: I'd love to know about a few more.

10:52 jkdufair: how can i use slime to send an expression to the REPL, copying and eval-ing it in the REPL itself?

10:53 i'm giving a presentation demo-ing clojure

10:56 bhenry: jkdufair: i feel like i've seen it in presentations but don't know how to do it myself. if you can't find it make a keyboard macro for C-k C-y C-c-z C-y

10:56 you'd do that from the beginning of the form you want to send to the repl

10:56 jkdufair: yeah, it's not very useful outside of presentations

11:10 trybeingarun: Hey guys

11:11 tonyl: hello

11:11 trybeingarun: (read-line) is not working in emacs. Any fix available?

11:11 tonyl: sorry, not an emacs guy

11:11 trybeingarun: Fyn :)

11:12 @tonyl: what editor are you using btw?

11:13 not trying to start an editor war btw ;)

11:14 tonyl: i don't car about those wars

11:15 I use vim, but run clojure with a bash script

11:15 trybeingarun: me neither. Whatever works fine for the job :)

11:15 nice...

11:17 cemerick: puredanger: Got your back on the ccw keybindings. :-) FYI, Laurent will hopefully have an RC that includes the new REPL stuff this week.

11:18 puredanger: cemerick: cool, thx

11:18 trybeingarun: I am new to functional programming and clojure too. Can anybody suggest a good reading material (other than Practical clojure and Programming Clojure books) ?

11:18 puredanger: cemerick: does that mean just that you agree with me or that you're actually changing it? :)

11:18 cemerick: puredanger: what prompted you to bounce back and forth? I thought you had settled in with emacs, at least for a little while?

11:19 puredanger: cemerick: I've been doing more design work where I want to see a lot of stuff at once and I find Eclipse much easier to do that in

11:19 cemerick: puredanger: I'm all for changing it, but it's Laurent's sandbox. If he says it's a go, and it's just a matter of adding a condition to delegate off to your usual action for text editing in those contexts, then I'll make sure it's in the RC.

11:20 If we don't have the current editing scope handy already, then it may be added to the backlog.

11:21 puredanger: cemerick: the thing that I find really disorienting about it is the difference in behavior with alt-left (left by word) and alt-shift-left (expand selection to entire string, instead of left by word expanding selection)

11:21 tonyl: trybeingarun: for me to understand clojure clojure.org helped me out. functional programming helped me just to go along and program some mini programs

11:21 i haven't read any books just coding and reading blog posts

11:21 pdk: trybeingarun

11:21 look into on lisp/ansi common lisp

11:22 google sicp and look into haskell and ML (say SML or o'caml) as well

11:22 trybeingarun: Isn't there appreciable difference between common lisp and clojure?

11:23 AWizzArd: Is there a test to check if an object is either a Boolean or a primitive boolean?

11:23 pdk: true but the book can still be helpful for getting a feel for lisp on the whole and it spends some time covering things like what you can do with macros

11:23 trybeingarun: I mean, would not immutability make significant difference?

11:23 AWizzArd: other than (or (true? x) (false? x))

11:23 pdk: (doc boolean?_

11:23 clojurebot: EOF while reading

11:23 pdk: (doc boolean?)

11:23 clojurebot: Pardon?

11:23 pdk: hm

11:24 ,(. Integer java_class)

11:24 clojurebot: java.lang.NoSuchFieldException: java_class

11:24 cemerick: puredanger: Absolutely, yes. It's fundamentally just an impl detail, as the arrangement makes perfect sense in actual code.

11:24 pdk: ,(. Integer value_type)

11:24 clojurebot: java.lang.NoSuchFieldException: value_type

11:25 pdk: blast

11:25 trybeingarun: I have the following books with me. Can anybody order in increasing degree of importance/difficulty?

11:25 AWizzArd: Integer/TYPE exists

11:25 Also Boolean/TYPE

11:25 cemerick: I'll have to scrounge up one of those paredit screencasts to see how the other side does things.

11:25 pdk: ,(. Integer TYPE)

11:25 clojurebot: int

11:25 pdk: hm

11:25 AWizzArd: ,(instance? Boolean/TYPE (Boolean. true))

11:25 clojurebot: false

11:25 tonyl: Integer/TYPE

11:25 trybeingarun: 1. Practical Clojure 2. Programming Clojure 3. Practical Common Lisp 4.On lisp 5. PAIP 6. SCIP

11:26 pdk: ,(. Integer getClass)

11:26 clojurebot: java.lang.NoSuchFieldException: getClass

11:26 tonyl: i would say on lisp first then anything else would make sense, if you are new to lisp of course

11:26 pdk: on lisp makes sense after you've learned the basic stuff

11:26 practical clojure is a little sparse

11:27 though if you already know java and skimmed through some other lisp tutorials it could be helpful

11:27 ,(. (new Integer) getClass)

11:27 trybeingarun: Also, I have heard great things about SICP. But the fact that it is being recommended heavily by universities itself makes me a bit anxious.

11:27 clojurebot: java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer

11:27 trybeingarun: Will it be too theoritical??

11:28 I know java.

11:28 pdk: it's probably the first thing people will name if you say you want to learn scheme

11:29 i don't see any big reason to worry but if you want to be sure maybe do practical clojure to learn the basic concepts like what a form is, funargs etc

11:30 trybeingarun: What are you guys using clojure for? I am looking at it just for fun (I mean doing some pet projects)

11:31 puredanger: trybeingarun: large data integration w/ semantic web tech

11:31 tonyl: me too

11:31 i am learning some game theory with it too

11:32 and a have a project in the future for a web app

11:32 trybeingarun: how easy/difficult is it to adapt to pure clojure (FP) mindset.

11:33 Of course, it is kind of a stupid question because it cant be quantified

11:33 puredanger: trybeingarun: anyone that thinks about programming seriously should read SICP imho, regardless of what lang you use. But I'm not sure it's the best way to dabble in FP.

11:33 trybeingarun: but, more particularly, any pain/pleasure points?

11:33 Then I will surely read SICP

11:34 puredanger: trybeingarun: you might have fun using Clojure Koans https://github.com/functional-koans/clojure-koans

11:34 trybeingarun: for(int i = 0; i < blah; i++) {printf ("This has been my life so far");}

11:35 tonyl: trybeingerun: for me there was a learning curve (new to fp, lisp, and jave newbee) but it is worth it

11:36 i see some problems in a different perspective

11:36 pdk: you could also learn more about fp by looking into books/articles etc on fp in general or other fp languages

11:36 say haskell or some variety of ML

11:36 trybeingarun: tonyl: could you please elaborate? What do you value most?

11:36 tonyl: change that to ##(doseq [x (range 10)] (prn "This is now how I do it"))

11:36 sexpbot: ⟹ "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" nil

11:37 pdk: chris okasaki also has a good phd thesis out there specifically on data structures in fp

11:37 later made into a book you could get somewhere say amazon

11:37 tonyl: pdk: that looks interesting

11:37 http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504

11:38 trybeingarun: there is some effort going on to rewrite SICP in clojure, right. Anybody knows what happened to it?

11:39 pdk: the purely functional retrogames article series is also interesting

11:39 trybeingarun: sexpbot: funny :)

11:39 AWizzArd: ,(integer? 9999999999999)

11:39 clojurebot: java.lang.ExceptionInInitializerError

11:39 pdk: even if you're not looking at games programming it talks about how to go along doing stuff that you'd think would be prohibitive without imperative programming

11:39 tonyl: there is a blog that is trying to do that

11:39 AWizzArd: $(integer? 9999999999999)

11:40 tonyl: &(integer? 9999999999999)

11:40 sexpbot: java.lang.Exception: EvalReader not allowed when *read-eval* is false.

11:40 pdk: and game coding is usually something where we favor doing things highly imperatively

11:40 trybeingarun: tonyl: Ya. But in some forum I read the author is not responding to any queries and the effort might have halted. (I hope I am wrong :) )

11:41 tonyl: maybe, it's been a while since I read those posts

11:41 pdk: where is that series? I am trying to learn to do games in FP

11:41 trybeingarun: @RH: Blip.tv videos are amazing. Did not sleep during any of your talks :P

11:44 pdk: http://prog21.dadgum.com/23.html

11:45 tonyl

11:45 also trybeingarun

11:45 trybeingarun: pdk: any particular usecase where FP would do much much better than imperative style?

11:45 pdk: if you're looking into okasaki's book you could also find his phd thesis for free and see if it looks interesting

11:45 the book pretty much takes the thesis and expands on it

11:45 tonyl: thanks pdk

11:46 pdk: performance wise or in terms of being a more appropriate choice

11:46 trybeingarun: programming choice

11:47 pdk: hm that i couldn't answer 100% off the top of my head though folks are advocating it for any sort of highly concurrent coding

11:47 if you read on lisp as well it shows how the lisp style macro system can go surprisingly far

11:48 doing stuff like defining domain specific languages in terms of lisp macros so those mini languages can sit on top of your app

11:48 trybeingarun: Was trying out Practical Common Lisp.

11:49 pdk: on lisp can be had for free in pdf or html as well

11:49 trybeingarun: The author had developed a primitive unit testing framework in just under 30 lines

11:49 ammmmazing

11:49 pdk: same with pcl

11:49 trybeingarun: code was beautiful

11:49 pdk: good thing too since a hardcover on lisp is still like $140

11:49 and who knows why

11:50 trybeingarun: $140 ??? I am scared

11:50 Chousuke: I don't remember who it was that said this, but lisp is a language where you can build up the language to suit your problem domain, rather than having to break down your problem into something expressible in the language :)

11:50 pdk: for a physical copy trybeingarun

11:50 tonyl: i think that was paul graham

11:50 pdk: online it can be had for free legitimately

11:50 yeah it's a paul graham book

11:50 Chousuke: tonyl: probably

11:52 trybeingarun: I just downloaded a copy. Thanks pdf :)

11:52 Paul Graham was working on his own language (Arc) right

11:52 tonyl: yeah

11:52 trybeingarun: anybody following that?

11:52 pdk: i'd be surprised if arc is still going

11:53 tonyl: is there, but there is not much development last time i checked

11:53 cemerick: pdk: it is, surprisingly.

11:53 pdk: hm

11:53 arclanguage.org has downloads though the site is incredibly sparse

11:53 cemerick: Nevermind, I'm not suprised :-P

11:53 trybeingarun: A:P

11:53 pdk: and it has recent forum posts

11:55 trybeingarun: Is it true that clojure's Regex support is not as good as perl or ruby's (I think I heard Stuart Halloway saying that in some talk (video))

11:55 tonyl: under it it uses Java's

11:55 cemerick: trybeingarun: Clojure's regex support is as good as Java's, which is to say, very good.

11:55 Not as good as perl's presumably.

11:56 they are PCRE's, after all :-)

11:56 tonyl: found a bug on the java implementation

11:56 but there are workarounds

11:56 trybeingarun: tonyl: what bug?

11:56 pdk: failing that you could just use java regexes anyway :p

11:56 tonyl: umm let me try ig

11:56 *it

11:57 when you use a [ inside a class group

11:57 pdk: god knows there's probably been countless projects to reimplement perl regex syntax as a java class either way

11:57 tonyl: like this #"[[]"

11:57 it throws a matching error

11:58 technomancy: the literal syntax is nicer in Ruby, but I haven't found anything else problematic with Clojure's

11:58 part from the fact that they're not callable

11:59 *apart

11:59 tonyl: ruby's syntax is like perl isnt? using /regexp/

11:59 technomancy: yeah, more pertinently it supports interpolation and things like /foo/i for case-insensitive

11:59 tonyl: yeah, that is handy

12:00 technomancy: case-insensitive in Clojure looks pretty silly: #"(?i)foo"

12:00 trybeingarun: technomachy: Dude, how is there a fix for emacs' (read-line) issue? (sorry to take to conversation off topic)

12:00 cemerick: tonyl: that's not a bug?

12:00 &(re-seq #"[\[]" "[")

12:00 sexpbot: ⟹ ("[")

12:00 tonyl: &(re-matches #"[[]" "what [] up?")

12:00 sexpbot: java.util.regex.PatternSyntaxException: Unclosed character class near index 2[[] ^

12:00 tonyl: the [ is not supposed to be a special char inside the []

12:01 cemerick: tonyl: oh, you mean, a bug re: "perl compatible"

12:01 amalloy: tonyl: this was discussed in #clojure a week or two ago. java's regex engine, although supposedly PCRE, does that wrong

12:01 technomancy: trybeingarun: I'm not sure; maybe put your input in the buffer where you launched swank?

12:01 tonyl: yeah, that's what I meant

12:02 not only perl, but the only doc http://www.regular-expressions.info/charclass.html

12:02 trybeingarun: technomancy:okay. I will try that

12:02 amalloy: chouser came up with something weird without using \ that i think worked

12:02 tonyl: unless there is a specification that I don't know about, and that always happens :P

12:02 amalloy: &#"[[[]]" maybe

12:02 sexpbot: java.util.regex.PatternSyntaxException: Unclosed character class near index 4[[[]] ^

12:03 tonyl: now I'm intrigued how he did it

12:03 cemerick: tonyl: to be fair, the javadoc for j.u.Pattern doesn't claim to be perl-compatible *shrug*

12:03 tonyl: yeah, understandable

12:03 amalloy: &#"[[]]"

12:03 sexpbot: java.util.regex.PatternSyntaxException: Unclosed character class near index 3[[]] ^

12:03 tonyl: and easy to workaround \

12:04 amalloy: feh

12:04 cemerick: I'll always miss the named groups in python's impl

12:04 * tonyl to the logs!

12:04 fogus_: cemerick: until Java7 anyway

12:04 cemerick: fogus_: oh really?

12:04 fogus_: I think I read that somewhere

12:04 * cemerick dances in place

12:05 cemerick: That'd be phantabulous.

12:05 fogus_: cemerick: http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#groupname

12:05 tonyl: &(let [[a b c] (re-matches #"([-+]?[0-9]+)/([0-9]+)" "22/7")] [a b c])

12:05 sexpbot: ⟹ ["22/7" "22" "7"]

12:06 cemerick: indeed

12:06 tonyl: destructuring helps you name the groups

12:06 cemerick: fogus_: the 6 years were worth the wait! :-P

12:06 Man, matcher destructuring discussed again…

12:09 defn: hello all

12:09 fogus_: well, re-matches returns a vector no?

12:09 tonyl: here's chousers ##(re-find #"[[]]]" "]")

12:09 sexpbot: ⟹ "]"

12:10 fogus_: ,(re-matches #"(\d) (\d) (\d)" "1 2 3")

12:10 clojurebot: ["1 2 3" "1" "2" "3"]

12:10 defn: ##(re-find #"[[]]]" "]")

12:10 sexpbot: ⟹ "]"

12:10 defn: did sexpbot change again?

12:10 -> (+ 1 2)

12:10 guess so...

12:11 cemerick: fogus_: true, thought I saw re-matcher

12:11 fogus_: cemerick: did you see my tweet about matcher destructuring? it was sick (in a bad way)

12:12 defn: i saw it. i threw up.

12:13 amalloy: defn: sexpbot changes a lot, though last i checked -> still worked. weird

12:13 but & is easier to type as a prefix, and ## works anywhere in the message

12:13 sexpbot: java.lang.Exception: Unable to resolve symbol: works in this context

12:14 cemerick: fogus_: Hrm, perhaps.

12:14 amalloy: sexpbot: wtf, i fixed that problem

12:14 cemerick: I remember seeing matcher destructuring lately somewhere, and being surprised that it was supported at all.

12:14 Side-effecting destructuring?

12:14 * cemerick gasps

12:14 cemerick: etc

12:14 amalloy: cemerick: what side effects?

12:15 when you destructure a matcher it gives you the groups of the most recent find, without starting a new find

12:16 * defn inspects Raynes' matcher code for sexps

12:16 fogus_: amalloy: But you have to start the find in the first place

12:16 defn: #((\()))

12:16 ##((\()))

12:16 sexpbot: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn

12:16 amalloy: fogus_: certainly. which is why there are no side effects in the destructuring

12:17 defn: it's actually my code

12:17 fogus_: amalloy: I see what you mean

12:17 http://twitter.com/#!/learnclojure/status/1746438878920704

12:18 amalloy: defn: the regex for matching ## 'things is pretty awful tbh

12:18 sexpbot: ⟹ things

12:19 amalloy: (and next time he pulls, it won't match words mid-message in case someone wants to talk about channels with two #s)

12:20 defn: amalloy: i can show you some code that's worse...

12:20 amalloy: defn: i wouldn't be surprised, but have you looked at the regex? :P

12:21 defn: amalloy: https://github.com/defn/walton/blob/master/src/walton/core.clj#L38

12:22 it was designed to be "fast", and by "fast" i mean "completely incomprehensible"

12:22 cemerick: amalloy: fair enough, not side-effecting destructuring; rather, side-effectable destructuring :-P

12:22 amalloy: defn: condp instead of cond would make things a lot more readable

12:23 and personally i'd use a map of {character=>keyword} pairs - surely a hashtable lookup is faster than testing N boolean expressions?

12:24 defn: amalloy: good point

12:24 cemerick: oddly enough, the matcher destructuring isn't congruent with re-groups (i.e. doesn't include group 0)

12:24 amalloy: also, you test for \\ twice in a row

12:24 Chousuke: amalloy: depends on the number of boolean expressions I guess.

12:24 defn: amalloy: yeah im re-reading this code now -- i just left it alone once it was done

12:24 fliebel: How can I read json, and return nil if it fails? This raises an exception, while the doc says it dhould retorn nil, if I'm correct. (read-json-from "" true false nil)

12:25 (hi defn)

12:25 defn: (hi fliebel)

12:26 AWizzArd: fliebel: you can embed it into a try/catch

12:26 fliebel: AWizzArd: try is bulky, and the docs say it should be able to return nil if it find an empty string.

12:27 trybeingarun: Almost midnight @ India. Bye guys!

12:28 joegallo: drewr: Maintain radio silence!

12:28 drewr: joegallo: yessir

12:29 joegallo: drewr: Heh, we're having seekaret conversations over here. Ssshhh.

12:34 fliebel: I found a bug in clojure.contrib.json.

12:36 Consider this bit and then try &|(char −1)|& on the REPL. if we are at the end of a file, we're never going to make it to the if statement. https://github.com/richhickey/clojure-contrib/blob/1e3333335334139669fb1e859fb0c3cb77b968df/src/main/clojure/clojure/contrib/json.clj#L116-121

12:36 sexpbot: java.lang.Exception: Unable to resolve symbol: −1 in this context

12:37 fliebel: huh...

12:37 fogus_: cemerick: Yeah, it's messed up (technical term). Creating that little snippet of matcher destructuring convinced me to never do it again.

12:37 Raynes: fliebel: Use ##(char -1) now, btw.

12:37 sexpbot: java.lang.IllegalArgumentException: Value out of range for char: -1

12:37 * Raynes runs off

12:37 fliebel: ty

12:39 cemerick: rhickey: What was the motivation for destructuring of j.u.Matchers?

12:58 fliebel: Where do I submit bugs and how do I get this contributors agreement to fix things myself?

12:59 arohner: fliebel: the CA is http://clojure.org/contributing

13:07 fliebel: arohner: Thanks. Do I really need to send this in for… submitting a bug?

13:08 arohner: fliebel: I don't think so. I think you only need to for submitting patches

13:08 amalloy: fliebel: and more power to you if you manage to fix anything. i got my CA in like a month ago, but gave up on changing anything because the instructions are so out-of-date and circular

13:09 arohner: oh, and bugs go here http://dev.clojure.org/jira/browse/CLJ

13:12 fliebel: arohner: I thought I red you need to be contributer to be allowed to be on there, but I'm on it right now and everything seems fine.

13:12 cemerick: fliebel: anyone can submit a bug. The CA is needed only if you're contributing code.

13:13 jimdagem: hi

13:13 cemerick: amalloy: I'm guessing the docs haven't been updated to reflect the move to JIRA, but: fix, produce patch, upload?

13:13 amalloy: cemerick: upload to where?

13:14 cemerick: amalloy: as an attachment to the corresponding JIRA ticket

13:14 esj: cemerick: your maven Enforcer just slapped me around for my own good :) Time for maven 3.0....

13:15 cemerick: esj: ?

13:16 jimdagem: How do I properly do what I'm trying to do: http://pastebin.com/zsXSbzS6

13:16 esj: I tried to build core.unify with maven. The build, courtesy of the Enforcer Plugin, told me that my Maven v 2.2.0 was no good. Reading through the poms, I'm deciding it must be your fault :)

13:17 cemerick: esj: Indeed, v2.2.0 won't do :-)

13:17 clojurebot: #<RuntimeException java.lang.RuntimeException: org.apache.http.conn.HttpHostConnectException: Connection to https://api.del.icio.us refused>

13:17 zmyrgel: hmm, I'm trying to assoc new value with my state record but it fails with "String cannot be cast to Associative"

13:18 cemerick: esj: IIRC, v2.2.0 didn't play well with gpg, used for signing artifacts

13:19 amalloy: jimdagem: (declare fib) (def fib (memoize (fn [x] ...))) is the hack i use

13:19 esj: cemerick: cool, I should be on the latest stable anyway. Now I just have to figure out how to make clojure:swank come back.

13:20 jimdagem: amalloy, sweet!

13:20 zmyrgel: here's the code piece causing the error: http://pastebin.com/c38Lq91F

13:20 jimdagem: clojure is so neato

13:20 fliebel: My bug: http://dev.clojure.org/jira/browse/CONTRIB-101

13:21 amalloy: zmyrgel: your state is being set to a string instead of a map somehow, is what your error message says

13:21 or your move, i guess

13:22 fogus_: pdlogan: You sir are a glutton for painful twitter conversations. ;-)

13:23 amalloy: although, jimdagem, better still is not to memoize fib at all

13:23 zmyrgel: hmm, I'll check what gets passed to the function

13:23 amalloy: jimdagem: http://rosettacode.org/wiki/Fibonacci_sequence#Clojure

13:26 zmyrgel: ha, my previous function returned a string instead of associating it with a state

14:02 Phantom_Hoover: ([f xs] (reduce (fn [a x] (+ a (f x))) 0 xs)))

14:03 Does Clojure pattern match with vectors?

14:03 amalloy: Phantom_Hoover: not as far as i know, but i'm not sure i understand what your snippet is supposed to do

14:03 Phantom_Hoover: Wait, me neither...

14:04 chouser: heh

14:04 amalloy: wow, a hit and run

14:04 esj: grin

14:11 pdlogan: fogus_: I simply unfollowed him. nevermore.

14:32 KirinDave: technomancy: I do not understand octo-inc's utility. Is this trololo time or am I yet again too obtuse for this community? :)

14:32 pppaul: (defn 2d-map [fn 2d-array]

14:32 (map (fn [row]

14:32 (map fn row))

14:32 2d-array))

14:32 is something like that in core?

14:33 Chousuke: no

14:33 technomancy: KirinDave: oh man we use oinc all the time. it's like the fibbonacci of sonian.

14:33 alpheus: Is there something like binding that will work across threads?

14:33 chouser: alpheus: binding in 1.3 :-/

14:33 amalloy: alpheus: ##(doc bound-fn)?

14:33 sexpbot: ⟹ "Macro ([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."

14:34 tonyl: or def ?

14:34 KirinDave: technomancy: Trololo

14:34 technomancy: chouser: it's not binding though; it's with-redefs, isn't it?

14:34 KirinDave: exactly.

14:34 KirinDave: technomancy: Link to isthereaproblem.com

14:34 chouser: heh. depends on what you want. all these answers are good.

14:35 KirinDave: chouser: Didn't you have some rationale for not using :use, or using with with blank :onlys or something?

14:35 chouser: I think I remember you mentioning this, but I can't remember why. it came up the other day.

14:35 fliebel: Would it be doable/easy/useful to implement things like agents, refs and atoms over a network, for managing state of multiplayer/-user games/applications?

14:35 alpheus: tonyl: def just changes the root binding, so I don't think that's what I want.

14:36 amalloy: fliebel: you want the state in a server somewhere, right? if you rely on the clients to keep it, it's easy to cheat

14:36 chouser: alpheus: with-redefs temporarily changes the root binding, binding in 1.3 automatically passes the dynamic state across 'future' and 'send' calls

14:36 alpheus: short of those, see bound-fn

14:37 alpheus: So, bound-fn for now, then just call future directly in 1.3?

14:38 chouser: KirinDave: 'use' has a superset of 'require's fetures, plus a bad default. so using :only [] in 'use' means it behaves sanely to start with, and then you can add/remove options as needed without switching to/from 'require'

14:38 fliebel: amalloy: I'm thinking of keeping the state on the server, but do (swap) or (send) or whatever sortof RMI style.

14:38 chouser: alpheus: that should do it.

14:38 ossareh: technomancy: stupid question, why is oinc any different than (+ 8 x) ?

14:38 KirinDave: ossareh: needs more obfuscation.

14:39 hiredman: the infamous octo-inc

14:39 pjstadig: o stands for octo

14:39 hiredman: well played

14:40 ossareh: KirinDave: I'm referring to this: http://twitter.com/#!/technomancy/status/4617786731008000

14:40 KirinDave: ossareh: So was I

14:40 ossareh: I'm confused then :)

14:41 pjstadig: oinc is much cooler than (+ 8 x)

14:41 technomancy: it's "more functional"

14:41 since it involves more functions.

14:41 pjstadig: and shorter

14:41 tonyl: where is this oinc?

14:41 KirinDave: Lazier

14:41 ossareh: tonyl: see the link above

14:41 pjstadig: and we all know short and incomprehensible is better than long and understandable

14:41 chouser: has a bug

14:41 fliebel: technomancy: Hoave you seen my awesome function for generating an infinit lazy seq of ones?

14:42 ossareh: chouser: followed up in the next tweet

14:42 http://twitter.com/#!/technomancy/status/4618155515191296

14:42 chouser: oh

14:42 hiredman: ,(nth (iterate inc 1) 7)

14:42 clojurebot: 8

14:43 fliebel: What is the difference between base and ancestors?

14:43 ossareh: technomancy, KirinDave: I'm not at the level of foo that I get either the application or the humour behind this :)

14:43 KirinDave: Well, I heard that you liked function calls

14:44 So Phil put some function calls in your function calls

14:45 amalloy: hiredman: i was looking around for your pl macro this morning, but i can't seem to find it

14:46 fogus_: ,(let [oinc (fn [n] (reduce + n (map #(%) (repeat 2r000001000 #(*)))))] [(oinc 8) (oinc 32)])

14:46 clojurebot: [16 40]

14:48 technomancy: fogus_: hats off to you sir.

14:48 pjstadig: holy crap fogus_

14:48 amalloy: fogus_: #(*) is comical

14:48 KirinDave: So what are people using for date handling these days?

14:48 pjstadig: you have a new presentation for the meetup

14:48 KirinDave: Just raw-dogging on Joda Time?

14:48 ossareh: KirinDave: joda

14:49 KirinDave: Wasn't clj-time gonna start to bite into that?

14:49 fogus_: There must be a better way to obfuscate the number 8 than 2r000001000

14:49 amalloy: fogus_: (count "fourteen")?

14:49 fogus_: oooo, that's pretty cool

14:50 KirinDave: technomancy: You know, there's got to be something amusing you could do with the way clojure handles arglists.

14:50 ossareh: KirinDave: http://dev.clojure.org/pages/viewpage.action?pageId=950382 <- this is good. clj-time has some very good work in it.

14:50 hiredman: clojurebot: transform

14:50 clojurebot: transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj

14:50 hiredman: amalloy: somewhere there

14:50 amalloy: ah, thanks

14:50 pjstadig: church numerals?

14:51 * ossareh just had it dawn on him that the current trend is creating obfuscated code

14:51 fogus_: pjstadig: need to think of how to fit that into a tweet

14:51 fliebel: ossareh: How do you do those italic messages you just did?

14:51 amalloy: fliebel: /me whatever

14:52 and how they show up depends on your client. they don't look italic to me

14:52 * fliebel thinks he gets it

14:53 KirinDave: I wonder if you can get an arglist where it does work.

14:56 fogus_: This is kinda weird: (defn oinc [num] (reduce + num (map #(%) (repeat (inc (count (str (:arglists (meta oinc))))) #(*)))))

14:57 amalloy: fogus_: that's horrible. but like, horrible-good

14:58 ossareh: fwiw, all this obfuscated clojure is somewhat like what I'm working with now: imovie.

14:58 amalloy: fogus_: ##(first (nth (iterate (fn [[a b]] [b (+ a b)]) [0 1]) 6)) maybe?

14:58 sexpbot: ⟹ 8

14:59 amalloy: cause you might as well compute some fibonacci numbers if you're going to add eight

15:00 esj: KirinDave: clj-time is built around joda AFAIK

15:05 fogus_: I think I'll just stick with this one: (defn oinc "fourteen" [n] (reduce + n (map #(%) (repeat (.length ((keyword (apply str (map char [100 111 99]))) (meta (var oinc)))) #(*)))))

15:06 140 chars FTW!

15:07 chouser: Curious George golf

15:07 kotarak: What is this oinc stuff about?

15:08 amalloy: kotarak: there seems to be a competition to come up with the grossest way to write #(+ 8 %)

15:08 kotarak: oh, ah,

15:08 Kjellski: ping?

15:08 clojurebot: PONG!

15:09 Kjellski: ,(indexed (seq "Where are you"))

15:09 clojurebot: java.lang.Exception: Unable to resolve symbol: indexed in this context

15:09 kotarak: ,(map-indexed vector "Here")

15:09 clojurebot: ([0 \H] [1 \e] [2 \r] [3 \e])

15:09 tonyl: &(String/parseInt "3" 10)

15:09 sexpbot: java.lang.IllegalArgumentException: No matching method: parseInt

15:09 tonyl: what?!

15:09 kotarak: ,(Integer/valueOf "3" 10)

15:10 * fogus_ just set the respectability of Clojure back 5 months

15:10 clojurebot: 3

15:10 amalloy: tonyl: Integer/parseInt

15:11 Kjellski: kotarak: thanks a lot ^^ was looking at the docs, and they´re unfortunately wrong... http://richhickey.github.com/clojure-contrib/seq-utils-api.html

15:11 kotarak: Or am I?

15:11 amalloy: Kjellski: neither

15:11 kotarak: Kjellski: The docs are now at clojure.github.com/clojure-contrib

15:11 amalloy: that function is in clojure.contrib.seq-utils, not in core

15:12 &(require clojure.contrib.seq-utils)

15:12 sexpbot: java.lang.ClassNotFoundException: clojure.contrib.seq-utils

15:12 amalloy: &(require 'clojure.contrib.seq-utils)

15:12 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/seq_utils__init.class or clojure/contrib/seq_utils.clj on classpath:

15:12 Kjellski: What a mess, sorry but where do I need to look at if I want to see just the latest docs?

15:12 amalloy: bah

15:12 kotarak: Kjellski: http://clojure.github.com/clojure (resp. ....-contrib)

15:13 Kjellski: kotarak: Thanks in advance for the next years ^^

15:13 tonyl: :P

15:13 kotarak: Kjellski: you are welcome >^.^<

15:23 tonyl: &(reduce + (map #(Integer/valueOf (str %) 10) (remove #(= % \.) (subs (str Math/PI) 0 4)))

15:23 sexpbot: java.lang.Exception: EOF while reading

15:23 tonyl: &(reduce + (map #(Integer/valueOf (str %) 10) (remove #(= % \.) (subs (str Math/PI) 0 4))))

15:23 sexpbot: ⟹ 8

15:26 amalloy: tonyl: #{\.} is the same as #(= % \.)

15:28 tonyl: wow

15:29 how if it is a set ...

15:29 &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4)))

15:29 kotarak: ,(#{\.} \.)

15:29 clojurebot: \.

15:29 tonyl: oh man

15:29 raek: well, a set used as a function will not return true/false, but the-element/nil

15:29 kotarak: ,(#{\.} \a)

15:29 clojurebot: nil

15:29 amalloy: &(map #{:a :b :c} [1 2 3 :a 3 :b])

15:29 sexpbot: ⟹ (nil nil nil :a nil :b)

15:30 raek: but for truthiness, it's requivalent

15:30 tonyl: i knew that and i can't still wrap my head around the possibilities

15:30 &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4)))

15:30 sexpbot: java.lang.Exception: EOF while reading

15:30 raek: :)

15:30 kotarak: ,(some #{false} [true true false true]) ;:P

15:30 clojurebot: nil

15:31 tonyl: &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4))))

15:31 sexpbot: ⟹ 8

15:31 amalloy: tonyl: my favorite example of using objects as functions: ##(filter (comp #{"david"} :first) [{:first "steve" :last "smith"} {:first "david" :last "roberts"}])

15:31 sexpbot: ⟹ ({:first "david", :last "roberts"})

15:31 tonyl: composing a set and a keyword

15:32 thanks guys, clojure doesn't stop amazing me

15:34 Kjellski: Somebody with a fresh install of clojurebox arround? Could you try to define a namespace in a file buffer and use C-c C-c to run?

15:37 alpheus: kotka has a nice write-up on bound-fn: http://kotka.de/blog/2010/05/Did_you_know_IV.html

15:37 Kjellski: Right now, C-c C-c over (ns foo.bar) leads to "No such namespace: de.kjellski.games.bagels [Thrown class java.lang.Exception]" ...

15:45 raek: Kjellski: does the same thing happen with C-x C-e and C-M-x ?

15:45 (I don't have clojurebox)

15:45 talios: Morning.

15:46 Kjellski: raek: Hmmmm, that leads somewhere... it seems to work with C-x C-e when I´m at the end of the whole sexp...

15:48 raek: And surprisingly the C-c C-c works there as well....

15:48 raek: At least a nice workarround, thanks!

15:49 raek: Kjellski: C-M-x should work "in the middle"

15:50 Kjellski: raek: There you go, thanks, it works in the middle as well =)

15:51 raek: =( but I was already used to C-c C-c in the last version of ClojureBox...

15:54 amalloy: well, i guess he left. but emacs does the same thing for C-c C-c, if you haven't already compiled the whole file once with C-c C-k, in my experience

15:57 sthuebne_: I've just noticed technomancy's and cemerick's tweets regarding version ranges. That reminded me to ask, how the DSL for Lein/Maven/anythng is coming along?

16:00 pppaul: anyone think that something like this would be useful in contrib?

16:00 user=> (def matrix [[1 2][3 4]])

16:00 user=> (map-2d #(* % 2) matrix)

16:00 ((2 4) (6 8))

16:00 ((user=> (map-2d #(* %1 %2) matrix matrix)

16:00 ((1 4) (9 16))

16:02 or something like a function/macro that is a nested map of n depth?

16:03 or, am i nuts?

16:04 LauJensen: You guys know when you do a SELECT statement in the mysql client, you get a really nicely formatted table as the output? Do we have a pretty printer for that in clojure-land ?

16:05 pppaul: there is a pprint

16:05 contrib.pprint and core

16:05 LauJensen: pppaul: I know, but does it handle resultset-seqs ?

16:06 pppaul: example?

16:06 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

16:06 kotarak: LauJensen: you can specify format strings on steroids.

16:06 kind a map-like

16:07 (the function map, not the structure map)

16:07 sthuebne_: format is voodoo

16:07 LauJensen: Ah right, format might be the ticket. It would have been in CL thats for sure

16:08 thanks kotarak

16:08 kotarak: btw, clojureql 1.0.0-beta1 release is now imminent :)

16:08 kotarak: you are welcome, my danish friend

16:08 LauJensen: I'm following it.

16:09 LauJensen: Hopefully tomorrow or the day after at the latest

16:10 scottj: what did you guys think of clojurize?

16:11 LauJensen: scottj: is it a movie that just came out?

16:11 sthuebne_: LauJensen: BTW: what's the state of affairs regarding DSL for pom/project.clj

16:11 =

16:11 ?

16:11 LauJensen: sthuebne_: read the google group 'project.clj spec'

16:11 sthuebne_: oh

16:11 I wasn't aware of that

16:12 stuartsierra: The State of Affairs is: Growling and gnashing of teeth

16:12 scottj: http://anvil.io/2010/10/25/clojurize-the-data-not-the-database.html

16:12 sthuebne_: LauJensen: thanks for the pointere!

16:12 Jesus, I miss my keyboard

16:13 LauJensen: scottj: its not really interesting to me

16:13 sthuebne_: nps :)

16:13 scottj: LauJensen: why? it seems very similar to clojureql

16:14 LauJensen: scottj: Its totally different. Its based on SQL

16:26 clizzin1: this is a pretty dumb question, but how do i convert a map to a sorted-map?

16:27 amalloy: clizzin1: ##(into (sorted-map) {1 2. :a 4})

16:27 sexpbot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Keyword

16:27 amalloy: bleh whatever. do it like that

16:28 clizzin1: thanks amalloy!

16:33 LauJensen: I need the latest artifact for clojure.contrib.sql, where do I find its group/artifact-id ?

16:36 talios: LauJensen: that

16:36 kotarak: org.clojure.contrib/sql maybe?

16:36 talios: that's mentioned in the pom - https://github.com/clojure/clojure-contrib/blob/master/modules/sql/pom.xml - org.clojure.contrib:sql

16:36 LauJensen: kotarak: I dont need the name itself as much as I need a method for getting that an other artifact names. hudson isnt being very helpful

16:36 ah right

16:37 And these modules are only available from 1.3.0 right?

16:37 talios: I believe so yes.

16:37 the split up was post 1.2

16:42 clizzin1: if i want to write a custom compare function in clojure for use in sort-by, how do i make it implement java.util.Comparator?

16:43 sthuebne_: stuartsierra, LauJensen Now, I'm up-to-date. A clash of philosophies.

16:43 LauJensen: sthuebne_: What are we talking about now?

16:43 sthuebne_: sorry ,-)

16:43 project.clj

16:43 LauJensen: ooh :)

16:45 sthuebne_: What is the goal of a unified DSL for describing builds?

16:47 LOPP: clizzin all functions are comparators

16:47 clojurebot: functions are maps

16:47 sthuebne_: the existing build tools, that happen to use similar dialects for build specs, work very different. on purpose I suppose

16:47 LOPP: they will fail to work if they don't have 2 arguments

16:48 LauJensen: sthuebne_: Ease of implementing these. Right now consumers of project.clj have to make 1 implementation for each build tool

16:48 Even simple builds fail to run of all 3 tools, which sucks

16:48 sthuebne_: I see that.

16:51 it seems, that only simple builds are likely to be portable between the three

16:51 LauJensen: True

16:52 sthuebne_: correct me if I'm wrong, but Lein plugins work very different (on a different level) than Maven plugins.

16:52 LauJensen: Very differently

16:52 talios: I think the goal of a unified DSL for builds is good, but fundamentally flawed.

16:53 sthuebne_: there might be a chance to align plugin names and to make sure, that plugins exist in both/all three worlds

16:53 LauJensen: sthuebne_: http://stackoverflow.com/questions/3906276/whats-the-difference-between-cake-and-leiningen - See lancepantz reply

16:53 sthuebne_: that provide the same behaviour

16:53 talios: sthuebne_: really? you're going to implement EVERY SINGLE MAVEN PLUGIN?

16:53 ejb? xml paring? osgi?

16:53 sthuebne_: talios: no!

16:54 talios: sthuebne_: and thus dies the aim of a cross build that works :(

16:54 sthuebne_: I was thinking of the opposite - have maven plugins where Leiningen's plugins are unique

16:54 but that seems sort of stupid as well

16:55 why multiplying efforts

16:55 talios: true, but given anyone can create lein plugins, and people often do ( such as Brian Marrick's midge plugin ) - it'll be an endless game of rinse and repeat

16:55 sthuebne_: exactly

16:55 technomancy: I don't really understand the motivation. Do you see people wanting to use make to build clojure because they are opposed to greenspunning?

16:55 talios: unless you mean "core" plugins

16:56 technomancy: autoconf for the win :-)

16:56 they don't even use make anymore :)

16:56 * talios hides

16:56 technomancy: talios: I almost said autoconf but didn't want to give anyone the shivers =)

16:57 talios: you're too nice then.

16:58 LauJensen: I would really love a Clojurish build tool which plugged into the entire Maven world, plugins going back and forth etc

16:59 I will call it : Mavadvenjure

17:00 talios: LauJensen: if it's declaritve only, it could be doable. but the moment you bring in any form of dynamic scripty ness, you lose that two-way round trip. as the DSL builds a model that can't generate itself (only its canonical representation)

17:01 sthuebne_: I head a brief chat with Jazon van Zyl earlier this year. I was asking him (since pmaven was new to me back then), whether pmaven would provide anything like a "scriptable" build.

17:01 talios: which, when you look at things like the maven-release-plugin which update version numbers, could be an issue.

17:01 sthuebne_ - my origin clojure-pmaven work had full scriptable ness, to generate the model.

17:02 as does the groovy and scala versions

17:02 sthuebne_: yeah, that's what they do - they generate the model

17:03 talios: that's really all they can do, its also what gradle does

17:03 sthuebne_: maybe I didn't understand the current implementation of it, but it seemed to me to be really just a different language to describe the model. how would you add dynamics?

17:04 LauJensen: I hate to leave in the middle of this, but I have to, goodnight everybody

17:04 talios: mmm, i see the wiki's not been updated, but in my original code, you could do: (if-not (contains-plugin? main "some.groups:plugin")

17:04 (add-plugin! main ["some.groups:plugin:1.0" {:configuration {:name "value"}}]))

17:05 dynamically adding a dependency, you could dynamically modify/update/add plugins etc.

17:05 I guess the core question to ask is.... what kind of dynamic nature do you want.

17:06 LOPP: I often see #' in the code

17:06 I forgot...when am I supposed to use that

17:07 cemerick: LOPP: that give you the named var, rather than its value

17:07 &#'+

17:07 sexpbot: ⟹ #'clojure.core/+

17:07 cemerick: &+

17:07 sexpbot: ⟹ #<core$_PLUS_ clojure.core$_PLUS_@b5f87c>

17:07 cemerick: same as (var +)

17:07 LOPP: ok but why do you use that

17:07 talios: 'lo cemerick

17:08 cemerick: LOPP: so you can do things with vars instead of their values :-)

17:08 talios: afternoon :-)

17:08 talios: morning :-) 11:11am here.

17:08 * cemerick thankfully missed the pmaven conversation

17:08 sthuebne_: talios: grep doesn't find any "add-plugin" on master

17:08 cemerick: talios: damn! :-P

17:09 sthuebne_: sorry, I've started it.

17:09 talios: sthuebne_: sadly when antony ported/rewrote my initially implementation he removed all those dsl things ;(

17:10 sthuebne_: I was late to the project.clj--spec discussion in the first place

17:10 * talios hasn't looked at, or touched pmaven since january.

17:10 sthuebne_: that's a long time indeed

17:11 talios: work and the podcast got in the way, along with the realization that it was mostly a futile effort.

17:12 sthuebne_: from the current perspective it's just a different language to express the very same thing

17:12 talios: that looses the two-way roundtrip nature, and breaks the ecosystem.

17:13 sthuebne_: realizing that, I was asking myself what the actual point would be, to have a clojure-ish POM

17:14 talios: XML is evil didn't you know?

17:15 sthuebne_: sure, whatever they say

17:17 stuartsierra: talios: any idea why this fails?

17:17 http://build.clojure.org/job/clojure-testbuild/8/console

17:17 * talios looks

17:17 LOPP: is there a reason not to use #'x instead of x?

17:18 sthuebne_: its verbose, OK. but honestly, I can write POMs for fairly complex builds by just using nXML in Emacs and nobody ever exposed me to a build tool, that wouldn't force me to write my builds in one or another language myself

17:18 amalloy: LOPP: they're different things

17:18 Raynes: &(macroexpand '#'blah)

17:18 sexpbot: ⟹ (var blah)

17:18 amalloy: &(#'first first)

17:18 sexpbot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$first

17:18 amalloy: &([#'first first])

17:18 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentVector

17:18 Raynes: &(macroexpand first)

17:18 sexpbot: ⟹ #<core$first clojure.core$first@615dc4>

17:18 amalloy: damn it. whatever

17:18 &[#'first first]

17:18 sexpbot: ⟹ [#'clojure.core/first #<core$first clojure.core$first@615dc4>]

17:18 LOPP: &(#'first [1 2])

17:18 sexpbot: ⟹ 1

17:18 Raynes: #'something is just shorthand for (var something)

17:19 LOPP: since #'first works just as well as first, why not always use #'?

17:19 amalloy: LOPP: #' only works for things that *have* vars

17:19 Raynes: Why would you want to do that in the first place?

17:19 amalloy: (or are vars, if you prefer)

17:20 LOPP: because I have code that uses values

17:20 Raynes: Since (identity (identity (identity 5))) works as well as 5, why not always do that?

17:20 LOPP: then it turned out I had to use #' in various places for it to work properly

17:20 that got me thinking, why not preemptively use #' everywhere I can

17:20 so far I can see no reason

17:21 amalloy: LOPP: it's a terrible idea. why not check (foo != null) every time you call a method on foo, just in case it's become null when you weren't looking?

17:21 in both cases, you're better off actually understanding the difference

17:22 talios: stuartsierra: hmmm, is clojure.java.io.Coercions a .java or .clj file? if the later my guess is the namespace is turning up later in the build path? If you run mvn with -X and get all the debug output we can see the actual command line we're calling

17:22 stuartsierra: neither, it's a protocol defined in io.clj

17:23 LOPP: the problem is where I use lists of listener functions subscribed to events

17:23 if I change the function the handler of course doesn't

17:23 but ok

17:23 here's another question

17:23 why is conj '[1 2 3] faster than conj [1 2 3]

17:24 sorry

17:24 amalloy: LOPP: if you want to change things, my suggestion is to use something with real STM semantics, like an atom, instead of abusing vars

17:24 stuartsierra: talios: What I don't get is that it works the first time, when it does "mvn clean verify" then fails when it does "mvn deploy"

17:24 * Raynes doesn't think he meant to sound snarky.

17:24 LOPP: the whole map is in a ref

17:24 but it's a map of vectors of sets

17:25 no matter

17:25 &(time (dotimes [n 100000] (conj '[1 2 3] 4)))

17:25 sexpbot: ⟹ "Elapsed time: 14.451 msecs" nil

17:25 LOPP: &(time (dotimes [n 100000] (conj [1 2 3] 4)))

17:25 sexpbot: ⟹ "Elapsed time: 29.008 msecs" nil

17:26 LOPP: why the difference?

17:26 amalloy: you want to...what, be able to change the definition of a listener function with a new defn, and have the objects who were tracking those automagically use the new function of the same name?

17:26 talios: stuartsierra: right - i see no reference to io.clj being compiled before hand in the deploy step, but it does in the first set. thats.... weird.

17:26 amalloy: i mean, yes, that's kinda what vars are for, but it seems like a weird thing to want

17:27 LOPP: don't worry, I'm just messing around a bit... don't really need the solution right now

17:27 Raynes: LOPP: Well, it isn't evaluating anything inside of the vector, for one.

17:28 I'm not exactly sure why it would be faster.

17:28 LOPP: here's another problem I have a very unelegant solution for: you have a vector of sets and you need to return a vector of sets where all the intersecting sets are combined

17:28 talios: stuartsierra: if you configure maven to run with -X we can see if the plugins just not telling the compiler to compile io, or if its clojure itself.

17:28 LOPP: yeah it's weird...I mean, won't it have to evaluate that eventually?

17:29 amalloy: all the...intersecting sets are combined? what do you mean by "intersecting" and "combined" here? or give a small-scale example?

17:30 _mst: I remember something (from the clojure group, probably) about the quoted form allowing the reader to create the vector data structure once up front and reuse it for each call

17:30 LOPP: sure

17:30 _mst: whereas the unquoted variant would create a new vector for every iteration

17:30 but that might be complete rubbish... or I might have dreamt it. I can't find where I read it :)

17:30 stuartsierra: talios: ok, running now at http://build.clojure.org/job/clojure-testbuild/10/console

17:30 LOPP: [#{:a :b :c} #{:c :d} #{:e :f}] -> [#{:a :b :c :d} #{:e :f}]

17:31 [#{:a :b} #{:c :d} #{:b :c :e}

17:31 -> [#{:a :b :c :d :e}]

17:31 amalloy: i see

17:32 LOPP: I did it but it was ugly as hell

17:32 very javaish

17:33 amalloy: off the top of my head, it looks like you want to use reduce, some, and update-in to do the heavy lifting

17:33 stuartsierra: talios: Nuts, same failure, no new information.

17:34 sthuebne_: talios, stuartsierra the order clj-files are compiled is completely different in both steps

17:34 stuartsierra: yes, I think that has something to do with it

17:34 but in theory it shouldn't matter

17:36 clojure.java.shell declares :use on clojure.java.io, so clojure.java.io should get compiled automatically when you try to compile clojure.java.shell

17:36 jarpiain: LOPP: (conj '[1 2 3] 4) and (conj [1 2 3] 4) generate exactly same bytecode in 1.3

17:37 stuartsierra: wait a minute

17:38 "Exception… at clojure.java.shell__init.<clinit>(Unknown Source)"

17:38 talios: stuartsierra: i thought use didn't alter order, but require did

17:38 stuartsierra: talios: Nothing alters order, but any ns that loads other namespaces will cause them to be compiled when it is compiled.

17:38 *BUT*

17:38 In this instance, clojure.java.shell is being loaded from a .class file, not from source.

17:39 I don't know why

17:39 talios: Hrm

17:39 LOPP: I don't see where I'd use update-in, I have no nesting

17:40 amalloy: yeah, i'm wrong about that part :P

17:40 i'm writing it now

17:42 talios: stuartsierra: weird, in the deploy/release phase, that .class shouldn't yet exist as target/checkout/classes should be where it's looking..... *blink* or is the plugin looking at the wrong place and finding the .class from target/classes ( which would explain it )

17:43 LOPP: I basically combined each set with other set and compared sizes, if it wasn't the sum of the 2 sets I combined then they intersect. However that only works for 2 individual sets, so I had to do iterations of this and I had to rotate which set I started the iteration with. In the end quite ugly.

17:43 stuartsierra: There's something screwy going on with directories, that's for sure.

17:43 talios: odd that -X didnt give the debug info I expected

17:44 stuartsierra: It's becasue the deployment is being controlled by the Sonatype OSS release parent POM

17:44 talios: I'll do some digging when I get home tonight

17:44 stuartsierra: talios: ok, thanks, appreciate it

17:44 sthuebne_: talios: it should report the classpath for plugins, shouldn't it?

17:46 talios: sthuebne_: in this instance its not the classpath of the plugin that's actually the problem, more the directories being configured for it.

17:46 I suspect I've hardcoded a target/classes reference

17:46 or more "outputdirectory/classes"

17:47 sthuebne_: but that should work in case of "release:perform" a ka deploy as well

17:48 talios: but in this case, that {outputdir}/classes still has the .class files from the prepare phaze

17:48 a work around could be release:prepare clean release:perform

17:49 amalloy: LOPP: https://gist.github.com/0557059ea1585b322cec

17:49 sthuebne_: are you shure about that?

17:49 amalloy: not very elegant, but functional (pun intended)

17:49 sthuebne_: release:perform forks a new maven process on a different dir

17:49 which is target/checkout

17:50 so, how could the clojure plugin in that other process get hold of the .class files of the former?

17:51 talios: i have NO idea :) the clean step would just proove that. it's possible I'm looking at the wrong var and the one I'm looking at it always "target"

17:53 sthuebne_: OR does one of the profiles do something fishy with sourceDir/outputDirß

17:55 LOPP: I'll check it out

17:56 about 3 times shorther than what I wrote

17:56 :)

17:56 make that 5

17:57 amalloy: oh, i didn't include it in the gist, LOPP, but you have to (use 'clojure.set)

17:57 talios: sthuebne_ - not sure, the log says its all looking at target/checkout/target/* so I'm confused. tho I can't look at it just now work. darn day job ;)

17:58 LOPP: right...what does clojure.set do anyway?

17:58 amalloy: intersect, union, that sort of stuff

17:58 LOPP: all those fns are too complicated

17:58 amalloy: you can write your own union with into, but i assume clojure.set does it better

18:00 quizme: are the clojure conj videos posted online?

18:01 LOPP: what's old-form arg in if-let?

18:02 amalloy: LOPP: something deprecated, don't use it

18:03 sthuebne_: talios: well, my day job is starting in about 7hrs. So I say n8 for now

18:03 chouser: & (if-let a 5 true)

18:03 sexpbot: java.lang.IllegalArgumentException: if-let requires a vector for its binding

18:05 mjg123: Hello - is "init" a special name for clojure in deftype'd types?

18:05 If I wanted to implement javax.servlet.Servlet#init(ServletConfig), how could I do that?

18:07 I tried: javax.servlet.Servlet (init [this config] ( ... something ... )) - but no init() method is generated in the .class file

18:07 amalloy: &(if-let a 5 true false)

18:07 sexpbot: java.lang.IllegalArgumentException: if-let requires a vector for its binding

18:09 bhenry: chouser amalloy ???

18:09 amalloy: bhenry: trying to figure out how to use the old form of if-let to tell LOPP what not to do. fortunately (i guess?) it's hard

18:10 LOPP: :D

18:10 yeah :)

18:10 well I won't use it

18:13 pppaul: can i use cons cells as keys in my hash-map?

18:14 i'm trying and they aren't working... i day or so ago i thought i did some tests that showed i could... maybe they were flawed?

18:15 forest

18:15 {(1 0) :grass, (0 0) :tree, (1 1) :grass, (0 1) :grass}

18:16 that is the hash-map i have, but i have trouble using (get) on it

18:17 oh i was using get wrong (arg pos was in wrong order)

18:17 dnolen: ,{[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass}

18:17 clojurebot: {[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass}

18:18 dnolen: ,((juxt [1 0] [0 0] [1 1] [0 1]) {[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass})

18:18 clojurebot: java.lang.IllegalArgumentException: Key must be integer

18:18 dnolen: oops

18:22 pppaul: cons cells work

18:22 i was using get like this (get :key :map)

18:22 LOPP: hm amalloy your code for sets doesn't work

18:22 (def sets [#{:a :c :b} #{:d :e} #{:c :e}])

18:23 (#{:a :c :b :e} #{:d :e})

18:23 which is wrong result

18:24 I had the same problem, in one pass I only paired the first set with all I could find, but not the others

18:29 tonyl: LOPP do you need to keep the number of sets in the vector? or can it be just one holding all the results?

18:44 amalloy: LOPP: ah, right. because it's not going back and filtering in old sets that now match

18:44 tricky

18:45 LOPP: yes

18:45 that's the thing...by combining sets you get new matches

18:46 nickik: is there a function to write a vector one value per line into a file

18:46 amalloy: i did something like this in CL in like...april, i think. but there was a guarantee that the final result would be exactly two sets

18:47 LOPP: one thing you can do is maybe put iterate around it and check for when the sequence stabilizes

18:47 amalloy: yeah, i was thinking that too. so gross :P

18:48 LOPP: in any case this is one devilishly complex problem yet it looks so simple, a human can do it easily

18:48 amalloy: LOPP: a human can do it easily for small numbers of small sets

18:48 LOPP: that's true

18:49 tonyl: nickik: something like (doseq [x myvec] (spit myfile (print-str x \newline))

18:49 LOPP: well I did the thing with iterate and the seqence doesn't stabilize, the order of sets keep changing even though the sets themselves don't

18:50 amalloy: hah

18:50 tonyl: LOPP: does it have to keep the number of sets in the vector?

18:50 amalloy: well, that's easy though

18:50 just have it operate on a set instead of a vector

18:51 tonyl: or can it output all the items in 1 set as a result

18:51 powr-toc: does anyone know what happened to clojure.contrib.repl-utils/show ?

18:51 I've just updated to 1.2.0

18:51 amalloy: powr-toc: i it's in clojure.repl now, i think

18:51 powr-toc: amalloy, I can't see it in there

18:51 amalloy: or maybe not? i always lose it too

18:51 LOPP: but you want the sets to rotate

18:52 because otherwise you might get stuck as in some cases you keep picking same first set as the starting set

18:52 and you might not progress

18:52 kjellski: What is the right way to look at wethere a seq contains an element or not?

18:52 amalloy: kjellski: ##(doc some)

18:52 sexpbot: ⟹ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

18:53 amalloy: LOPP: ? every iteration you'll be removing one element

18:53 kjellski: amalloy: ty

18:53 powr-toc: has show been removed from contrib?

18:53 tonyl: &(apply union [#{:a :c :b} #{:d :e} #{:c :e}])

18:53 sexpbot: java.lang.Exception: Unable to resolve symbol: union in this context

18:54 raek: powr-toc: don't think so

18:55 powr-toc: raek, Then where is it?

18:55 tonyl: it is not in clojure.contrib.repl-utils/show ?

18:55 amalloy: tonyl: ##(use 'clojure.set)

18:55 sexpbot: ⟹ nil

18:55 tonyl: &(apply union [#{:a :c :b} #{:d :e} #{:c :e}])

18:55 sexpbot: ⟹ #{:a :c :b :d :e}

18:56 raek: &(clojure.contrib.repl-utils/show Object #"toString")

18:56 sexpbot: java.lang.ClassNotFoundException: clojure.contrib.repl-utils

18:56 raek: &(require 'clojure.contrib.repl-utils)

18:56 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:

18:56 tonyl: &*clojure-version*

18:56 sexpbot: ⟹ {:major 1, :minor 2, :incremental 0, :qualifier ""}

18:56 raek: well, I used it yesterday

18:57 amalloy: it's around /somewhere/, but it always takes me ages to find it

18:57 powr-toc: raek: it seems to have vanished for me too :-\

18:57 tonyl: &(find-doc "^show")

18:57 sexpbot: ⟹ ------------------------- clj-time.format/show-formatters ([] [dt]) Shows how a given DateTime, or by default the current time, would be formatted with each of the available printing formatters. ------------------------- clj-github.gists/show-gist ([auth id file-... http://gist.github.com/702762

18:57 powr-toc: surely clojure.repl would be a good place for it

18:57 raek: powr-toc: which version?

18:57 powr-toc: 1.2.0

18:58 of contrib and clojure

18:58 tonyl: it is in my local contrib

18:58 Raynes: raek: Something weird about sandboxes causes *some* contrib things to simply disappear in the sandbox. It appears to happen across all sandboxes.

18:58 powr-toc: tonyl: is that 1.2.0 though?

18:58 tonyl: yeah

18:59 both clojure and contrib

18:59 user=> (find-doc "^show")

18:59 -------------------------

18:59 clojure.contrib.repl-utils/show

19:00 raek: powr-toc: works in my 1.2 repl

19:00 amalloy: maybe you need lein deps to pull in contrib?

19:00 powr-toc: raek: oh right enough it is in repl-utils

19:01 find-doc wasn't showing it... but I guess I hadn't loaded the namespace

19:02 tonyl: &(require '[clojure.contrib.repl-utils :as repl-utils])

19:02 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:

19:02 raek: ah, yes. find-doc will only look at the loaded vars...

19:13 kjellski: I´ve got a seq of vectors and want to compare the second values in these vectors, what´s the most idiomatic way?

19:15 amalloy: compare them how? i mean, to get out a seq of the second elements you can just (map second seq-of-vectors)

19:16 kjellski: amalloy: compare them by =

19:17 amalloy: kjellski: you're not saying what you want to /do/ with the results of the comparison. do you want to group the vectors by second element, for example?

19:18 kjellski: I have a sequence like this ([0 \a] [1 \b] ...) and a second one that goes just like this one... now I want to find the position of the elements that are =

19:19 amalloy: the index is already in the first elements by map-indexed....

19:22 raek: (map #(= (second %1) (second %2)) seq1 seq2)?

19:23 ah. just read the rest of the text. neverminf.

19:23 amalloy: kjellski: sorry, i still don't understand what you're trying to do

19:23 kjellski: amalloy: just a sec, preparing a snipped ^^

19:24 amalloy: I´m trying to translate this python function into clojure: https://gist.github.com/702785

19:24 pppaul: &(take 2 {:a 1 :b 2 :c 3 :d 4})

19:24 sexpbot: ⟹ ([:a 1] [:b 2])

19:25 pppaul: how do i feed that into another map using assoc, or something else?

19:25 amalloy: ah

19:26 kjellski: pppaul: ##(into {} (take 2 {:a 1 :b 2 :c 3 :d 4}))

19:26 sexpbot: ⟹ {:a 1, :b 2}

19:26 amalloy: i think map-indexed is likely just getting in the way, but no matter

19:26 kjellski: pppaul: where {} is your other map?

19:26 pppaul: same map

19:27 i want to do some work on a seq, and assoc back into the map

19:27 amalloy: pppaul: why not use update-in?

19:27 pppaul: cool, i'll look at that

19:27 kjellski: amalloy: I´m still trying to find the right way ^^ open for every solution =)

19:28 pppaul: i'm using this site to help me with the hash-map stuff http://clojure.org/data_structures#Data%20Structures-Maps%20%28IPersistentMap%29

19:28 is there a better place i should be looking at?

19:30 amalloy: &(let [[answer guesses :as data] [[1 2 3] [4 2 1]]] (map = data))

19:30 sexpbot: ⟹ (true true)

19:31 amalloy: &(let [[answer guesses :as data] [[1 2 3] [4 2 1]]] (apply map = data))

19:31 sexpbot: ⟹ (false true false)

19:31 amalloy: kjellski: enough to get you headed in the right direction, maybe?

19:32 kjellski: amalloy: yeah, I hope so... thanks for the start =)

19:55 KirinDave: Hum

19:56 Does anyone here use clojure w/ flume?

19:56 Perhaps have a reference to a library? Google is coming up empty

20:28 vIkSiT: lo all

20:28 anyone here use clojure with hadoop?

20:28 I'm looking for pointers on libs/docs to get started..

20:31 hiredman: vIkSiT: many do, I don't, but most seem to use cascading and cascalog

20:31 vIkSiT: hmm, cascalog I guess would mostly be for querying large datasets.

20:32 I'll check out cascading, thanks. Looking for something a bit more low level though.

20:42 tomoj: vIkSiT: I use it, have no pointers

20:42 am looking for pointers myself

20:42 I must not understand clojure-hadoop

20:44 vIkSiT: tomoj, hehe, you mean you do use clojure-hadoop?

20:44 or you dont? (I can't get it to install using lein, for instance)

20:45 and get into dependency hell if i use it manually in lib/, since lein deps cleans out the lib dir each time!

20:46 tomoj: paste your project.clj?

20:47 vIkSiT: sec

20:47 tomoj: did you add stuartsierra's maven repo?

20:48 vIkSiT: hmm

20:48 i didnt actually.

20:50 tomoj, http://pastebin.com/mMgM2F9d

20:50 tomoj: :repositories {"stuartsierra-releases" "http://stuartsierra.com/maven2"}

20:50 vIkSiT: how exactly do I add that maven repo, btw?

20:50 wow, I didn't know that format worked in lein.

20:50 tomoj: you may also need to add [org.apache.hadoop/hadoop-core-with-dependencies "0.18.3"]

20:50 not sure

20:51 so far I jar after every change, it's terrible

20:51 I'm sure there's a better way with clojure-hadoop

20:51 vIkSiT: hmm.

20:51 tomoj: but I don't want to be stuck on 0.18.3 either..

20:52 vIkSiT: gah.

20:52 technomancy: we ended up ditching hadoop largely because of problems like this

20:53 tomoj: for what?

20:53 technomancy: conduit, through a circuitous route

20:53 vIkSiT: I'm still stuck with this : http://paste.lisp.org/display/116749

20:53 technomancy: granted if you need HDFS there's not really a good alternative.

20:53 but we have lots of small files that we can't afford to keep anywhere but s3

20:53 amrk: conduit? i don't think I've heard of that one..

20:54 technomancy: clojurebot: google clojure conduit

20:54 clojurebot: First, out of 235 results is:

20:54 Stream Processing in Clojure - intensivesystems.net

20:54 http://intensivesystems.net/tutorials/stream_proc.html

20:54 technomancy: clojurebot: botsnack

20:54 clojurebot: thanks; that was delicious. (nom nom nom)

20:54 tomoj: hmm

20:54 vIkSiT: tomoj, my project.clj is updated btw. let me refresh that

20:54 tomoj, http://paste.lisp.org/display/116749#1 is the project.clj

20:55 tomoj: vIkSiT: still not working?

20:56 there is no clojure-hadoop 1.2.0, is there?

20:57 1.2.0-SNAPSHOT is the latest in the repo

20:57 but not published

20:57 (git repo)

20:57 the latest in his maven repo looks like 1.1.0

20:58 vIkSiT: oh hmm

20:58 argh. I didn't notice that, thanks for the pointer tomoj

21:01 tomoj, btw, why is that version of hadoop-core-with-deps at 0.18.3?

21:01 tomoj: that's the one clojure-hadoop is compatible with

21:04 vIkSiT: ah I see.

21:04 tomoj, I'm pretty sure hadoop can be used directly from clojure too?

21:04 rather than have a bunch of wrappers around it?

21:04 has anyone tried that here?)

21:09 tomoj: see in clojure-hadoop

21:09 read the examples in order

21:10 wordcount1 just works directly on the hadoop api

21:10 with some helpers

21:12 if you want to target a more recent version of hadoop I guess you will have to do it raw too

21:12 vIkSiT: true

21:13 tomoj, do you have any public repos of code that works? I've been trying experiments with alexott's clojure-examples/hadoop, but no luck so far..

21:13 tomoj: no, I don't have anything I can publish

21:14 did you already try the examples in clojure-hadoop?

21:15 alexott's example looks like it should work

21:16 if you jar it up, you can run it like this:

21:17 java -cp "lib/*:com.example.foo-0.1.0-SNAPSHOT.jar" clojure_hadoop.job -job com.example.foo.jobs/bar -input input/foo -output output/bar

21:17 (but there must be a better way)

21:25 vIkSiT: tomoj, hmm, looks like clojure-hadoop-job might be a different jar altogether

21:26 mattmitchell: i have a clojure.lang.PersistentStructMap instance, that looks like this: {:count(*) 521845} -- how do i get the value?

21:27 hiredman: clojurebot: how can mattmitchell get teh value?

21:27 clojurebot: Titim gan éirí ort.

21:27 mattmitchell: i've tried (:count(*) my-struct) but that doesn't do it

21:29 hiredman: ,(*)

21:29 clojurebot: 1

21:29 hiredman: ,(:count 1 {})

21:29 clojurebot: {}

21:29 tomoj: vIkSiT: huh? clojure_hadoop.job is surely in the clojure-hadoop jar I use

21:30 ,(:count(*) "fnord")

21:30 clojurebot: "fnord"

21:32 tomoj: why do you have a struct-map with a "count(*)" field?

21:33 mattmitchell: tomoj: this is the result from a mysql select

21:33 tomoj: I see

21:33 maybe munge the keys?

21:34 mattmitchell: tomoj: this seems to work, but awkward: (last (first (seq (first my-struct))))

21:34 tomoj: otherwise you will have to do (def count-* (keyword "count(*)")) (count-* my-struct) or (get my-struct (keyword "count(*")))

21:34 hiredman: is it really a keyword?

21:34 mattmitchell: tomoj: sorry i should've mentioned the struct it wrapped in a list as well

21:35 tonyl: or query with count(*) AS mycount

21:35 mattmitchell: tomoj: yeah thanks, the helps

21:35 dakrone: ,(get {(keyword "count(*)") 1} (keyword "count(*)"))

21:35 clojurebot: 1

21:35 dakrone: ugh, that's ugly

21:36 tonyl: ${(keyword "count(*)") 343}

21:36 &{(keyword "count(*)") 343}

21:36 sexpbot: ⟹ {:count(*) 343}

21:36 tomoj: do you create a new struct for every query?

21:37 mattmitchell: tomoj: it seems to work that way yes, this is using the sql stuff from clojure contrib

21:37 tonyl: you can change your query a bit and use it like this SELECT COUNT(*) AS mycount FROM mytable;

21:37 tomoj: oh

21:37 I'm using the sql stuff from clojure contrib too

21:37 tonyl: ooh ok

21:37 tomoj: I hadn't tried counting yet I guess

21:37 tonyl: haven't used that

21:37 jweiss_: anyone know why github won't highlight this code? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj

21:37 tomoj: I despise c.c.sql

21:38 hiredman: jweiss_: I think it's too big, the hilighter chokes

21:38 jweiss_: ah

21:38 mattmitchell: tonyl: yeah the "count as" is much better thanks

21:39 tonyl: I need a help in speed

21:39 in this code: (reduce + (filter even? (take 4e6 (clojure.contrib.lazy-seqs/fibs))))

21:40 can't make it run any faster when it is 4e5 or higher

21:40 it gives the result back fast when it is 4e4 or less

21:47 freaking computer froze

21:49 &(reduce + (filter even? (take 4e2 (lazy-seqs/fibs))))

21:49 sexpbot: java.lang.Exception: No such namespace: lazy-seqs

21:54 tonyl: can anybody help me to speed up this snippet

21:54 (reduce + (filter even? (take 4e6 fibs)))

21:55 it takes forever (never stops) from 4e5 up

21:56 fibs is a fn: (reduce + (filter even? (take 4e6 (fibs))))

22:04 Iam guessing the overload is in the filtering, it is pretty high numbers

22:05 amalloy: tonyl: unlikely. i think it's just in generating (fibs)

22:05 the four millionth fibonacci number is quite large, which means the jvm is doing a lot of math with BigIntegers to get to it

22:05 and that's a /lot/ slower than ints or longs

22:06 tonyl: yeah i saw a snippet of the fib, those are big numbers

22:09 amalloy: tonyl: (fib n) grows about as fast as (exp 2 n), so it becomes infeasible after a while

22:11 tonyl: I'm trying to figure out how to break down the computation than

22:11 I am trying the project euler challenges and I am stuck in number 2 :P

22:11 pppaul: use the phi equation

22:12 tonyl: thanks pppaul i'll take a look at it

22:13 amalloy: tonyl: also don't bother with filter even. no need to do any division/math, when you know every other fib will be even

22:13 pppaul: (use 'clojure.contrib.math)

22:13 (def PHI (/ (+ 1 (sqrt 5)) 2))

22:13 (defn fib-double ([n] (/ (- (Math/pow PHI n) (Math/pow (- 1 PHI) n)) (sqrt 5))))

22:13 (defn fib ([n] (round (fib-double n))))

22:14 convert that to use bigint and bigdec

22:14 cus i don't know if it'll work due to precision problems

22:15 tonyl: amalloy: not every other number in the fibs seq is even, but you might be right about filter

22:15 pppaul: you may be able to get fast functions using def-memo

22:16 tonyl: pppaul: is round the only function used from c.c.math?

22:16 pppaul: yes

22:16 can be replaced with (int

22:16 amalloy: tonyl: oh, i guess you're right. it must go odd-odd-even-odd-odd-even...

22:16 pppaul: i made it a long long time ago

22:16 amalloy: so you can take every third

22:17 &(doc take-nth)

22:17 sexpbot: ⟹ "([n coll]); Returns a lazy seq of every nth item in coll."

22:17 tonyl: I am going to look at both options, thanks guys

22:18 pppaul: since it's a series, and fibs are based off of the phi functions, there is probably a simple sum function for fibs

22:18 you could have a constant time fib-sum :)

22:34 `jstirrell: hi

22:34 mattmitchell: &(doc seq)

22:34 sexpbot: ⟹ "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."

22:36 `jstirrell: How do you call a function A from function B when function A occurs later in code than function B?

22:36 tonyl: what do you mean occurs?

22:36 `jstirrell: like it is defined lower in source

22:37 tonyl: you can declare it before function A

22:37 (declare fnB)

22:37 `jstirrell: AH! thanks, I knew it was something easy I just forgot the term

22:37 tonyl: np

22:41 pppaul: (declare war)

22:42 &(declare war)

22:42 sexpbot: java.lang.SecurityException: You tripped the alarm! def is bad!1

22:42 pppaul: (source declare)

22:42 &(source declare)

22:42 sexpbot: java.lang.Exception: Unable to resolve symbol: source in this context

22:42 tonyl: $source declare

22:42 sexpbot: declare is http://is.gd/hg4Aa

22:42 pppaul: &(sorce declare)

22:42 sexpbot: java.lang.Exception: Unable to resolve symbol: sorce in this context

22:42 pppaul: &(sauce declare)

22:42 sexpbot: java.lang.Exception: Unable to resolve symbol: sauce in this context

22:43 pppaul: $8ball am i getting it?

22:43 sexpbot: pppaul: You may rely on it.

22:43 pppaul: $8ball it it it it it?

22:43 sexpbot: pppaul: Don't count on it.

22:43 rata_: hi all

22:43 pppaul: hi

22:43 rata_: hi pppaul

22:44 pppaul: (inc rata_)

22:44 sexpbot: ⟹ 1

22:44 rata_: :)

22:50 slyrus: I agree with you now that fnparse 3.x has better names for its functions... it was just a problem getting used to :require and the h/ thing

23:10 mattmitchell: &(doc doseq)

23:10 sexpbot: ⟹ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."

23:13 * tonyl gives up for now. prepare for the next round tomorrow fib

23:36 livingston: so I have this class being given to me: http://repository.aduna-software.org/docs/info.aduna/api/info/aduna/iteration/Iteration.html

23:36 and I'd like to just call seq or iterator-seq on it but it doesn't actually implement iterable, just something almost identical...

23:37 presumably there's a clever way to use extend to patch it, but I'm having a hard time finding an example.

23:40 tonyl: got it (reduce + (take-nth 3 (take-while (partial >= 4e6) (fibs))))

23:45 amalloy: livingston: this isn't "almost iterable", but rather "almost an iterator"

23:46 livingston: amalloy: er right, that

23:47 amalloy: right now I just defined sesame-iteration-seq that produces a lazy list - that's probably good enough -- but I was playing around with other protocols tonight

23:55 slyrus: rata_: ah, good

23:55 livingston: yeah I was just looking for a clean example of extending an existing java class with the ISeq protocol.

23:55 slyrus: yeah, I think joshuachoi made it better with fnparse3

23:59 my only gripe about fnparse is that it makes my previous parsing attempts for the same task look (in CL) look rather lame

23:59 well, ok, probably not my only gripe, but you get the idea

Logging service provided by n01se.net