#clojure log - May 15 2011

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

6:01 lchaplin: hey guys

6:08 AWizzArd: Hallo lchaplin.

7:18 mduerksen: which contrib-lib do i have to reference for -?> ?

7:19 when i am using clojure 1.3, i mean

7:20 i already tried adding [org.clojure.contrib/core "1.3.0-SNAPSHOT"] to my project.clj, but that artifact isn't there

7:20 AWizzArd: What is -?> doing?

7:21 mduerksen: Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation).

7:23 i found it in clojure-contrib / modules / core / src / main / clojure / clojure / contrib / core.clj

7:25 but leiningen won't get that jar for me

7:27 hmm, must have misspelled something

7:28 skuro: mduerksen: the artifact you're looking for is in http://build.clojure.org/snapshots/org/clojure/contrib/core/1.3.0-SNAPSHOT/

7:29 your dependency looks fine to me

7:30 and that repo is by default looked into by lein

7:32 mduerksen: skuro: yes, i found my mistake now: i had spelled it with capital O

7:32 thanks

7:36 fliebel: What would I use to parse really long numbers? java.lang.NumberFormatException: For input string: "10234567891011121314"

7:45 AWizzArd: ,(bigint "9832570932875093270932732095732777")

7:45 clojurebot: 9832570932875093270932732095732777

7:45 fliebel: wee :)

7:48 I'm trying to solve http://code.google.com/codejam/contest/dashboard?c=189252#s=p0 but I run into trouble with the big input.

8:01 Does anyone have a correct solution? I'm pretty sure mine is correct, but Google disagrees, but does not tell which one was/where wrong?

9:51 infosophy: /part

9:52 ssideris: hello, what's the idiomatic way to say "evaluate the following if the value of the expression is not nil, otherwise return nil"?

9:53 tomoj: I'd say it is unidiomatic to say that

9:53 ssideris: ok

9:54 tomoj: when-not is idiomatic and close

9:54 but if the value of the expression is false, it will evaluate the following

9:55 ssideris: I'm parsing some xml, and I when I select for elements with DOM they may not always be present

9:55 if they are present, I'd like to process them further

9:55 otherwise I'd like to set the relevant value to nil

9:56 tomoj: sounds just like when

9:56 must have been confused to think when-not

9:56 ssideris: ok, looking up...

9:56 thanks

9:56 tomoj: &(let [a 1 b nil] [(when a (inc a)) (when b (inc b))])

9:56 sexpbot: ⟹ [2 nil]

9:56 tomoj: but again: ##(when false (not false))

9:56 sexpbot: ⟹ nil

9:57 ssideris: yes, when it is :-)

9:58 code used to be: (if (element) nil (text-to-first-tag (.html element)))

9:58 now is: (when element (text-to-first-tag (.html element))

9:58 much cleaner

12:16 Vinzent: in enlive, I have #{[:.title] [:.info]} (substitute (header ...)), where header is a snippet. On the resulting page, content of (header ...) appears twice somehow. What's wrong in my code?

12:34 thorwil: Vinzent: needs more context

12:36 Vinzent: thorwil, i understood waht's the problem: it's substituting content of every tag in the set, but i need to substitute the whole selection

12:40 so the right thing is {[:.title] [:.info]} (substitute (header ...)) - map selects fragment

15:06 blackcoffeerider: saludos & hello

15:07 can anyone explain to me why switching from clojure 1.1 to 1.2 rose strange behaviour in #{...} expressions...

15:09 parsing a xml file gives me: {:tag :foo, :attrs {:bla "fasel"}, :content [{:tag :bar, :attrs {:ebb "es"}, :content [" anneres "]}]}

15:10 but writing the same in the REPL as #{:tag ...} gives me => #{:foo :content {:bla "fasel"} :attrs :tag [{:tag :bar, :attrs {:ebb "es"}, :content [" anneres "]}]}

15:10 which doesnt make any sense to me at all

15:11 fliebel: blackcoffeerider: What is the # good for? you're creating a set instead of a map now.

15:12 blackcoffeerider: fliebel, was it both implemented the same way in 1.1? sinc im pretty positive that the coding i'm looking at was working neat pre 1.2

15:14 fliebel: thanks for hitting my head at it... seeing it now...

16:51 patrkris: i get the following exception when trying to load a .clj file from the REPL that has byte order marks: java.lang.Exception: Unable to resolve symbol: in this context (test.clj:2)

16:51 is that normal?

16:52 clojure 1.2

17:24 aav: what is the official minimal java version that can run clojure?

17:27 amalloy: 1.5

17:30 a_robbins: hey, I'm trying to work through the macros tutorial here: https://github.com/swannodette/macros-tutorial 'lein deps' dies saying org.clojure:clojure:jar:1.1.0-master-SNAPSHOT is missing. Any ideas?

17:31 Here is the relevant project.clj file: https://github.com/swannodette/macros-tutorial/blob/master/project.clj

17:31 amalloy: that is a hideously old version

17:32 a_robbins: so old that the jar isn't available any more?

17:32 amalloy: yes

17:32 aav: amalloy: thanx!

17:32 amalloy: it was a snapshot

17:33 a_robbins: the trick is finding the oaf who's depending on it (since it's not in your project.clj, of course) and changing it there

