#clojure log - Jan 03 2010

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

0:22 quizme: Did Rick Hickey use Clojure for the exit polling app? What did he use for persistence?

3:14 LauJensen: Morning team

3:18 polypus: hello

3:18 20 past midnight here

3:20 quizme: hi

3:21 replaca: hey Lau

3:21 quizme: how about we make a new company consisting of everybody on this channel

3:21 replaca: I thought that's what Dysinger was up to :-)

4:10 noidi: I 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

5:33 LauJensen: Anyone in here with some flair for design, who can help me out 2 minz?

5:38 Ok I guess that was a long shot in the forum for Lispniks :)

5:39 timothypratley: *chuckle* maybe if you were after macro design someone would chime up :P

5:39 but I'm guessing something more visual?

5:41 LauJensen: You guessed right

5:42 _alex: I do design

5:43 LauJensen: Great ---> Priv :)

7:16 zakwilson: While 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.

7:47 Chousuke: zakwilson: my first guess would be that the build script is horribly outdated.

7:49 zakwilson: Chousuke: I'm sure it is. I just don't know what to do about it.

8:01 hoeck: zakwilson: 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:05 noidi: how might I go about using penumbra in a leiningen project?

10:20 jamescarr: hi

10:20 is there a mavenized jar for the clojure jsr-223 implementation?

10:39 Licenser: mavenized sounds fun .P

10:52 somnium: urk, what do you do if someones squatting on your group at clojars (with a fork of your project)?

11:20 mebaran151: how do I run a zipper on a nested map

11:49 edbond: how to fix 'java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn'?

11:51 guru: typically you program contains an error like this

