#clojure logs

2011-05-15

06:01lchaplinhey guys
06:08AWizzArdHallo lchaplin.
07:18mduerksenwhich contrib-lib do i have to reference for -?> ?
07:19mduerksenwhen i am using clojure 1.3, i mean
07:20mduerkseni already tried adding [org.clojure.contrib/core "1.3.0-SNAPSHOT"] to my project.clj, but that artifact isn't there
07:20AWizzArdWhat is -?> doing?
07:21mduerksenSame as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation).
07:23mduerkseni found it in clojure-contrib / modules / core / src / main / clojure / clojure / contrib / core.clj
07:25mduerksenbut leiningen won't get that jar for me
07:27mduerksenhmm, must have misspelled something
07:28skuromduerksen: the artifact you're looking for is in http://build.clojure.org/snapshots/org/clojure/contrib/core/1.3.0-SNAPSHOT/
07:29skuroyour dependency looks fine to me
07:30skuroand that repo is by default looked into by lein
07:32mduerksenskuro: yes, i found my mistake now: i had spelled it with capital O
07:32mduerksenthanks
07:36fliebelWhat would I use to parse really long numbers? java.lang.NumberFormatException: For input string: "10234567891011121314"
07:45AWizzArd,(bigint "9832570932875093270932732095732777")
07:45clojurebot9832570932875093270932732095732777
07:45fliebelwee :)
07:48fliebelI'm trying to solve http://code.google.com/codejam/contest/dashboard?c=189252#s=p0 but I run into trouble with the big input.
08:01fliebelDoes anyone have a correct solution? I'm pretty sure mine is correct, but Google disagrees, but does not tell which one was/where wrong?
09:51infosophy /part
09:52ssiderishello, what's the idiomatic way to say "evaluate the following if the value of the expression is not nil, otherwise return nil"?
09:53tomojI'd say it is unidiomatic to say that
09:53ssiderisok
09:54tomojwhen-not is idiomatic and close
09:54tomojbut if the value of the expression is false, it will evaluate the following
09:55ssiderisI'm parsing some xml, and I when I select for elements with DOM they may not always be present
09:55ssiderisif they are present, I'd like to process them further
09:55ssiderisotherwise I'd like to set the relevant value to nil
09:56tomojsounds just like when
09:56tomojmust have been confused to think when-not
09:56ssiderisok, looking up...
09:56ssideristhanks
09:56tomoj&(let [a 1 b nil] [(when a (inc a)) (when b (inc b))])
09:56sexpbot⟹ [2 nil]
09:56tomojbut again: ##(when false (not false))
09:56sexpbot⟹ nil
09:57ssiderisyes, when it is :-)
09:58ssideriscode used to be: (if (element) nil (text-to-first-tag (.html element)))
09:58ssiderisnow is: (when element (text-to-first-tag (.html element))
09:58ssiderismuch cleaner
12:16Vinzentin 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:34thorwilVinzent: needs more context
12:36Vinzentthorwil, 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:40Vinzentso the right thing is {[:.title] [:.info]} (substitute (header ...)) - map selects fragment
15:06blackcoffeeridersaludos & hello
15:07blackcoffeeridercan anyone explain to me why switching from clojure 1.1 to 1.2 rose strange behaviour in #{...} expressions...
15:09blackcoffeeriderparsing a xml file gives me: {:tag :foo, :attrs {:bla "fasel"}, :content [{:tag :bar, :attrs {:ebb "es"}, :content [" anneres "]}]}
15:10blackcoffeeriderbut writing the same in the REPL as #{:tag ...} gives me => #{:foo :content {:bla "fasel"} :attrs :tag [{:tag :bar, :attrs {:ebb "es"}, :content [" anneres "]}]}
15:10blackcoffeeriderwhich doesnt make any sense to me at all
15:11fliebelblackcoffeerider: What is the # good for? you're creating a set instead of a map now.
15:12blackcoffeeriderfliebel, 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:14blackcoffeeriderfliebel: thanks for hitting my head at it... seeing it now...
16:51patrkrisi 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:51patrkrisis that normal?
16:52patrkrisclojure 1.2
17:24aavwhat is the official minimal java version that can run clojure?
17:27amalloy1.5
17:30a_robbinshey, 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:31a_robbinsHere is the relevant project.clj file: https://github.com/swannodette/macros-tutorial/blob/master/project.clj
17:31amalloythat is a hideously old version
17:32a_robbinsso old that the jar isn't available any more?
17:32amalloyyes
17:32aavamalloy: thanx!
17:32amalloyit was a snapshot
17:33amalloya_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:33a_robbinsok, I'll just comment out the other ones one at a time until I don't get the error
17:34amalloyi wish more people would know about, and use, version ranges
17:34amalloyeg [clojure "[1.1.0-SNAPSHOT,)"] to mean "this version or anything higher"
17:35a_robbinsYeah, that'd be nice. I'm fortunate, it was lein-swank that required it, and it was only a dev dependency anyway
17:35amalloyoh. change the lein version to like 1.5.2, then :P
17:35amalloysomething a *little* newer :)
17:36a_robbinsI 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:36amalloyk
17:37a_robbinsamalloy: thanks!
17:37amalloywelcome
17:37a_robbinsalso, thanks for providing feedback on my euler clojure problems. The DFW clojure group is going to meet and go over them tomorrow.
17:41dnolena_robbins: I should probably erase that macro tutorial, it's full of information that's outdated.
17:42a_robbinsoh, should I not read it? Is there a better place to learn?
17:43dnolena_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:43a_robbinsok, I'll leave it alone then. Thanks for the heads up
17:43dnolena_robbins: have too many other things on my plate to write a better macro tutorial, hopefully somebody else can/will.
17:44amalloyno good macro tutorials? that's hard to believe
17:44technomancya_robbins: swank doesn't work with vim; generally you use nailgun
17:44dnolena_robbins: the books, Joy of Clojure perhaps.
17:44symboleClojure in Action as well.
17:44amalloyat worst you can read a common-lisp macro tutorial, exchange , for ~, and be reasonably close
17:45a_robbinstechnomancy: 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:45dnolenmacro-tutorial put to rest.
17:47a_robbinsdnolen: 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:49technomancya_robbins: I haven't ever really used nailgun or vim; I just know they go together.
17:50a_robbinstechnomancy: fair enough, thanks for the input
18:01Yamazaki-kunDoes 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:05amalloyYamazaki-kun: iirc it's C-<UP>?
18:10Yamazaki-kunamalloy: that was indeed it.
18:25Clintegerhi amalloy
18:48jtoyhi all
18:49jtoyreading some clojure books today
18:49Touqenjtoy: Any recommendations?
18:49wastrelclojure books eh
18:49wastreli downloaded "on lisp"
18:52amalloythat's a good book. so is JoC
19:01jtoyTouqen: Im reading practical clojure now
19:01jtoybuti also have the joy of clojure
19:02jtoycan I output all the code in the repl I've rwitten to a file?
19:05technomancyjtoy: there's nothing in the built-in repl to do that. would be a neat idea for an additional tool though.
19:15pdkpractical clojure is great for a reference book though you can tell it was a bit rough around the edges
19:15pdkthings like crap typesetting and a couple code sample errors but you'll deal
19:29symboleApress books aren't known for their typesetting.
19:40wastrelthe jthingy has history
19:41wastreljline
19:41wastrelso presumably that's stored somewhere
19:42amalloyugh jline
19:42amalloydo yourself a favor and install rlwrap
19:42wastrelwill do
20:21amalloy$findfn [[1 2] [3 4]] 3
20:21sexpbot[]
20:22amalloyaw, we don't have an flast?
20:24dnolenthis 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:25amalloy&(fnext [[1 2] [3 4]])
20:25sexpbot⟹ [3 4]
20:26amalloyweird. isn't fnext just second?
20:37wastrelit's from 1995
20:37wastreli wasn't even born then
20:38amalloywhat's from 95?
20:39wastrel20:27 < dnolen> this is a great read,
20:39wastrelhttp://www2.parc.com/csl/groups/sda/projects/oi/towards-talk/transcript.html
23:18TheMoonMasterAnyone use lwjgl with clojure?
23:21dnolenTheMoonMaster: only via Penumbra.
23:21TheMoonMasterdnolen: I'm trying it without it, and it isn't going well, lol
23:21TheMoonMasterIs Penumbra worth checking out?
23:22dnolenTheMoonMaster: yes, removes a lot of awful boilerplate, Java-ness.
23:22TheMoonMasterdnolen: Awesome, I'll check it out, thanks.
23:23dnolenTheMoonMaster: 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:24TheMoonMasterdnolen: Looks like a good start, thanks.
23:24dnolenoops, I meant, https://github.com/swannodette/clj-nehe
23:25TheMoonMasterOh wow, he has a lot of stuffo nthere
23:25dnolenTheMoonMaster: doing OpenGL stuff should be a lot more fun now that Clojure 1.3.0 numeric perf is much improved.
23:26TheMoonMasterdnolen: Thats good to hear, I'll have to pull 1.3 for this project
23:26dnolenTheMoonMaster: previously ztellman and I had lot of hacky macro numeric code to get decent perf.
23:26TheMoonMasterThat doesn't sound fun at all
23:27dnolen(+ 1 2 3 4 5) used to have to be transformed to (int (+ (int 1) (int (+ (int 2) (int (+ (int 3 ...
23:27clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "+">
23:28TheMoonMasterThat probably would have made me switch languages for this project
23:28TheMoonMasterlol
23:30dnolenTheMoonMaster: 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:31TheMoonMasterdnolen: 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:47dnolenTheMoonMaster: interested to hear how that goes. One thing about Clojure I enjoy is the ability to update running Penumbra programs.
23:47TheMoonMasterdnolen: Clojure is amazing, if this goes well I want to write an open source minecraft + zombies kind agame
23:49dnolenTheMoonMaster: 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:50TheMoonMasterdnolen: I'll check it out, I appreciate all the resources and help.
23:50dnolenTheMoonMaster: 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:51TheMoonMasterOh wow, that is awesome
23:51TheMoonMasterDefinitely using 1.3