17:33 a_robbins: ok, I'll just comment out the other ones one at a time until I don't get the error

17:34 amalloy: i wish more people would know about, and use, version ranges

17:34 eg [clojure "[1.1.0-SNAPSHOT,)"] to mean "this version or anything higher"

17:35 a_robbins: Yeah, that'd be nice. I'm fortunate, it was lein-swank that required it, and it was only a dev dependency anyway

17:35 amalloy: oh. change the lein version to like 1.5.2, then :P

17:35 something a *little* newer :)

17:36 a_robbins: I haven't put in the time to learn how to make vim and swank work together, or even if it is worthwhile, so I'm just going to drop it.

17:36 amalloy: k

17:37 a_robbins: amalloy: thanks!

17:37 amalloy: welcome

17:37 a_robbins: also, thanks for providing feedback on my euler clojure problems. The DFW clojure group is going to meet and go over them tomorrow.

17:41 dnolen: a_robbins: I should probably erase that macro tutorial, it's full of information that's outdated.

17:42 a_robbins: oh, should I not read it? Is there a better place to learn?

17:43 dnolen: a_robbins: there are no good macro tutorials I'm aware of, but that tutorial relies on a very old version of Clojure, and some of the ideas there are irrelevant based on where 1.3.0 is going.

17:43 a_robbins: ok, I'll leave it alone then. Thanks for the heads up

17:43 dnolen: a_robbins: have too many other things on my plate to write a better macro tutorial, hopefully somebody else can/will.

17:44 amalloy: no good macro tutorials? that's hard to believe

17:44 technomancy: a_robbins: swank doesn't work with vim; generally you use nailgun

17:44 dnolen: a_robbins: the books, Joy of Clojure perhaps.

17:44 symbole: Clojure in Action as well.

17:44 amalloy: at worst you can read a common-lisp macro tutorial, exchange , for ~, and be reasonably close

17:45 a_robbins: technomancy: What is the big benefit of using nailgun as opposed to just running a repl in a terminal window and pasting code into it?

17:45 dnolen: macro-tutorial put to rest.

17:47 a_robbins: dnolen: Yeah, I'll go back into Joy of Clojure and reread the section on macros. I was hoping to find a nice clonable tutorial with code samples, but I guess I can learn from books too :)

17:49 technomancy: a_robbins: I haven't ever really used nailgun or vim; I just know they go together.

17:50 a_robbins: technomancy: fair enough, thanks for the input

18:01 Yamazaki-kun: Does Enclojure have some equivalent to M-p and M-n in slime, other then pulling up the command history as a .clj file, highlighting the s-expr, and C-s-e?

18:05 amalloy: Yamazaki-kun: iirc it's C-<UP>?

18:10 Yamazaki-kun: amalloy: that was indeed it.

18:25 Clinteger: hi amalloy

18:48 jtoy: hi all

18:49 reading some clojure books today

18:49 Touqen: jtoy: Any recommendations?

18:49 wastrel: clojure books eh

18:49 i downloaded "on lisp"

18:52 amalloy: that's a good book. so is JoC

19:01 jtoy: Touqen: Im reading practical clojure now

19:01 buti also have the joy of clojure

19:02 can I output all the code in the repl I've rwitten to a file?

