#clojure logs

2010-01-03

00:22quizmeDid Rick Hickey use Clojure for the exit polling app? What did he use for persistence?
03:14LauJensenMorning team
03:18polypushello
03:18polypus20 past midnight here
03:20quizmehi
03:21replacahey Lau
03:21quizmehow about we make a new company consisting of everybody on this channel
03:21replacaI thought that's what Dysinger was up to :-)
04:10noidiI see that optimizer had problems with xmonad... in case anyone else is getting grey screens with Java apps, this might help http://awesome.naquadah.org/wiki/Problems_with_Java
05:33LauJensenAnyone in here with some flair for design, who can help me out 2 minz?
05:38LauJensenOk I guess that was a long shot in the forum for Lispniks :)
05:39timothypratley*chuckle* maybe if you were after macro design someone would chime up :P
05:39timothypratleybut I'm guessing something more visual?
05:41LauJensenYou guessed right
05:42_alexI do design
05:43LauJensenGreat ---> Priv :)
07:16zakwilsonWhile trying to build the neman libs with Clojure 1.1, it complains "clojure#clojure;svn1322: not found". I've never built these before so I don't know if this is a version conflict or something else. I also don't really know my way around ant, ivy or other Java-universe tools that well, so a pointer in the right direction would be appreciated.
07:47Chousukezakwilson: my first guess would be that the build script is horribly outdated.
07:49zakwilsonChousuke: I'm sure it is. I just don't know what to do about it.
08:01hoeckzakwilson: you could simply set your classpath to contain all those clj files, and then search for gen-class to figure those out who need AOT compilation and do it by hand
10:05noidihow might I go about using penumbra in a leiningen project?
10:20jamescarrhi
10:20jamescarris there a mavenized jar for the clojure jsr-223 implementation?
10:39Licensermavenized sounds fun .P
10:52somniumurk, what do you do if someones squatting on your group at clojars (with a fork of your project)?
11:20mebaran151how do I run a zipper on a nested map
11:49edbondhow to fix 'java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn'?
11:51gurutypically you program contains an error like this
11:51guru,((lazy-seq '()))
11:51clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
11:51edbondguru: I suppose this is because of map
11:52gurupost code snippet
11:52guruplz
11:52lisppaste8edbond pasted "java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn" at http://paste.lisp.org/display/92961
11:53gurucould you already isolate the error?
11:53edbondits somewhere in row-vals
11:53gurudo you know the function it occurs in?
11:53edbondfunction max-in-row
11:54edbondget-all-variants works
11:54edbond(get-all-variants int-grid 4 4) => ((51 99 64 2) (51 3 67 20) (51 67 63 89) (51 60 14 57))
11:54guru (get (grid) y0)
11:55gurushould be (get grid y0) i guess
11:55guruor just (grid y0)
11:55guru(vectors are functions with the index as their parameter)
11:56guruvectors are functions is a bit misleading
11:56edbond(int-grid 4) doesnt works
11:57edbondbut ((int-grid) 4) works
11:57guruif you define a vector, there is a function with the same name
11:57guruyep
11:58guru(get grid y0) should work
11:58edbondthats why I used (get (grid) y0)
11:58guruyeah, just get rid of the get
11:58edbondanyway I still have the same exception
11:58guruah uh
11:58edbondlazyseq -> ifn
12:01edbondbtw (map #(%) (range(4))) throw similar error
12:02guru,(map (fn [x] x) (range 4))
12:02clojurebot(0 1 2 3)
12:02guru(map #(%) (range 4))
12:03gurua #(...) style function must start with an IFn
12:03guruso it tries to execute the %, which is intended as return value
12:03edbondI got it, thanks
12:04edbond,(map (fn [x] x) (range 4))
12:04clojurebot(0 1 2 3)
12:04guruand by (range(4)) you say give me the range starting from 0 up to the value that the 'function' 4 returns
12:04guruoh, but i was wrong on that (get (grid) y0) line
12:05guruyour version is right
12:05gurusince grid is a function, which returns a lazy seq
12:09guruthe problem still remains, i guess?
12:09edbondyep
12:11gurudid you replace that line
12:11gururow-vals (map #(get-all-variants grid % y0) (range (count row)))]
12:11guruwith the (fn [x] ... version?
12:14edbondno
12:14guruwell
12:14guruthere is no reason too ;-)
12:14gurusry
12:18gurutake a look at the last line of max-in-row
12:20gurur u still with me?
12:37mebaran151do zippers work with nested maps?
12:40gurumebaran: http://clojure.org/other_libraries
12:40guruand there the bottom of the page
12:44edbondguru: sorry, had to leave.
12:44guruwb ;-)
12:45guruso, have a look at the last line of max-in-row
12:45edbondI have fixed the function
12:46edbonddid, row-vals (mapcat (fn [x] (get-all-variants grid x y0)) (range (count row)))]
12:46gurunice
12:46edbondand removed () from row-vals at the end
12:47guruthat mapping from the re-seq results to bigint might be unneccessary
12:47gurufor that (fn [x] (get-all-variants grid x y0)) part, you might as well write #(get-all-va...)
12:47gurui was wrong on this one
12:48guruyou are doing a conversion from int to bigint right?
12:50edbondno, from string to bigint, I had problems with this
12:52guruok, i use sth like (map read-string (re-seq #"\d+" %)) for these things
12:52guruu should know that u donÄt have to worry about overflows
12:53guruif an overflow would occur, clojure converts you number type into one which can hold bigger numbers
12:54guru,(type ( + 1 1))
12:54clojurebotjava.lang.Integer
12:55guru,(type 1000000000)
12:55clojurebotjava.lang.Integer
12:56guru(type (* 1000000000 1000000000))
12:56guru,(type (* 1000000000 1000000000))
12:56clojurebotjava.lang.Long
12:56guru,(type (* 1000000000 1000000000 1000000000))
12:56clojurebotjava.math.BigInteger
12:57edbondI had to convert string to integer, don't know about read-string
12:57guruyep
12:57guruand bigint isnt that bad here
12:57gurusince it "naturally" takes a string
12:57gurubut if you dont need big numbers
12:57gurujust use read-string
12:57guruwhich converts about any number
12:58gurui was glad too, that i found that function
12:58edbond,(max [1 2 4])
12:58clojurebot[1 2 4]
12:58edbondhow to use max function?
12:58guru,(max 1 2 4)
12:58clojurebot4
12:59guru,(apply max [1 2 4])
12:59clojurebot4
12:59edbondthanks
12:59gurunp
13:00MenTaLguYhello
13:01MenTaLguYwhat's the best option for a persistent queue data structure in Clojure?
13:02polypusdo you mean persistent in the clojure sense?
13:03edbondheh, solved :)
13:03edbond(time (solve int-grid))
13:03edbond"Elapsed time: 8554.364876 msecs"
13:03edbondguru: thanks
13:03guruyou're welcome
13:06MenTaLguYpolypus: yes.
13:19gurumentalguy: http://markmail.org/message/brvozelsgmr5a3ba
13:19MenTaLguYoh, that's interesting
13:20MenTaLguYWhy it isn't exposed as part of the API?
13:20lopexMenTaLguY: it's also use here http://www.bestinclass.dk/index.php/2009/09/scala-vs-clojure-round-2-concurrency/
13:20gurui dunno, looks pretty useful
13:20mebaran151how do try and finally interact with lazy-seq?
13:21mebaran151is finally immediately called or is does it wait until the seq is entire consumed?
13:21replacaMenTaLguY: good question. If you want blocking behavior, also look at clojure.contrib.seq-utils/fill-queue
13:21MenTaLguYdon't need blocking, just a simple queue
13:22replacacool
13:22MenTaLguYthanks
13:31Licenserhmm I've some problems using lein and swank :/ they refuse to see eachother :(
13:31the-kennyPersistentQueue isn't mutable, right?
13:33MenTaLguYcorrect
13:35Licenserokay I was just stupid :)
13:39chousermebaran151: if something producing a step of a lazy seq throws an exception, it happens right then when that step is realized.
13:40chouserI'm not sure if that answers your question.
13:40MenTaLguYwhat happens if that step is subsequently re-requested?
13:41mebaran151chouser, I was thinking of ensuring that I closed certain iterators
13:42mebaran151basically I'd like to be able to make a seq, that when it goes to garbage collection, will be closed
13:42mebaran151how does the usual java idiom of finally work with this
13:44Chousukehm... it doesn't?
13:44Chousukefinally is for doing cleanup when you get an exception, not when some object is garbage-collected :/
13:44mebaran151finally is for making sure something is called no matter what
13:44mebaran151exception or not
13:45Chousukewell, yeah
13:45Chousukebut it's got nothing to do with GC :)
13:45mebaran151but if I call seq on the iterator (which could be a pretty big iterator), I might not use all of it
13:45mebaran151however if it prematurely calls finally, I won't be able to get the next item
13:45Chousukein that case, you just need to take care of closing the iterator manually somehow.
13:45mebaran151right now, I'm getting basically first item, then an exception that states everything was closed to early
13:46mebaran151exactly!
13:46mebaran151I want to preserve laziness and make sure when I'm done with the lazy thing, it cleans itself up, without my library user having to know anything about transactions or iterators or nothin'
13:47ChousukeI wonder if that's even possible.
13:47Chousukethe seq could keep the iterator open somehow perhaps, but then the problem would be how to ensure it's cleaned up :/
13:54chouseryou can try to use weak references to do some clean-up action when a thing get GC
13:55chouserbut this is generally not recommended
13:59mebaran151so essentially I can't hide the evils of db iteration
13:59mebaran151is there anyway to be informed when a seq goes out of scope?
14:15quizmedoes the enclojure plugin work for netbeans 6.8?
14:15quizmei'm on linux ubuntu 9.10. anybody know of a good clojure editor ?
14:16guruenclojure works for 6.8
14:16the-kennyquizme: Emacs + Slime
14:17quizmeok
15:17danleiI'm looking for a video where rich talked at some kind of lispers metting, where he demonstrated ants (not clojure fore java/lisp programmers) any ideas what that was?
15:17danlei*meeting
15:17hiredman~blip.tv
15:17clojurebotblip.tv is http://clojure.blip.tv/
15:17danleihm
15:18danleiaaah
15:18danleiclojure concurrency ...
15:18danleithanks hiredman
15:19danleiin a hurry ... see you guys
15:32edbondhow to profile clojure programs?
15:36pdkyou should be able to profile them with regular java profiling tools
15:36pdkrecent jdk versions come with a profiler, let's see if i recall the name
15:37pdkjvisualvm
15:37pdki think you can run it from the command line if javac is in your path
16:11djorkWhat's the state of Clojure jobs?
16:11djorkIs there such a thing yet? :P
16:18ohpauleezdjork: There are two companies that use clojure just in the Philadelphia region
16:18ohpauleezone of them is Comcast
16:18ska2342djork: it probably depends on where you live. Many recruiters will probably honor if you got it under your sleeve, even though the companies dont use Clojure(yet).
16:19ordnungswidrigre
16:19djorkDC area. Not really interesting in working in DC though.
16:19djorkhttp://craiglook.com/all.html?q=clojure&m=0 aww, zero listings
16:19ohpauleezThe other company rights highly available messaging systems for financial companies
16:19djorkinteresting
16:19ohpauleezwrites*
16:20djorkseems like more of an Erlang niche
16:20djork(just saying)
16:20djork(not that I wouldn't try it in Clojure myself)
16:21ohpauleezclojure is one piece of the puzzle
16:21ohpauleezthere is some erlang in the solution, as well as RabbitMQ, ruby (on rails) and standard Java
16:22ska2342Many companies just got to evaluating Clojure which is probably not done in the wide public. It is quite easy to integrate Clojure for internal tools (like testing or command line interfaces) where Java is used. It's probably harder to persuade a customer of this new technology.
16:22ohpauleezOne large engineering group in Comcast is using it, and adopting it more extensively
16:23ska2342Learning Clojure is a bet (besides being fun :-)
16:23ohpauleeza second group (also very large) is going to put it up for trial the beginning of this year for some stuff
16:27hiredmanohpauleez: interesting about comcast
16:36ohpauleeztotally
16:36pdkdjork if you google lispjobs it covers clojure as well
16:36djorkgood tip, thanks pdk
16:37hiredmanmy gui repl starts up 21 threads just to sit idle
16:38patrkrisany clever libraries available that makes talking to web services easy in Clojure?
16:38hiredmanclojure-json
16:38the-kennyclojure-http-client
16:38patrkrissorry, I mean for SOAP-based web services
16:38technomancypatrkris: clojure.http.client has a "resourcefully" ns that you might like
16:39technomancyeww
16:39patrkrisyeah, I don't like SOAP either
16:39technomancy=(
16:39patrkristechnomancy: resourcefully is for SOAP stuff?
16:40technomancyno, just for REST
16:40hiredmanI think I call future for each evaluation (yaya threadpool!)
16:41patrkristechnomancy: stupid question, did you mean clojure-contrib?
16:41patrkrisnot that it matters much in the case of SOAP
16:42technomancypatrkris: no, this is separate: http://github.com/technomancy/clojure-http-client
16:42patrkrisah
16:48hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Repl.png
17:05Immutable7are there any libraries for networking? eg like mina?
18:02quizmedoes enclojure work with netbeans 6.8 ?
18:27the-kennyWhy is something like rename-keys in clojure.set?
18:43mebaran151technomancy, I have a set of unit tests for my library in subfolder test
18:43mebaran151how do I get lein test to run them
18:43mebaran151they just use clojure.test
18:45ikitat$ lein test
18:45mebaran151I use lein test
18:45mebaran151but it blows up, complaing there's no clojure
18:45mebaran151but there is!
18:46ikitatclojar.jar in your lib folder?
18:47technomancymebaran151: did you do lein deps?
18:47mebaran151yeah
18:49mebaran151I apologize wrong error
18:49mebaran151it can't find my test clj files
18:49mebaran151I keep my tests in test
18:49mebaran151anyway to add that to the search path
18:51technomancymebaran151: it should be by default, but you can add a :test key to project.clj
18:51mebaran151what namespace should my tests live in?
18:51technomancyany namespace is fine
18:51technomancyit will just run all the tests in all the namespaces in the test/ dir of your project
18:52technomancysorry, the :test-path key in project.clj
18:52technomancyas always, test namespaces need to match the file they're stored in
18:52mebaran151well mine are in com.bebop.appledelhi.bdb-test
18:52mebaran151and it picks up that those are tests to run
18:52mebaran151however it throws a Java IO file exception
18:55Licenseris there something like a default case for multi methods?
18:58mebaran151still can't find them
18:58mebaran151I just have 3 simple clj files in test
18:58mebaran151changed them all to have flat namespaces without the com.bebop prefix, but lein test can't find 'em
19:13hoeckLicenser: yes, :default option in defmulti, defaults to :default, e.g. (defmethod foo :default [] ...)
19:14Licenserhoeck: so whatever I pass if nothing else matches :default will be called? Nice :D thank you hoeck
19:15hoeckLicenser: exactly
19:15Licenserhamza: way thank you!
19:49polypusis there a good writeup anywhere on deftype. i'm especially interested in how it fits into or is used in conjunction with derive and the hierarchy system. any pointers?
20:25hoeckpolypus: have you seen http://www.assembla.com/wiki/show/clojure/Datatypes ?
20:30mebaran151I have a weird issue: I have to mutually reliant clj files
20:30mebaran151*two
20:31mebaran151but it seems one can't see the globals that it uses from the other
20:45arohnerwhat do you mean by mutually reliant?
20:45arohnernm, he left
20:46ohpauleezarohner: I bet he meant he has circular dependencies
20:46arohneryeah, that's what I suspected
21:12mebaran151I have two mutually reliant namespaces
21:12mebaran151while I somehow get them to load at the repl
21:12mebaran151all my compiles fail with various var not found messages
21:14hiredmandon't do that
21:15mebaran151I wanted to split out the indexing from the my main wrapping code
21:15hiredmanso?
21:15hiredmandon't create cyclic dependencies
21:16mebaran151well I just need one var from the main namespace *neo*
21:16Chousukeif you just want to split the code, you can use load to load plain files.
21:16mebaran151is there anyway just to copy the var
21:16mebaran151otherwise I can always just cut and paste it back together
21:18mebaran151are there no possible declare hacks?
22:22mebaran151ah well, I just refactored so as to avoid the circular dependencies
22:22chousermebaran151: good job!
22:23mebaran151but there's no way to have circularly dependent clj files for the future?
22:24chousernot that I know of. Does it really seem like a good thing to you?
22:40mebaran151it was just one global variable that would have been nice to have had access to within both
22:41mebaran151and also I ended up having to cut and paste one small definition that probably should get moved to a utils anyway
22:47danlarkinI want to convert a clojure.lang.Ratio to a BigInteger, do I have to do something like this, (.divide (.numerator 9/4) (.denominator 9/4))?
22:53piccolinoIs that gonna be an integer?
22:54danlarkinit's a BigInteger
22:54technomancydanlarkin: will (int my-ratio) cause nasty overflow? it works fine for small values
22:55technomancyto answer my own question: yes, it overflows
22:55danlarkintechnomancy: values will be larger than an int can hold :(
22:55ikitat,(.decimalValue 999999999999999/2)
22:55clojurebot499999999999999.5M
22:56chouser'int' means primitive int
22:58ikitat,(type (.toBigInteger (.decimalValue 9/4)))
22:58clojurebotjava.math.BigInteger
22:58technomancyhandy
22:58danlarkinHm!
23:00ikitator .toBigIntegerExact which will throw an ArithmeticException on ratios that result in remainders
23:00technomancy\
23:03danlarkinikitat: thanks, .toBigInteger on the .decimalValue is what I'll use
23:05ikitat,(bigint (bigdec 9/4))
23:05clojurebot2
23:05ikitata bit nicer
23:06ikitat,(bigint 9/4)
23:06clojurebot2
23:06ikitathaha... jackpot
23:06danlarkinhey now that's more like it