11:51 ,((lazy-seq '()))

11:51 clojurebot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

11:51 edbond: guru: I suppose this is because of map

11:52 guru: post code snippet

11:52 plz

11:52 lisppaste8: edbond pasted "java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn" at http://paste.lisp.org/display/92961

11:53 guru: could you already isolate the error?

11:53 edbond: its somewhere in row-vals

11:53 guru: do you know the function it occurs in?

11:53 edbond: function max-in-row

11:54 get-all-variants works

11:54 (get-all-variants int-grid 4 4) => ((51 99 64 2) (51 3 67 20) (51 67 63 89) (51 60 14 57))

11:54 guru: (get (grid) y0)

11:55 should be (get grid y0) i guess

11:55 or just (grid y0)

11:55 (vectors are functions with the index as their parameter)

11:56 vectors are functions is a bit misleading

11:56 edbond: (int-grid 4) doesnt works

11:57 but ((int-grid) 4) works

11:57 guru: if you define a vector, there is a function with the same name

11:57 yep

11:58 (get grid y0) should work

11:58 edbond: thats why I used (get (grid) y0)

11:58 guru: yeah, just get rid of the get

11:58 edbond: anyway I still have the same exception

11:58 guru: ah uh

11:58 edbond: lazyseq -> ifn

12:01 btw (map #(%) (range(4))) throw similar error

12:02 guru: ,(map (fn [x] x) (range 4))

12:02 clojurebot: (0 1 2 3)

12:02 guru: (map #(%) (range 4))

12:03 a #(...) style function must start with an IFn

12:03 so it tries to execute the %, which is intended as return value

12:03 edbond: I got it, thanks

12:04 ,(map (fn [x] x) (range 4))

12:04 clojurebot: (0 1 2 3)

12:04 guru: and by (range(4)) you say give me the range starting from 0 up to the value that the 'function' 4 returns

12:04 oh, but i was wrong on that (get (grid) y0) line

12:05 your version is right

12:05 since grid is a function, which returns a lazy seq

12:09 the problem still remains, i guess?

12:09 edbond: yep

12:11 guru: did you replace that line

12:11 row-vals (map #(get-all-variants grid % y0) (range (count row)))]

12:11 with the (fn [x] ... version?

12:14 edbond: no

12:14 guru: well

12:14 there is no reason too ;-)

12:14 sry

12:18 take a look at the last line of max-in-row

12:20 r u still with me?

12:37 mebaran151: do zippers work with nested maps?

12:40 guru: mebaran: http://clojure.org/other_libraries

12:40 and there the bottom of the page

12:44 edbond: guru: sorry, had to leave.

12:44 guru: wb ;-)

12:45 so, have a look at the last line of max-in-row

12:45 edbond: I have fixed the function

12:46 did, row-vals (mapcat (fn [x] (get-all-variants grid x y0)) (range (count row)))]

12:46 guru: nice

12:46 edbond: and removed () from row-vals at the end

12:47 guru: that mapping from the re-seq results to bigint might be unneccessary

12:47 for that (fn [x] (get-all-variants grid x y0)) part, you might as well write #(get-all-va...)

12:47 i was wrong on this one

12:48 you are doing a conversion from int to bigint right?

12:50 edbond: no, from string to bigint, I had problems with this

12:52 guru: ok, i use sth like (map read-string (re-seq #"\d+" %)) for these things

12:52 u should know that u donÄt have to worry about overflows

12:53 if an overflow would occur, clojure converts you number type into one which can hold bigger numbers

12:54 ,(type ( + 1 1))

12:54 clojurebot: java.lang.Integer

12:55 guru: ,(type 1000000000)

12:55 clojurebot: java.lang.Integer

12:56 guru: (type (* 1000000000 1000000000))

12:56 ,(type (* 1000000000 1000000000))

12:56 clojurebot: java.lang.Long

12:56 guru: ,(type (* 1000000000 1000000000 1000000000))

12:56 clojurebot: java.math.BigInteger

12:57 edbond: I had to convert string to integer, don't know about read-string

12:57 guru: yep

12:57 and bigint isnt that bad here

12:57 since it "naturally" takes a string

12:57 but if you dont need big numbers

12:57 just use read-string

12:57 which converts about any number

12:58 i was glad too, that i found that function

12:58 edbond: ,(max [1 2 4])

12:58 clojurebot: [1 2 4]

12:58 edbond: how to use max function?

12:58 guru: ,(max 1 2 4)

12:58 clojurebot: 4

12:59 guru: ,(apply max [1 2 4])

12:59 clojurebot: 4

12:59 edbond: thanks

12:59 guru: np

13:00 MenTaLguY: hello

13:01 what's the best option for a persistent queue data structure in Clojure?

13:02 polypus: do you mean persistent in the clojure sense?

13:03 edbond: heh, solved :)

13:03 (time (solve int-grid))

13:03 "Elapsed time: 8554.364876 msecs"

13:03 guru: thanks

13:03 guru: you're welcome

13:06 MenTaLguY: polypus: yes.

13:19 guru: mentalguy: http://markmail.org/message/brvozelsgmr5a3ba

13:19 MenTaLguY: oh, that's interesting

13:20 Why it isn't exposed as part of the API?

13:20 lopex: MenTaLguY: it's also use here http://www.bestinclass.dk/index.php/2009/09/scala-vs-clojure-round-2-concurrency/

13:20 guru: i dunno, looks pretty useful

13:20 mebaran151: how do try and finally interact with lazy-seq?

13:21 is finally immediately called or is does it wait until the seq is entire consumed?

13:21 replaca: MenTaLguY: good question. If you want blocking behavior, also look at clojure.contrib.seq-utils/fill-queue

13:21 MenTaLguY: don't need blocking, just a simple queue

13:22 replaca: cool

13:22 MenTaLguY: thanks

13:31 Licenser: hmm I've some problems using lein and swank :/ they refuse to see eachother :(

13:31 the-kenny: PersistentQueue isn't mutable, right?

13:33 MenTaLguY: correct

13:35 Licenser: okay I was just stupid :)

13:39 chouser: mebaran151: if something producing a step of a lazy seq throws an exception, it happens right then when that step is realized.

13:40 I'm not sure if that answers your question.

13:40 MenTaLguY: what happens if that step is subsequently re-requested?

13:41 mebaran151: chouser, I was thinking of ensuring that I closed certain iterators

13:42 basically I'd like to be able to make a seq, that when it goes to garbage collection, will be closed

13:42 how does the usual java idiom of finally work with this

13:44 Chousuke: hm... it doesn't?

13:44 finally is for doing cleanup when you get an exception, not when some object is garbage-collected :/

13:44 mebaran151: finally is for making sure something is called no matter what

13:44 exception or not

13:45 Chousuke: well, yeah

13:45 but it's got nothing to do with GC :)

13:45 mebaran151: but if I call seq on the iterator (which could be a pretty big iterator), I might not use all of it

13:45 however if it prematurely calls finally, I won't be able to get the next item

13:45 Chousuke: in that case, you just need to take care of closing the iterator manually somehow.

13:45 mebaran151: right now, I'm getting basically first item, then an exception that states everything was closed to early

13:46 exactly!

13:46 I 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:47 Chousuke: I wonder if that's even possible.

13:47 the seq could keep the iterator open somehow perhaps, but then the problem would be how to ensure it's cleaned up :/

13:54 chouser: you can try to use weak references to do some clean-up action when a thing get GC

13:55 but this is generally not recommended

13:59 mebaran151: so essentially I can't hide the evils of db iteration

13:59 is there anyway to be informed when a seq goes out of scope?

14:15 quizme: does the enclojure plugin work for netbeans 6.8?

14:15 i'm on linux ubuntu 9.10. anybody know of a good clojure editor ?

14:16 guru: enclojure works for 6.8

14:16 the-kenny: quizme: Emacs + Slime

14:17 quizme: ok

15:17 danlei: I'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:17 *meeting

15:17 hiredman: ~blip.tv

15:17 clojurebot: blip.tv is http://clojure.blip.tv/

15:17 danlei: hm

15:18 aaah

15:18 clojure concurrency ...

15:18 thanks hiredman

15:19 in a hurry ... see you guys

15:32 edbond: how to profile clojure programs?

15:36 pdk: you should be able to profile them with regular java profiling tools

15:36 recent jdk versions come with a profiler, let's see if i recall the name

15:37 jvisualvm

15:37 i think you can run it from the command line if javac is in your path

16:11 djork: What's the state of Clojure jobs?

16:11 Is there such a thing yet? :P

16:18 ohpauleez: djork: There are two companies that use clojure just in the Philadelphia region

16:18 one of them is Comcast

16:18 ska2342: djork: 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:19 ordnungswidrig: re

16:19 djork: DC area. Not really interesting in working in DC though.

16:19 http://craiglook.com/all.html?q=clojure&m=0 aww, zero listings

16:19 ohpauleez: The other company rights highly available messaging systems for financial companies

16:19 djork: interesting

16:19 ohpauleez: writes*

16:20 djork: seems like more of an Erlang niche

16:20 (just saying)

16:20 (not that I wouldn't try it in Clojure myself)

16:21 ohpauleez: clojure is one piece of the puzzle

16:21 there is some erlang in the solution, as well as RabbitMQ, ruby (on rails) and standard Java

16:22 ska2342: Many 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:22 ohpauleez: One large engineering group in Comcast is using it, and adopting it more extensively

16:23 ska2342: Learning Clojure is a bet (besides being fun :-)

16:23 ohpauleez: a second group (also very large) is going to put it up for trial the beginning of this year for some stuff

16:27 hiredman: ohpauleez: interesting about comcast

16:36 ohpauleez: totally

16:36 pdk: djork if you google lispjobs it covers clojure as well

16:36 djork: good tip, thanks pdk

16:37 hiredman: my gui repl starts up 21 threads just to sit idle

16:38 patrkris: any clever libraries available that makes talking to web services easy in Clojure?

16:38 hiredman: clojure-json

16:38 the-kenny: clojure-http-client

16:38 patrkris: sorry, I mean for SOAP-based web services

16:38 technomancy: patrkris: clojure.http.client has a "resourcefully" ns that you might like

16:39 eww

16:39 patrkris: yeah, I don't like SOAP either

16:39 technomancy: =(

16:39 patrkris: technomancy: resourcefully is for SOAP stuff?

16:40 technomancy: no, just for REST

16:40 hiredman: I think I call future for each evaluation (yaya threadpool!)

16:41 patrkris: technomancy: stupid question, did you mean clojure-contrib?

16:41 not that it matters much in the case of SOAP

16:42 technomancy: patrkris: no, this is separate: http://github.com/technomancy/clojure-http-client

16:42 patrkris: ah

16:48 hiredman: http://www.thelastcitadel.com/images/Screenshot-Repl.png

17:05 Immutable7: are there any libraries for networking? eg like mina?

18:02 quizme: does enclojure work with netbeans 6.8 ?

18:27 the-kenny: Why is something like rename-keys in clojure.set?

18:43 mebaran151: technomancy, I have a set of unit tests for my library in subfolder test

18:43 how do I get lein test to run them

18:43 they just use clojure.test

18:45 ikitat: $ lein test

18:45 mebaran151: I use lein test

18:45 but it blows up, complaing there's no clojure

18:45 but there is!

18:46 ikitat: clojar.jar in your lib folder?

18:47 technomancy: mebaran151: did you do lein deps?

18:47 mebaran151: yeah

18:49 I apologize wrong error

18:49 it can't find my test clj files

18:49 I keep my tests in test

18:49 anyway to add that to the search path

18:51 technomancy: mebaran151: it should be by default, but you can add a :test key to project.clj

18:51 mebaran151: what namespace should my tests live in?

18:51 technomancy: any namespace is fine

18:51 it will just run all the tests in all the namespaces in the test/ dir of your project

18:52 sorry, the :test-path key in project.clj

18:52 as always, test namespaces need to match the file they're stored in

18:52 mebaran151: well mine are in com.bebop.appledelhi.bdb-test

18:52 and it picks up that those are tests to run

18:52 however it throws a Java IO file exception

18:55 Licenser: is there something like a default case for multi methods?

18:58 mebaran151: still can't find them

18:58 I just have 3 simple clj files in test

18:58 changed them all to have flat namespaces without the com.bebop prefix, but lein test can't find 'em

19:13 hoeck: Licenser: yes, :default option in defmulti, defaults to :default, e.g. (defmethod foo :default [] ...)

19:14 Licenser: hoeck: so whatever I pass if nothing else matches :default will be called? Nice :D thank you hoeck

19:15 hoeck: Licenser: exactly

19:15 Licenser: hamza: way thank you!

19:49 polypus: is 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:25 hoeck: polypus: have you seen http://www.assembla.com/wiki/show/clojure/Datatypes ?

20:30 mebaran151: I have a weird issue: I have to mutually reliant clj files

20:30 *two

20:31 but it seems one can't see the globals that it uses from the other

20:45 arohner: what do you mean by mutually reliant?

20:45 nm, he left

20:46 ohpauleez: arohner: I bet he meant he has circular dependencies

20:46 arohner: yeah, that's what I suspected

21:12 mebaran151: I have two mutually reliant namespaces

21:12 while I somehow get them to load at the repl

21:12 all my compiles fail with various var not found messages

21:14 hiredman: don't do that

21:15 mebaran151: I wanted to split out the indexing from the my main wrapping code

21:15 hiredman: so?

21:15 don't create cyclic dependencies

21:16 mebaran151: well I just need one var from the main namespace *neo*

21:16 Chousuke: if you just want to split the code, you can use load to load plain files.

21:16 mebaran151: is there anyway just to copy the var

21:16 otherwise I can always just cut and paste it back together

21:18 are there no possible declare hacks?

22:22 ah well, I just refactored so as to avoid the circular dependencies

22:22 chouser: mebaran151: good job!

22:23 mebaran151: but there's no way to have circularly dependent clj files for the future?

22:24 chouser: not that I know of. Does it really seem like a good thing to you?

22:40 mebaran151: it was just one global variable that would have been nice to have had access to within both

22:41 and also I ended up having to cut and paste one small definition that probably should get moved to a utils anyway

22:47 danlarkin: I 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:53 piccolino: Is that gonna be an integer?

22:54 danlarkin: it's a BigInteger

22:54 technomancy: danlarkin: will (int my-ratio) cause nasty overflow? it works fine for small values

22:55 to answer my own question: yes, it overflows

22:55 danlarkin: technomancy: values will be larger than an int can hold :(

22:55 ikitat: ,(.decimalValue 999999999999999/2)

22:55 clojurebot: 499999999999999.5M

22:56 chouser: 'int' means primitive int

22:58 ikitat: ,(type (.toBigInteger (.decimalValue 9/4)))

22:58 clojurebot: java.math.BigInteger

22:58 technomancy: handy

22:58 danlarkin: Hm!

23:00 ikitat: or .toBigIntegerExact which will throw an ArithmeticException on ratios that result in remainders

23:00 technomancy: \

23:03 danlarkin: ikitat: thanks, .toBigInteger on the .decimalValue is what I'll use

23:05 ikitat: ,(bigint (bigdec 9/4))

23:05 clojurebot: 2

23:05 ikitat: a bit nicer

23:06 ,(bigint 9/4)

23:06 clojurebot: 2

23:06 ikitat: haha... jackpot

23:06 danlarkin: hey now that's more like it

Logging service provided by n01se.net