19:05 technomancy: jtoy: there's nothing in the built-in repl to do that. would be a neat idea for an additional tool though.

19:15 pdk: practical clojure is great for a reference book though you can tell it was a bit rough around the edges

19:15 things like crap typesetting and a couple code sample errors but you'll deal

19:29 symbole: Apress books aren't known for their typesetting.

19:40 wastrel: the jthingy has history

19:41 jline

19:41 so presumably that's stored somewhere

19:42 amalloy: ugh jline

19:42 do yourself a favor and install rlwrap

19:42 wastrel: will do

20:21 amalloy: $findfn [[1 2] [3 4]] 3

20:21 sexpbot: []

20:22 amalloy: aw, we don't have an flast?

20:24 dnolen: this is a great read, http://www2.parc.com/csl/groups/sda/projects/oi/towards-talk/transcript.html Kiczales (Art of the Metaobject Protocol) thoughts on what's wrong w/ black boxes.

20:25 amalloy: &(fnext [[1 2] [3 4]])

20:25 sexpbot: ⟹ [3 4]

20:26 amalloy: weird. isn't fnext just second?

20:37 wastrel: it's from 1995

20:37 i wasn't even born then

20:38 amalloy: what's from 95?

20:39 wastrel: 20:27 < dnolen> this is a great read,

20:39 http://www2.parc.com/csl/groups/sda/projects/oi/towards-talk/transcript.html

23:18 TheMoonMaster: Anyone use lwjgl with clojure?

23:21 dnolen: TheMoonMaster: only via Penumbra.

23:21 TheMoonMaster: dnolen: I'm trying it without it, and it isn't going well, lol

23:21 Is Penumbra worth checking out?

23:22 dnolen: TheMoonMaster: yes, removes a lot of awful boilerplate, Java-ness.

23:22 TheMoonMaster: dnolen: Awesome, I'll check it out, thanks.

23:23 dnolen: TheMoonMaster: I haven't had time to keep this up-to-date, but you might find it useful, https://github.com/swannodette/clj-nehe/blob/master/src/clj_nehe/tutorial13.clj

23:24 TheMoonMaster: dnolen: Looks like a good start, thanks.

23:24 dnolen: oops, I meant, https://github.com/swannodette/clj-nehe

23:25 TheMoonMaster: Oh wow, he has a lot of stuffo nthere

23:25 dnolen: TheMoonMaster: doing OpenGL stuff should be a lot more fun now that Clojure 1.3.0 numeric perf is much improved.

23:26 TheMoonMaster: dnolen: Thats good to hear, I'll have to pull 1.3 for this project

23:26 dnolen: TheMoonMaster: previously ztellman and I had lot of hacky macro numeric code to get decent perf.

23:26 TheMoonMaster: That doesn't sound fun at all

23:27 dnolen: (+ 1 2 3 4 5) used to have to be transformed to (int (+ (int 1) (int (+ (int 2) (int (+ (int 3 ...

23:27 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "+">

23:28 TheMoonMaster: That probably would have made me switch languages for this project

23:28 lol

23:30 dnolen: TheMoonMaster: heh, even that pain was not worth switching to write code in Java. all the other dynamic langs have much worse perf that Clojure for OpenGL stuff even w/o the macro hacks.

23:31 TheMoonMaster: dnolen: Well, I convinced the guy I am working on the project with to use Clojure instead of Scala, that would have made him change his mind on the choice of language

23:47 dnolen: TheMoonMaster: interested to hear how that goes. One thing about Clojure I enjoy is the ability to update running Penumbra programs.

23:47 TheMoonMaster: dnolen: Clojure is amazing, if this goes well I want to write an open source minecraft + zombies kind agame

23:49 dnolen: TheMoonMaster: i will say it's not always obvious how to write fast Clojure code tho it's possible, perhaps you might find this useful as well, https://github.com/swannodette/flocking/blob/master/src/flocking/flocking.clj

23:50 TheMoonMaster: dnolen: I'll check it out, I appreciate all the resources and help.

23:50 dnolen: TheMoonMaster: uses the latest 1.3.0 numeric stuff, it's very close to Java perf, in fact I think the bottleneck at this point is actually clj-processing.

23:51 TheMoonMaster: Oh wow, that is awesome

23:51 Definitely using 1.3

Logging service provided by n01se.net