#clojure logs

2008-11-26

00:00Chousernotallama: structure your .clj file as show in the link above
00:00Chouserput it in a directory that matches your namespace. namespace: my.foo file: my/foo.clj
00:01Chousermake sure the 'my' directory's parent dir is in your classpath, and also that ./classes is
00:01Chouserthen (compile 'my.foo)
00:18notallamathanks. : )
00:20notallamai'll try it out once i manage to modify my class path. i know how to change it when running java from command line, yet i somehow mess it up in bash scripts every time.
00:50bradbevhas something changed recently? This used to work:user=> (doto (Thread. (fn[] (println "hi"))) (.start))
00:50bradbevjava.lang.IllegalArgumentException: No matching method found: .start for class java.lang.Thread (NO_SOURCE_FILE:0)
00:50bradbevuser=>
00:50bradbevmaking it (start) works
00:52Chouseryeah, but (start) is the older style. (.start) is current
00:52bradbeverr, that's what I thought
00:53bradbevoh yah, svn up & now I don't compile clean :(
01:20PupenoGood morning Clojure.
01:33PupenoCan multimethods have docstrings?
01:50Chouserclojurebot: defmulti doc?
01:50clojurebotdefmulti doc is (defmulti #^{:doc "docs for foo"} foo class)
03:05Lau_of_DKTop of the morning gents!
03:08Pupeno-GGood morning Lau_of_DK
04:56timothypratleyhow long does clojure take to build from source? (I'm trying to load old revisions and build them but it builds in 8 seconds from clean and that makes me suspicious)
04:58hoecktimothypratley: 8secs seems okay to me
05:00hoeckespecially on the old, less complex revisions (eg. without AOT)
05:00timothypratleyok thanks :) I have no clue how it can be so fast!
05:09hoecktimothypratley: building the latest rev takes 15s on a athlon 3800+, including the AOT stuff
05:14timothypratleywhen you say AOT stuff... is that extra (not default)?
05:15timothypratleyI'm just amazed... because I work on smaller C++ projects that take minutes to compile
05:18Chousuketimothypratley: AOT stuff is new, not just "extra"
05:19Chousuketimothypratley: it's really better to use the latest SVN instead of the released version. There have been breaking changes, and if you write code for the old version you'll have to fix it later :/
05:21timothypratleyyup thanks :) I was just going through old revisions because I found that the npe exception line reporting changed in revision 1030->1031 such that it hides the line number
05:38hiredmanI think most of C++ "compile" time is infact link time
06:21Chousukehiredman: hm? running ld doesn't take much time at all compared to the time gcc needs to produce the object files :/
09:04pdoubleyahi all. is clojure-contrib trunk stable, or is there a revision i should stick with? am just starting out with clojure.
09:10hoeckpdoubleya: clojure-contrib is just a collection of useful functions and the latest contrib revision works usually with the latest clojure revision
09:11hoeckpdoubleya: so there is no notion of a "stable" clojure.contrib, at least not for me :)
09:11pdoubleyahoeck: thanks, so: there's no release in place for contrib?
09:12hoecknone which i know, just grab the latest svn from contrib
09:12Lau_of_DKIts being looked at, if 1 of the libs in contrib should be included in the core, at I dont even think Rich is considering that yet. But who knows, for now I think the answer is no
09:13hoeckr/svn/svn revision
09:13Lau_of_DKs/hoeck/noob
09:13hoeckgrrrr
09:14Lau_of_DKIt was a joke man, calm down :)
09:15hoeckLau_of_DK: i know :)
09:18pdoubleyahoeck: thanks
09:19hoeckpdoubleya: np
09:54dfg59hey all, i'm coming to clojure from ruby. i'm reading this http://media.pragprog.com/titles/shcloj/flow.pdf and trying to figured out the simplest way to implement the indexOfAny at the end of the page
09:55dfg59any suggestions of the idiomatic way to do this?
09:55dfg59i was starting off with something like (zipmap my-str (iterate inc 0))
09:55dfg59to get the indices of the string along with it's characters
09:57dfg59however, i'm not sure how to iterate over the sequence and return the single index...maybe reduce?
09:58yanbebut reduce does not stop iteration on the middle of sequence
09:59yanbeunlike indexOfAny in the document you showed
09:59yanbehmm..
09:59tWiploop and recur
10:00Chouseryou can do anything with loop and recur, but if you can find a way to do it with higher-order functions, it'll often be more succinct.
10:01Chouserperhaps map and some
10:01dfg59Chouser: right...i know i can do it with loop/recur, but it doesn't seem elegant.
10:02dfg59how can i determine if a char is a member of a string?
10:04yanbe"abc".index(c) != nil
10:05yanbesorry, i misreaded
10:05Chouseror a more clojurey API would be for searchChars to be a set, in which case (searchChars the-char) would return nil or the-char
10:06dfg59i kind of wish this syntax was valid: ("abcd" \c)
10:09ChouserI think there'd be lots of competition for what a string would do when called.
10:10Chouser...assuming there'd be a sane way to make Java Strings callable.
10:12Chouserok, I got 'some' and 'map' to work. Not as elegant as I'd like, but that may be inherent in using index numbers.
10:13dfg59give me a sec, i think i have something
10:14rhickeyChouser: nothing is callable that is not IFn, so I can't make classes I don't own callable
10:15ChouserAnd String's final, so Clojure couldn't provide it's own subclass, right?
10:16danlarkinbut then we'd lose "foo" being a java.lang.String :(
10:16rhickeydanlarkin: right
10:17rhickeyor more important, strings coming from Java wouldn't play without conversion
10:17Chouserwhich leaves: wrapping Java Strings (indirection on every method call), reimplementing String (gak!), or doing an extra check before every function call to determine if it's a non-IFn that should be treated specially so it can be called (bleh).
10:18Chouserso not even close to worth it.
10:18rhickeyChouser: exactly, Clojure is too pragmatic for that
10:18Chouserhooray! :-)
10:19Chouseranybody have any hints on getting unicode chars from a literal Clojure String into a JTextPane?
10:20Chouser(.setContentType pane "text/plain; charset=UTF-8") doesn't seem to help.
10:21walterswell, Java strings are actually UTF-16
10:21waltersi'd be surprised if you had to call setContentType to make the text pane work though
10:22waltersi'd guess it's more likely a font issue
10:22Chouserah. hm...
10:22ChouserI guess I'm mostly used to browsers where it "just works". I suppose they may pick alternate fonts for individual glyphs as needed.
10:23dfg59any idea why i'm getting a "wrong number of arguments" error on this code? http://pastie.org/324523
10:23dfg59it's on the initial call to indexOfAny
10:23waltersChouser: It's fairly platform specific stuff, depends on your browser and OS
10:27Chouserdfg59: I made the same mistake. Note that the name of the function it complains about isn't actually indexOfAny, but fn inside that.
10:28dfg59ah, gotcha, that's a valid error
10:30dfg59Chouse: this is the best i could end up with, not sure how idiomatic it is: http://pastie.org/324534
10:30dfg59*Chouser
10:36Chouserah, you're returning nil on not-found. Good choice.
10:37dfg59i think it makes more sense if you abstract out the contains? function
10:38dfg59http://pastie.org/324544
10:38dfg59not sure if something like that already exists in the language
10:39duck1123Would it be too hard to make regex-literals callable? Or perhaps only those created by #""
10:39lisppaste8Chouser pasted "index-of-any (for dfg59)" at http://paste.lisp.org/display/71072
10:41Chouserdfg59: 'contains?' is already defined (differently) in clojure.core
10:41dfg59Chouser: awesome, i see...cool, you can decompose arguments with [[ ]]
10:41dfg59that's exactly what i wanted
10:41dfg59thanks for enlightening me :)
10:42Chousersure! that's called "destructuring", btw.
10:43Chouserand it's much more powerful than that. you can pick apart maps and seqs as well as vectors, and nested to any depth. http://clojure.org/special_forms#toc4
10:44wabashJava lets us do native code calls. Can I do that with Clojure?
10:44wabashI'd like to also hook up some CUDA code for parallel stuff with Clojure.
10:44waltersyou can use JNA through Clojure's Java integration
10:44wabashwalters: Great.
10:44wabashThanks. It's what I suspected, but not sure how it all works yet.
10:45waltersoh CUDA...probably sanest to use JNI then
10:45wabashSo if I use GSL, then I could call the GSL routines from clojure... So if I have some CUDA routines to run, I could call them too since they are basically C?
10:46wabashWhy is that?
10:46wabashUh oh, I'm confused now.... JNA vs. JNI.....
10:46wabashJNI == Java Native Interface?
10:46Chouserdfg59: Hm, your indexOfAny has a bug. zipmap returns a hash-map, so the order isn't guaranteed.
10:46walterswabash: yes
10:47wabashJNA == ??
10:47walterswabash: JNA is like ctypes for the JVM if you're familiar with Python: https://jna.dev.java.net/
10:48wabashOh, sorry, not familiar. JNI will work with any C code that compiles though, right? So that's a blanket solution.
10:49walterswabash: yep
10:49wabashwalters: Not familiar with JNA either. Reading your link now. .... Is it really just a Java API for native libraries?
10:49dfg59Chouser: you're right, thanks.
10:49bradbevcan somebody else please try this at their Clojure repl? (. (Thread. (fn[] (println "hi"))) (.start))
10:49walterswabash: for C libraries in particular, yeah
10:49wabashwalters: awesome. Thank you very much for pointing me in the right direction. I appreciate it.
10:49waltersnp
10:51bradbevhmm, (doto (Thread. (fn[] (println "hi"))) (.start)) works though
10:51Chouserbradbev: you're mixing syntaxes or something.
10:51bradbevI guess so - but the reason I am worried is that swank is doing it, not me :(
10:51Chouser(. thread start) or (. thread (start)) should work
10:52Chouser(.start thread) is also ok
10:52Chouser(. thread (.start)) doesn't work.
10:52bradbevWTF, now it is working properly? I think I must have had stale class files around
10:52bradbevmaybe I didn't clean build before
10:53duck1123I was about to say, I got that the other day when everything wasn't properly updated
10:53dfg59Chouser: what is the difference between if and when
10:53bradbevoh well, I guess everything is OK
10:55Chouserdfg59: 'when' doesn't have an else clause -- there's an "implicit do" around everything after the test
10:55Chouserdoesn't really matter in the case where I used it, since there's only one "then" clause. But it's generally considered good style to use 'when' if you have no "else"
10:56dfg59Chouser: great. this simple example is very helpful, thanks...trying to shake off the ruby ideas. feels eerily similar from coming to ruby from java.
10:57Chouseryou're quite welcome.
10:57dfg59so you're creating a list of two element vectors, yes?
10:58ChouserI highly recommend projecteuler for more simple tasks to attempt to solve in clojure.
10:58dfg59that's what (map vector ...) is doing
10:58dfg59Chouser: yeah, i've done quite a bit of projecteuler in ruby, great way to ramp up
10:58Chouserdfg59: technically a (lazy) seq of two-element vectors, but yes you've got the sense of it.
10:59dfg59ah yes, seq, that makes sense
10:59dfg59the laziness of seqs and methods that create seqs blows my mind
10:59Chouser:-)
11:05dfg59wrote my first usable macro :)
11:07Chousermore or less fun than writing a ruby iterator?
11:07dfg59http://paste.lisp.org/display/71074
11:07dfg59heh, quite a bit more fun
11:07wabashHey, can anyone give me suggestions about my learning path? (reading about Java and Ruby above from dfg59....) Me too: Java ==> Ruby... Now i want to do Lispy stuff. I'm working on SICP. Would it be best to finish SICP and then learn Clojure? Or better to dive into Clojure?
11:08dfg59wabash: i did some scheme with "the little schemer". great book.
11:08dfg59and read most of "practical common lisp"
11:09Chouserdfg59: what would you use as the 'enum' parameter?
11:09Chouserfor example.
11:09dfg59in this case, map
11:09dfg59so i did something like
11:09dfg59(with-index map (fn [[c i]] i) "abcd")
11:10dfg59which would give me a seq of the idices
11:10dfg59(useless example)
11:10wabashdfg59: Does that help you to understand Clojure?
11:10dfg59wabash: i'm getting there :) but i think having a background in some scheme / CL helped me ramp up quickly, understand the motivations, the screencasts, etc
11:10duck1123I wonder how many Clojurists come from Ruby vs. other languages
11:11Chouserwabash: I head people say good things about the foundation that SICP provides (though I've not read it myself). I wouldn't bother looking too deeply into Common Lisp, though.
11:11drewrrhickey: Thanks adding us to the contributors page. Would you mind adding drewr next to my name since my sf account isn't really informative?
11:11Chouser"I've heard people"...
11:11dfg59Chouser: the only thing CL helped me with was understanding clojures macro syntax
11:12Chouseryeah, I read "on lisp" before hearing of Clojure. The macro and tail-call discussions in there are helpful.
11:13Chouserhm, you'd think rhickey would count as a "primary" contributor. ;-)
11:13wabashChouser: dfg59: thanks, guys.
11:14dfg59np
11:16duck1123those of you that've read SICP, did you follow along with the code in the book? Wondering if I should DL scheme if I read it
11:16dfg59duck1123: yes. i've done it both ways and it only sinks in if you follow along (or at least attempt to).
11:17wabashwalters: Follow up question... JNA and JNI seem awfully similar.... Is the difference primarily where the connection takes place, i.e. with JNA the interface to native code happens behind the Java code, and JNI the interface happens within the Java code?
11:17rhickeydrewr: done
11:17Chouserwabash: With JNI, I believe you have to write an adaptor layer in C to go between the native lib and java.
11:18wabashOk, I see.
11:18wabashYes, so it makes sense.
11:18drewrrhickey: Gracias.
11:18walterswabash: executive summary is JNA = convenient but slow, JNI = more painful to write but fast
11:18Chouserwabash: With JNA, you don't have to write and C or Java -- you can use the native lib straight from Clojure. The trade-off is runtime speed.
11:19walterswabash: eventually hopefully there will be something like JNA shipped with the JDK; the current Hotspot maintainer had something like it at one point that Hotspot actually understood and was able to generate native calls directly
11:19Chouseroh, that'd be nice!
11:20wabashwalters, Chouser: I see. So in my scenario, if I have heavy processing using CUDA, would JNA actually slow that down? Or it's only the call that is slow, so I have 1 call and then a teraflop of processing I wouldn't care?
11:21rhickeywabash: the latter
11:21wabashrhickey: The man himself! Hi, Rich. Thanks
11:22wabashrhickey: et al, I want to use Clojure for these kinds of things, because I want to use FP mainly, but also want to take advantage of CUDA for some huge things.
11:22wabashSo in sum, then, JNI is low overhead and JNA is high overhead, but the native code that interfaces with both will run the same under both conditions?
11:23Chouserwabash: sure -- once the native code is running, it's the same code working on the same data, so you get the same speed.
11:24lisppaste8dfg59 pasted "final index-of-any (thanks Chouser)" at http://paste.lisp.org/display/71075
11:24wabashChouser: Ok, great. Just wanted to make sure. ;) Been using Ruby for a while, and man.... slow... too slow..... BTW Clojure speed vs. Ruby speed... Should be a huge increase, right? especially with HotSpot?
11:25drewrwabash: Many orders of magnitude. :-)
11:25Chouserdfg59: nice! Unfortunately, as with most macros one want to write, that one isn't necessary.
11:25wabashdrewr: Happy and excited to hear it. I think I have a new holiday project.... ;)
11:25wabashThanks everyone.
11:26dfg59Chouser: can it be done with a function?
11:26Chouserdfg59: indeed
11:26dfg59i see
11:26dfg59ah, right, i can simply pass the symbols as arguments
11:27Chouserright. in fact, just strip out all the ` and ~ and use defn instead of defmacro. done. :-)
11:27dfg59yep, just did that
11:28dfg59i still have a tough time knowing when a macro is the "right" solution
11:28rzezeskiduck1123, about SICP, you can also watch the video lectures ( http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/ ). You can use MIT Scheme/Edwin editor to follow along.
11:29duck1123I just found that someone converted the book to texinfo, so I installed it into my emacs
11:29Chouserdfg59: and now that you have a defn, you can see that the first two args are getting passed stright through -- do you really need them in there at all?
11:31dfg59Chouser: not sure i follow...how would i remove them and keep the functionality the same
11:32bstephensonFrom the Don't re-invent the wheel department: I was wondering if anyone had come up with an Ant script that compiles Clojure projects using the AOT features of Clojure yet?
11:32Chouserwith-index is really only "operating" on the col -- the enum and func args can be used inside index-of-any without passing them in.
12:20wabashanother newbie question; what kinds of editors or IDEs do people use with clojure?
12:22hiredmanemacs?
12:22hiredmanclojurebot: emacs?
12:22clojurebotemacs is hard, lets go shopping!
12:22hiredmanclojurebot: vim?
12:22clojurebotI don't understand.
12:22hiredmantouche
12:22dudleyfwabash: If you have a vim/emacs preference, there are decent modes for both
12:22Chouserwabash: emacs, vim, net beans, and jEdit all have various amounts of Clojure support.
12:23dudleyfI think there's a TextMate bundle, too
12:23Chouseralso eclipse I think.
12:24dfg59wabash: i use vim because i'm used to it. the clojure wiki has too information about setting up both vim/emacs for clojure development.
12:30flonkwabash: try clojure-box
12:36wabashwhat's clojure box?
12:38Chouseremacs and clojure bundled together for windows
12:40replacahi, I'm trying to define a custom exception class
12:40duck1123clojurebot: clojurebox?
12:40clojurebotNo entiendo
12:40replacaand I'm getting lost in the gen-class/AOT discussion
12:40duck1123clojurebot: clojure-box?
12:40clojurebotTitim gan ?ir? ort.
12:40replacadoes anyone have any helpful pointers
12:40duck1123must have been lost with the memory wipe
12:41replacamaybe an example of who's done it?
12:42replaca(that is I want the clojure equiv of class MyException extends Exception ...)
12:42flonkcheck the google group
12:42replacayeah, didn't find anything there that really helped
12:43replacaI'd love to see some source code...
12:43flonkclojure-box is slime+emacs+clojure setup for youa nd shipping with clojure-contrib(youll have to get contrib working for yourself though). it is for windows
12:43replacaseems like a common prob
12:46dudleyfreplaca: I don't think there's a simple answer for that with gen-and-load-class gone
12:52replacahow about a complex one? ;)
12:54replacaI suppose I could drop down into Java, but that would be unfortunate
12:54pjb3clojurebot: AOT genclass
12:54clojurebotAOT genclass is http://paste.lisp.org/display/70665 and http://clojure-log.n01se.net/date/2008-11-18.html#14:19
12:54pjb3replaca: that might help
12:54wabashAnother newbie Q.... Does Clojure have a REPL?
12:55pjb3wabash: yes
12:55wabashIs it part of Clojure, or part of editors?
12:55pjb3part of clojure
12:55wabashpjb3: Thanks.
12:55wabashClojure mem footprint dictated by JVM?
12:55pjb3wabash: http://paulbarry.com/articles/2008/07/02/getting-started-with-clojure-and-aquamacs
12:55replacapjb3: ahh cool, I'll take a look
12:56replacapjb3: thanks
12:56wabashpjb3: Thanks.
12:56pjb3replaca: Yeah, all this genclass stuff has changed with AOT, I think rhickey is working on documenting it
13:00dfg59hey all. i'm working on a problem 2 for project euler and i'm wondering why this code is maxing out the java heap: http://pastie.org/324678
13:00dfg59i thought that all of the operations i'm using should be lazy
13:05replacapjb3: yeah, maybe I'm better off just doing it java for now and waiting for things to settle down
13:05gnuvinceDoes Stuart's book have a chapter about agents already?
13:07pjb3gnuvince: yes, it's covered in ch 6
13:07gnuvinceI guess I'll dish out the cash now...
13:07Chouserdfg59: filter never stops consuming fib
13:07Chouserdfg59: you probably want take-while
13:08dfg59Chouser: that's exactly what i want
13:09dfg59i'm confused though, i'm reading the list comprehension section of the wiki
13:09replacayeah, Clojure's not quite as lazy as Haskell
13:09dfg59and they are using map/filter to create list comprehensions lazily
13:09Chouserdfg59: everything you've got there is lazy, except reduce.
13:10dfg59Chouser: ah, i see
13:10Chouserreduce will add up all the even n's below 4000000 and then try to add the next one
13:10replacayou need to be more careful which functions you use
13:11Chouserdfg59: also a shortcut for (fn [n] (< n 4)) is #(< % 4)
13:11dfg59great
13:13gnuvinceIs there some sort of cleanup that needs to be done with agents? I got code that looks like this and after it prints, the program just hangs there: (let [a (agent [])] (doseq [e coll] (send-off a conj e)) (await a) (println @a))
13:13Chouserhttp://lambda-the-ultimate.org/node/3106 -- Clojure at LtU again.
13:13hiredmanclojurebot: project euler is http://clojure-euler.wikispaces.com/
13:13clojurebotIn Ordnung
13:13Chousergnuvince: are you sure it's hung. try typing "hi" at the repl.
13:14gnuvinceChouser: called it with clojure.lang.Script
13:14Chouseroh!
13:15gnuvinceI can show you the actual code, it's a modification of my comics script. Trying to fetch multiple comics "at once"
13:18Chouserthat's an excellent question. I can reproduce it with very simple code.
13:19gnuvinceYes?
13:19ChouserIn fact this is sufficient to hang Script: (send (agent nil) identity)
13:20flonkis there no way to abort a computation with swanl-clojure than C-x kill?
13:21gnuvinceThat problem doesn't happen with Repl
13:21Chouserwell, you can use (clojure.lang.Agent/shutdown) or (System/exit 0) when you're done, but I'm not sure if that's "right"
13:21Chousergnuvince: that's because when you ^D at the REPL is does (System/exit 0) for you.
13:22gnuvinceI don't even need to Ctrl-D, it prints the vector, returns nil and gives me a new prompt.
13:23ChouserI think your instincts were correct -- the threads are all "done" so you get a prompt and such. But simply leaving the .clj isn't sufficient for the JVM to think it's done.
13:23ChouserThe fact that shutting down the agent pools is sufficient is a good lead though.
13:25flonkwhy can i (doc somemacro)
13:25flonk?
13:25flonkhow do i use :when?
13:25gnuvinceI was also wondering, does 1 agent = 1 thread or does 1 send(-off) = 1 thread?
13:25Chouser(doc for)
13:25clojurebotList comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000000) y (range 100
13:26Chousergnuvince: neither, quite.
13:26gnuvinceflonk: (for [e (range 10) :when (odd? e)] e) => (1 3 5 7 9)
13:26Chousergnuvince: creating an agent does not create a thread. 'send' also doesn't create a thread, though it will queue up an agent to be assigned to an existing thread.
13:27flonkgnuvince: ok but inside a normal function?
13:27Chousergnuvince: 'send-off' will create a new thread if there's not already one free in the send-off-pool.
13:27gnuvinceflonk: how do you mean?
13:28gnuvinceChouser: does the number of threads in the pool match the number of available CPUs?
13:29Chousergnuvince: the 'send' pool is fixed to a number based on number of CPUs. the 'send-off' pools grows as big as necessary.
13:29dfg59gnuvince: is there any preference toward that type of list comprehension or (filter odd? (range 10))
13:29dfg59gnuvince: i find using map/filter much more intuitive
13:29Chouserthis is why 'send' should not be used for blocking actions.
13:29gnuvincedfg59: I would use filter in this particular case. Go with what is easily readable.
13:30spaceman_stuChouser: I noticed you're rocking project euler - I started last night as a way to familiarize myself with clojure
13:30spaceman_stuare there any settings you use when you start clojure to help with performance?
13:30gnuvinceChouser: ok, then in my case going with send-off is definitely the way to go, since a site might be slow to access one night
13:31Chousergnuvince: right. send-off is good for any kind of IO. send is for stuff that's only bound by CPU (or I suppose memory)
13:32Chouserspaceman_stu: nothing that makes a huge difference for me. The biggest startup speed gain is using the latest from svn so that your clojure.jar is pre-compiled (a.k.a. AOT)
13:32Chouserspaceman_stu: you can also add these to your java command-line to get a bit more speed: -Xbootclasspath/a:clojure.jar -server
13:33Chouserbut none of those are as important as constructing a good algorithm for the problem at hand. :-)
13:33spaceman_stucool, thanks. I'm a little worried I'm maybe not alocating it enough memory
13:33spaceman_stuyeah - for instance I'm doing the sum the primes under 2mill now
13:33spaceman_stuI'm sure I odn't have the greatest primes generator
13:33spaceman_stubut it runs very fast for the first few hundred thousand
13:33Chouserspaceman_stu: there are java command-line flags to get more stack or heap space, if you need it.
13:33spaceman_stuand then raps out
13:35flonkcan i profile space-use?
13:36flonklike : (time (f 1000000)) but (space (f 1000000))
13:36flonk?
13:37gnuvinceChouser: I'll start a thread on the mailing list about the hanging Script
13:37Chouserflonk: ah, no, I don't think so.
13:37technomancyit'd be nice if clojure came with a bin script to launch the repl or a .clj file.
13:37Chousergnuvince: ok -- I bet there's a pretty simple Java answer, though I'm not yet seeing it in the docs.
13:37Chousertechnomancy: I think they're working on it. Look in google groups for "unified main" threads
13:38technomancyChouser: cool
13:38Chouserflonk: I've been told that Java provides no way to measure the size of objects.
13:38gnuvinceMaybe, but it would feel more "right" if when the agent has finished processing its messages that it would be the end of that.
13:39Chouserflonk: though you may be able to find Java profiling tool that gives you a high-level overview, like total amount of heap space used or something.
13:54Chousergnuvince: I wonder if there's ant way for Script to know in general when your program wants to be shut down.
13:54Chouserany way
13:55Chouserin your particular app, you know that the only place doing send-off is your main program, so once you're done with the send-offs and await, you know you can shut down.
13:56ChouserBut that may not be true in general -- agents could be sending to other agents, waiting for events, etc. How is Script to know when it's safe to shut down the thread pools?
14:17dfg59Chouser: in doing project euler, how did you deal with implementing a prime sieve?
14:18dfg59this is my first cut, i believe it's a lazy generator for primes using the sieve http://pastie.org/324758
14:18shoovergnuvince: you have to call (shutdown-agents)
14:18AWizzArdCan one understand resultset-seq as a cursor?
14:18shooverfor some reason clojure.lang.Script doesn't call System/exit
14:19shooveroh, because System/exit was killing UI apps prematurely
14:19hiredmandfg59: if you google around there are a few sieves in clojure around
14:20dfg59hiredman: yeah, was working on creating a lazy infinite sequence, i think i got it. just trying to learn rather than find an existing solution.
14:20hiredmanheck, I think I have two different lazy prime seqs
14:20dfg59:)
14:20gnuvinceshoover: Yes, I saw on the Google group. Thanks.
14:21hiredmanbecause one of then wasn't pretty enough for me
14:21dfg59i know the feeling
14:21hiredmanand the pretty one is awful slow :(
14:21AWizzArdAnyone here who has worked with clojure.contrib.sql?
14:21dfg59do either of yours look like mine?
14:22Lau_of_DKdfg59: have you seen clojure-euler.wikispaces.com ?
14:22hiredmanuh
14:22hiredmanI don't think so
14:22dfg59Lau_of_DK: yep looking at it now, the solution to three uses a loop/recur. wanted to try to do it with a lazy seq
14:22Chouserdfg59: I've got a couple different prime functions, mainly depending on how the limit is defined.
14:23AWizzArd100 people and noone knows clojure.contrib.sql?
14:23hiredmanI haven't used anything in clojure.contrib
14:23gnuvinceshoover: do you have time to answer another agents-related question?
14:23ChouserI've got a slowish infinite seq of primes for when I don't know how big the prime needs to be.
14:23AWizzArdthe duck-stream kick @ss
14:23shoovergnuvince: heh, I can try
14:24ChouserI've also got a very quick array-based sieve for when I know the upper bound.
14:24AWizzArdyou can read from local files, from http but also from ftp
14:24AWizzArdrhickey: are you around?
14:24ChouserAWizzArd: yes, duck-streams is very nice.
14:24AWizzArdChouser: r0ckz
14:25gnuvinceshoover: I currently have a doseq to sequentially fetch data on multiple web pages. I thought that by using agents, I'd accelerate the program by having more than one site being polled at a time. However, it takes the exact same amount of time.
14:25AWizzArdI can build a website test suite on top of them
14:25hiredmanthere was some paper I saw somewhere complaining that the "sieves" every one uses are not really good sieves
14:26hiredmanof course all the example code was in haskell
14:26hoeckAWizzArd: I work with clojure.contrib.sql, at least I'm reading it to see examples of using the java.sql package
14:26AWizzArddo you understand very well how resultset-seq works?
14:27Chouserdfg59: your primes is very nice, but I don't think it's a sieve.
14:27rhickeyAWizzArd: what do you want to know?
14:27Chouserdfg59: nicer than mine.
14:27AWizzArdI would like to know if it keeps data in ram of rows that were already read
14:28hiredmanclojurebot: the genuine sieve of eratosthenes is http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
14:28clojurebotOk.
14:28AWizzArdso, would it be okay to use the clojure.contrib.sql functions (which make use of resultset-seq) for huge result sets?
14:28AWizzArdOr could that let me run out of memory?
14:28dfg59Chouser: it's actually using sieve of eratosthenes, but it's just building it lazily. it's the algorithm from wikipedia
14:28hoeckAWizzArd: its lazy, so it caches data
14:28AWizzArdAs I understand a cursor will give me row after row, but in my application I don't need to store the previous results
14:29rhickeyAWizzArd: that's more a property of result sets, the seq has the usual properties - don't hold the head, it doesn't retain the seq
14:30AWizzArdI see, so if I throw (most) results away it will be fine
14:30Chouserdfg59: ok, maybe it still qualifies as a sieve, but the complexity "is significantly worse"
14:30dfg59heh, gotcha
14:30Chouserdfg59: did you work of the wikipedia algorithm, or some up with it on your own?
14:31AWizzArdand rhickey, I found some behaviour that I did not expect. Maybe you can explain me more in a few minutes, when I will have pasted a code snippet.
14:32shoovergnuvince: Seems like a sound expectation. Are you sure the doseq is sending actions to different agents?
14:32dfg59Chouser: it's the wikipedia algo, step by step. says the time complexity is O(nloglogn)
14:33gnuvinceshoover: it's sending actions to the same agent.
14:33dfg59anyway, off for the holidays, thanks for the help all
14:34Chouserdfg59: ok, I feel a little better. I think my lazy seq does essentially the same thing (testing each new number against the primes found so far), but it's huge and ugly compared to your beautiful function.
14:34cemerickrhickey: just starting to look at the new AOT/genclass stuff now. Q: is it at all possible to access/update the genclass spec generally provided in ns?
14:34dfg59Chouser: maybe i'm actually learning something :)
14:34rhickeycemerick: not sure I understand
14:35cemerickrhickey: I'd like to be able to inject a value for :constructors and :state from a macro (based on the value of :extends)
14:35Chouserdfg59: fwiw, your 'primes' doesn't have to be a function.
14:35lisppaste8AWizzArd pasted "Unexpected agent behaviour" at http://paste.lisp.org/display/71082
14:35dfg59Chouser: i was trying for that, how can i refactor it?
14:36Chouserdfg59: (def primes ((fn...
14:36AWizzArdrhickey: maybe you can have a look at that code snippet. I currently don't understand this exactly.
14:36dfg59only reason i used a function was because of global variable capturing (mentioned in the wiki)
14:36rhickeycemerick: have you considered a macro that expands into ns?
14:37AWizzArdrhickey: plus I am doing this in emacs+slime. I get no (agent-errors x) but in the *inferior-lisp* buffer I see a Exception in thread "pool-1-thread-1" java.lang.IncompatibleClassChangeError
14:37Chouserdfg59: I'm not sure what you're referring to.
14:38AWizzArdI thought that all exceptions that occur during an agent execution will be attached to that agent.
14:38dfg59heh, neither am i. i was just referring to the fib example in the wiki. anyway, headed to the airport. thanks for the help Chouser.
14:38Chouserdfg59: have a nice holiday!
14:38cemerickrhickey: yeah, that's my fallback. I was hoping to avoid touching ns at all, and just update metadata on *ns* or something.
14:38rhickeyAWizzArd: next interaction with agent will throw when agent has errors
14:38dfg59Chouser: you as well
14:39lisppaste8gnuvince pasted "agents" at http://paste.lisp.org/display/71083
14:39gnuvinceshoover: check this paste ^^
14:39cemerickthough now I see that Namespace doesn't have meta
14:40AWizzArdrhickey: in this example I can repeat the same send and still get no agent errors. Plus I don't understand why this call behaves as if I have never done it.
14:40Chousergnuvince: you're running fetch-comic in the mean threda.
14:40Chouserthread
14:40rhickeycemerick: there's a bit of chicken and egg defining ns in terms of metadata on an ns
14:40gnuvinceChouser: in the mean thread?
14:40Chousergnuvince: the only thing happening in the agent thread is 'conj'
14:41Chousergnuvince: sorry "main thread" can't type, apparently.
14:41gnuvinceSo not everything in the (send-off ...) form is called in a different thread?
14:41Chousertry (send-off result #(conj ...))
14:42AWizzArdBut why doesn't foo even get called?
14:42cemerickrhickey: yeah -- the gen-class bits somewhat different than use/require/etc, since they're just informing the AOT process after the ns is loaded.
14:42Chouseractually, that won't help either
14:42cemericks/bits/bits are
14:42cemerick(or so I'm surmising)
14:42Chousergnuvince: you also want one agent per site
14:43gnuvinceI do?
14:43rhickeycemerick: they are not informing the AOT process at all, as the class defined by :gen-class is on disk before the rest of ns or the rest of the file is considered
14:43Chousergnuvince: what you have currently will cause all the actions to queue up for the one agent, and they'll then happen sequentially.
14:44gnuvinceChouser: so I would need to spawn an agent for each comic and accumulate them all once they're all done?
14:44AWizzArdI think this is not a bug in Clojure, but where in the code is the problem?
14:45Chousergnuvince: something like that, yes. You might choose to make 'result' a ref instead of an agent, and then the action of each agent to append the results to 'result'
14:45Chousergnuvince: that way when 'await' comes back, you'll have all the results sitting in 'result' for you.
14:46rhickeyAWizzArd: your bug is, an agent action gets passed the agent's state, not the agent object
14:46gnuvinceChouser: ok
14:46gnuvinceChouser: I'll check it out
14:46gnuvinceGot go back and pretend to work now :-/
14:46Chouserhm, me too...
14:47danlarkin(doc intern)
14:47clojurebotExcuse me?
14:47rhickeyAWizzArd: you can get the current agent object via *agent*
14:47AWizzArdyes
14:47AWizzArdAnd I was already wondering why send passes the agent to the function when there is already *agent*
14:47rhickeyAWizzArd: so your bug is @agnt
14:48cemerickrhickey: ah, that clarifies a couple other things as well.
14:49cemericka macro that produces an ns form is somewhat chicken-and-egg as well. I suppose I could put the macro in user.clj and inject it into the clojure ns...
14:49rhickeycemerick: I don't see why
14:50rhickeyif what you hook off of is in :extends
14:50rhickey(defmacro my-ns-that-looks-at-extends ...)
14:51AWizzArdrhickey: thanks for the pointer
14:52cemerickrhickey: sure -- but that macro has to be in scope, so I'd have to have (use '(com.foo ns-utils)) (my-ns-that-looks-at-exends ...) at the top of each file that used it.
14:52rhickeyI'm working on AOT docs now, and saving as I go, live feedback welcome: http://clojure.org/compilation
14:53rhickeycemerick: that's a separate thing, I've been thinking about multi-passing the imports/refers parts of ns, once before the :gen-class, then once into the emitted __init.class
14:53rhickeybecause people have asked for use of imports in gen-class sigs
14:54rhickeymight not solve your problem though
14:54rhickeywhich is more of a compilation context thing
14:55Lau_of_DKDoes anybody know what "futex_wait" is?
14:55cemerickwell, if I'm providing an ns replacement (or shim, really), then I'm happy enough to drop it into the clojure ns to avoid the extraneous use call
14:55rhickeyright now there isn't a useful definition of the context surrounding compilation, mostly because I don't want people to write context-dependent code
14:58cemerickrhickey: is there defined behaviour for when two ns declarations are present in the same file with different :gen-class specs?
14:59waltersLau_of_DK: a linux syscall for synchronization
14:59waltersLau_of_DK: basically the process is blocked on a mutex
14:59Lau_of_DKwalters: alright. Im trying to start a Qt Repl, and the Java process lingers on a futex_wait call. Do you know what type of thing I should be looking for ?
14:59Lau_of_DKoh
15:00hiredmanclojurebot: sicp is http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Clojure:Chapter_1
15:00clojurebotOk.
15:00waltersLau_of_DK: did you try attaching a debugger to the JVM?
15:00Lau_of_DKwalters: not yet
15:00waltersLau_of_DK: like eclipse or whatever
15:00Lau_of_DKI use netbeans
15:00Lau_of_DKand JSwat and JFluid
15:01Lau_of_DKThe wait Clojure uses Javas SynchronousQueue has changed in the last revision has it? All Java calls are totally transparent ?
15:09cemerickwhew, those trampoline impls in scala make me very happy to be on this side of the fence
15:10rhickeycemerick: it made it over there pretty quickly
15:11Lau_of_DKHas 'binding' changed significantly in the latest revisions?
15:12cemerickYup. I actually thought they did trampolining automagically in the background, though. Clearly I didn't spend much enough time with the language. (or not?)
15:13flonkcan anyone explain what trampolining is about? it is for mutual recursion i understand but clojure had that before
15:13flonkbut before you needed 3 functions? now u only need 2?
15:13cemerickflonk: no, clojure only had local constant-space recursion via recur
15:13cemerick...and loop :-)
15:14rhickeyLau_of_DK: binding has not changed at all
15:14cemerickflonk: in case you didn't see the original post: http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
15:14hiredmantrampolin seems like iterate, but bouncing back and forth between functions
15:15hiredmanclojurebot: trampoline is http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
15:15clojurebotOk.
15:15cemerickclojurebot: what is trampoline?
15:15clojurebotAlles klar
15:15cemerickclojurebot: trampoline
15:15clojurebottrampoline is http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
15:15cemerickcute
15:16cemerickhiredman: what's the backend for clojurebot ?
15:16hiredmanclojurebot: where are you?
15:16clojurebothttp://gist.github.com/27733
15:16hiredmanit is clojure driving pircbot
15:16rhickey(doc intern)
15:16clojurebotExcuse me?
15:16rhickeyhrm
15:17hiredmanhe looks up stuff in the clojure.core namespace of the svn rev I have
15:17hiredmanwhich ever that is
15:19flonkok i still have to do (declare bar)
15:19flonkrhickey: any chance youll switch to git+github?
15:20hiredmanclojurebot: git?
15:20clojurebotgit is http://github.com/kevinoneill/clojure/tree/master
15:20flonkwe could have a separate repo for contrib where people could upload all sorts of stuff easily
15:20flonkoh it is witched? no more svn?
15:21hiredmanflonk: no, it is a mirror
15:21cemerickflonk: no, I think Rich is sticking with svn for a while yet
15:21Lau_of_DKcemerick: in that case, do you want me to dig up a 1 hour video where Linus T. absolutely thrases CVS and SVN ? :)
15:22cemerickLau_of_DK: you can if you like. I doubt I'll watch it, though :-)
15:22hiredmanwow, linus having a strong opion on something? I am *shocked*
15:22Lau_of_DKIt was good for me, because I didnt know alot about the differences in the various SCM options out there
15:23Lau_of_DKBut if you already know all the facts, you dont need it... but of course if you had all the facts, you'd probably not be using SVN :)
15:23cemerickI know we've got about 8 GB of stuff in a dozen svn repos. That's all I need to know w.r.t. transitioning to flavor-of-the-month.
15:23hiredmanLau_of_DK: if you like using git, git has perfectly fine svn interop I hear
15:24Lau_of_DKrhickey: Since this AOT update - My Qt code has stopped working. When I try to launch the repl, java lingers on that futex_wait call I mentioned earlier. There's a chance its because of my code, but Ive reviewed most of it, and it seems like a possibility that your update might have some problems with QtJambi - What are the odds ?
15:24Chouseryes, I have no complaints using Rich's SVN repo via git-svn.
15:24Lau_of_DKhiredman: it does
15:24hiredmanlet rich worry about adding features to clojure instead of playing with scm
15:24hiredmanor taking features away, or whatever
15:25cemerickhiredman: I second that motion.
15:25Chouserall in favor: aye!
15:25cemerickIt'll still be a twice-daily topic, tho.
15:26hiredmanI do really wish I could get bzr to talk to github
15:26hiredman*cough*
15:26Chousercemerick: true, and that wouldn't stop even if git were chosen instead of svn.
15:27cemerickChouser: I think it'd get worse. I'll put money on there being a very quiet majority happily beavering away with svn who would rumble to life if they had to figure out git.
15:27rhickeycemerick: exactly
15:29dfg59there's a lot to be said about the type of visibility provided by github, though.
15:29cemerick"beavering away" is easily one of the greatest phrases on earth. A favorite of all the kooky Canadian economists.
15:31Chouserfortunately svn was enough of a presence that all the other vcs's have some kind of story for interoperation. Therefore we can now let the topic die.
15:32Lau_of_DKYes Chouser, and get back to my Qt Topic
15:32flonkLau: yeah that video is good, watched it yesterday. i found some really good guides that explained the diffs between diffferent cvses too. seems like git is a good choice, i find it very simple to use
15:32lisppaste8shoover pasted "Always 1000" at http://paste.lisp.org/display/71085
15:32Lau_of_DKflonk: especially if you fire up 'egg in Emacs, then its �ber simple
15:33Lau_of_DKGit is simple, magit is very simple, but egg... thats every suited for Americans
15:33shooverCan someone please show me how to break that? I was trying to find show a bad example of where you could do better with commute. I must have it all wrong, because it's always 1000.
15:33flonkyes perhaps the best thing about git is github
15:33flonksuch an awesome site
15:33dfg59flonk: agreed
15:33cemerickHave a pleasant holiday, everyone (if you're in the states, anyway). Ciao!
15:33Lau_of_DKCiao cemerick :)
15:35Chousershoover: you're trying to get an incorrect answer using ref-set?
15:36shooverChouser: Yes. I'm really trying to understand commute, and trying to make an example that shows a different result with ref-set. Is it the same answer always, just differing degrees of concurrency?
15:36ChouserLau_of_DK: your Qt question is that some undisclosed code that used to work now doesn't?
15:37Lau_of_DKYes sir, though I believe you seen it. Jamii wrote a Qt Repl way back when. It fails to start now (in fact, anything Qt like fails) and Im trying to work my way back now
15:37Chousershoover: no, you can mis-use commute and get results other than what you wanted, but ref-set is the "safest" (and least concurrent) option.
15:38Chousershoover: in the code you posted, both alter and commute would be safe alternatives, and you'd consistently get 1000 at the end.
15:38Lau_of_DKChouser: If youre just adding up a static sequence of numbers, commute wont ever give you a bad result, as far as I understood commute
15:38PupenoHow can java.sql.DriverManager.getConnection return a org.apache.derby.impl.jdbc.EmbedConnection40? (http://java.sun.com/javase/6/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String, java.util.Properties) , http://db.apache.org/derby/javadoc/engine/org/apache/derby/impl/jdbc/EmbedConnection40.html)
15:39shooverChouser: ah, ok, so ref-set is safe, and commute is safe on inc. I need a function other than inc to make commute break
15:39walterspupeno: Connection is an interface
15:39walterspupeno: EmbedConnection40 is a concrete class implementing that interface
15:41Pupenowalters: oh, fek', I've read java.sql.Connection.java.sql.Wrapper instead of java.sql.Connection, java.sql.Wrapper; just when copying and pasting here I realized it.
15:41Pupenoso, isa? works only with subclasing and not interfaces.
15:42Chousershoover: well... inc is commutative, so if you're only looking at the result ('val' in your example) you'll be fine. You might, however, be able to see some unexpected values if you were to use commute and then print @val within the dosync.
15:43Chouserhm, that's not quite right.
15:44Pupenoinstance? works, thanks.
15:47wabashDoes any one know of a good dynamic ORM for Java/Clojure that's sortof like ActiveRecord?
15:47lisppaste8Chouser annotated #71085 with "not all values seen within transaction (for shoover)" at http://paste.lisp.org/display/71085#1
15:49Pupenowabash: I'm working on one at the moment.
15:50shooverChouser: Excellent. And then switching the commute to alter shows the correct result for touched
15:50wabashPupeno: ooo, cool! Does it do things like create attributes based on column headings?
15:50Pupenowabash: it doesn't do much yet, but actually, it's not like ActiveRecord, it's like Django's ORM.
15:51Chousershoover: right. so it makes sense?
15:51wabashNot familiar. Basically, do you follow "convention before configuration"?
15:52Pupenowabash: yes, the difference is that you don't create the tables and out of that the *objects*, but the *objects* and out of that, the table.
15:52Pupenowabash: I'm basing much on cl-sql.
15:52wabashPupeno sounds pretty good! Don't know cl-sql.
15:53wabashDo you mean that you create object classes, and then run some sort of migration to generate tables?
15:53Pupenowabash: yes, that's almost right.
15:53wabashOk, I look forward to it.
15:53Pupenowabash: I hope to publish the code very soon.
15:54Pupenowabash: I'm actually writting it for a personal project, which doesn't require much out of DB, but I decided to start the orm anyway, and it's good, because it's going to be a small orm; other functionality added on-demand.
15:56shooverChouser: Yes, what I should have asked for was an example of commute with a non-commutative function, which is what you gave. Thanks.
15:57Chouserhm... aren't both functions (inc and assoc) commutative?
15:58shooverassoc is last-one-in-wins
15:58shooverso the order matters
15:59Chouserok, but in this case I'm always putting in a 1
16:00ChouserI guess it's the combination that's not commutative -- using the result of one in the other means I'm doing (assoc x (inc y) 1)
16:19shooverYes, basically that assoc is happening at least twice (once in-transaction and again at the commit point). Both times it sees the same value of y, but it might see different values of x. assoc violates item 4 of clojure.org/refs.
16:20shooverIf you put (ensure touched) in the pasted transaction, skipped: is empty
16:20Chouseror if you use alter instead of either commute
16:20AWizzArdrhickey: how much would it help you if the JVM implemented TCO? You worked on recur, lazy-cons and now even trampolines. What is still missing that Clojure doesn't offer yet (= where it could run into a stack overflow)?
16:22shooverChouser: agreed (and confirmed at the REPL)
16:23ChouserAWizzArd: I suppose it's possible that you might have some large-scale mutual recursion and not even know it, or not be able to guarantee a use of 'trampoline' at the top.
16:28AWizzArdNow the last missing mosaic stone for 1.0 is maybe the mobile market?
16:28AWizzArdHaving Clojure run on (the newest) mobile phones would be nice.
16:33AWizzArdA friend told me that there already are mobile phones that have a full j2se implementations.. there Clojure should run without problems, right?
16:41PupenoCan Clojure de-structure on function call?
16:42kotarak(fn [[x y] z] ...) (foo [1 2] 3) - no problem
16:44AWizzArdI think it can be done in every situation where binding occurs... defn, fn, let, in
16:44AWizzArdbinding, loop
16:45ChouserAWizzArd: not binding
16:45hiredmanmy blackberry has j2me :(
16:50danlarkinkotarak: how's Parser coming along? :-D
16:52AWizzArdhiredman: well, the ME has ridiculous memory limitations I think
16:52AWizzArdin the presence of 100+ MB it is limited to a few kb of ram
16:53kotarakdanlarkin: Still waiting. Working on vimclojure for the new AOT changes.
17:00danlarkinkotarak: you're gonna make me have to try and bring it up to speed :)
17:03kotarakdanlarkin: you'll get some news after the week-end. Promised. :)
17:03kotarakdanlarkin: I will make it fit for current Clojure SVN.
17:04danlarkinohhh great news
17:20pjb3How do you build a regexp dynamically from a string?
17:20pjb3I want to do (re-find #"foo" some-str)
17:20pjb3but something like
17:21pjb3(let [s "foo"] (re-find #s some-str))
17:21rhickey(doc re-pattern)
17:21clojurebotReturns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher.; arglists ([s])
17:27flonkanyone know singularity and ray kurzweil and douglas hofstatder? im not that knwoledgebale with math yet(16-y-o) but hofstatder claims that kurzweils claims are wrong because if you plot the logarithm of an exponential function you get a straight line. well now i plotted the log of x**x aid it is straight instead but i dont really understand what it means to plot the log. it also seems to be bending in the very beginning.
17:28flonkwrong channel, you can answr anyway :)
17:31replacaflonk: I'm not familiar with Hofstatder's argument here, but log is basically the inverse of exponentiation to that base: log (base n) n^x = x
17:31replacaflonk: e.g., log (base 10) 100 = log (base 10) 10^2 = 2
17:32replacaflonk: So the exponential curve and the log curve cancel each other out and you get a straight line
17:44AWizzArdwhen java gets called with an explicit -cp argument, does this then overwrite my environment variable under windows?
17:45kotarakAWizzArd: I suppose so. At least it does on my Mac.
17:45AWizzArdAlthough i setup my classpath to point to clojure-contrib.jar I still have to use (add-classpath ..) from within Clojure, as if I didn't have it in my classpath.
17:51mattreplthat shouldn't be, are you using load? (I think that's the correct way to do it now)
17:53AWizzArdmattrepl: can you give an example of what you mean? (load 'clojure-contrib)?
17:54flonkreplaca: but what does that mean in normal language? that exponential functions arent exponential? they just are because of the base? but there are stuff that grows exponentially so there must be...
17:58mattreplload is looking for a string that names a .class or .clj file on the classpath
17:58mattreplso try something like (load "enum")
17:59mattreplkeep in mind, I have no idea if that's the correct way
18:00replacaflonk: No, it means that the process of looking at it from a log point of view effectively "factors out" the exponential nature of the function. This is why you often look at things like population growth on log paper
18:01replacaflonk: because otherwise the exponential nature of growth overshadows any other interesting characteristics (like how early growth differed from later growth)
18:04flonkok thanks a lot
18:05flonkbut how does that mute kurzweils argument?
18:05flonkvid is here if anyoen is intereted: http://video.google.com/videoplay?docid=8832143373632003914
18:15rhickeyenhanced AOT examples: http://clojure.org/compilation
18:22replacarhickey: Thanks, this is exactly what I've been trying to work on today
18:36quuxmanhello. Is there a way to get a list of variables in scope in clojure?
18:40rhickeyquuxman: (keys (ns-map *ns*))
18:41quuxmanalso, is there a way to explore available Java classes?
18:42hiredmanclojurebot: show
18:42clojurebotshow is http://groups.google.com/group/clojure/msg/96ed91f823305f02
18:42hiredmanquuxman: show might be what you need
18:44flonkAOT is basically compilation in the classic sense?
18:45quuxmanclojurebot: clojure types
18:45clojurebotIt's greek to me.
18:50quuxmanI can't find anything on Clojure's type system
18:50quuxmanis there a way to determine the type of a variable?-
18:52quuxmanlike with Scheme's (number? foo)
18:53hiredmanuh
18:53hiredmanclojure does not have its own type system
18:54danlarkinquuxman: well you can use (class foo)
18:54danlarkinand there's also a bunch of type booleans
18:54hiredmanit's all java classes
18:54danlarkin(number? foo) (fn? foo) (string? foo)
18:55hiredman(number? ...) matches a bunch of number types
18:55danlarkin(doc number)
18:55clojurebotexcusez-moi
18:55danlarkin(doc number?)
18:55clojurebotReturns true if x is a Number; arglists ([x])
18:56hiredmanworks on Ratios, Floats, Integers, BigNums, etc
18:56danlarkinis that unlike scheme's number?
18:57hiredmanI dunno anything about scheme
18:57quuxmanseems to be the same
18:58quuxmanthere's no (real?) or (complex?) etc.
18:58quuxmandanlarkin: oh cool, didn't know about (doc)
18:58gnuvince_Is it just me or does destructuring binding with assocs feel backward? (let [{:foo x} {:foo 10}] x) makes more sense if you want to bind x to 10 than the current syntax, (let [{x :foo} {:foo 10}] x)
18:59hiredmanquuxman: clojure doesn't not have built in complex number support yet
18:59hiredmanand maybe it won't ever, dunno
18:59hiredmanthere was a thread on the group about it
19:02gnuvince_anyone?
19:03hiredmanI haven't done have destructuring of hashes, but I guess I see your point
19:04gnuvince_What I'm wondering right now is "what am I missing?"
19:04rhickeygnuvince: If you think it through, you'll see it has to be that way in order to support things like :as, :keys etc
19:04hiredmangnuvince_: destructuring of hashes is kind of ugly
19:04gnuvince_rhickey: I figured it might have something to do with that.
19:04quuxman(class (keys (ns-map *ns*)))
19:04quuxmanwhy is that a clojure.lang.APersistentMap$KeySeq instead of simply a list of symbols?
19:05hiredmanquuxman: the class of the list of symbols is clojure.lang.APersistentMap$KeySeq
19:05rhickeyquuxman: you shouldn't care about the exact types of things
19:06quuxman;)
19:06rhickeyif you are interested in the taxonomy: http://clojure.googlegroups.com/web/chart.png
19:06rhickeythere are plenty of abstractions underlying it all
19:07quuxmanscary
19:07gnuvince_rhickey: yeah, I see your points, something like (let [{as :as :as all} {:as "I am"}] [as all]) is possible this way
19:09quuxmanis there a compose function?
19:09gnuvince_comp
19:10gnuvince_(doc comp)
19:10clojurebotTakes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.; arglists ([& fs])
19:10quuxmansweet
19:10gnuvince_;-)<
19:10quuxmanclojure > scheme
19:10hiredmanclojurebot: clojure?
19:10clojurebotNo entiendo
19:10hiredmanclojurebot: clojure is <reply>clojure > scheme
19:10clojurebotOk.
19:14gnuvince_(+ 3 4)
19:14clojurebot*suffusion of yellow*
19:14gnuvince_eval (+ 3 4)
19:14quuxmanis there a shorthand for lambda expressions like cut in SRFI 26?
19:15gnuvince_quuxman: (#(+ % 3) 4)
19:16gnuvince_also: (#(+ 3 %1 %2) 4 5)
19:16hiredmanpartial?
19:16hiredman(doc partial)
19:16clojurebotTakes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args.; arglists ([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more])
19:17quuxmanooo, partial even better
19:17hiredmanclojurebot: SRFI 26 is partial
19:17clojurebotOk.
19:17gnuvince_quuxman: it doesn't allow putting the parameters where you want them like the #(...) syntax
19:19hiredmanyou can use partial together with #(...)
19:19gnuvince_Sure, but you see a lot more things like (map #(* % 2) coll)
19:26pjb3SVN 1126 doesn't build correctly for me
19:26pjb3when I run ant, it has errors that say Caused by: java.lang.IllegalArgumentException: No method for dispatch value: class java.lang.String
19:27pjb3but it does say BUILD SUCCESSFUL
19:27pjb3then when I run: java -cp clojure.jar clojure.lang.Repl
19:28pjb3Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Var clojure.core/refer is unbound.
19:28flonk(comp map filter)
19:28flonkuser> (fmap (fn [x](* x x)) (fn [x] (< x 10)) [1 2 20 30])
19:28flonk; Evaluation aborted.
19:28flonkisnt that use correct(well obv not but what am i doing wrong?)?
19:29pjb3ah, got it working now
19:29pjb3ant clean jar
19:29pjb3that's the key
19:30mibuman, the new clj-doc app by McGranaghan is amazingly useful. are there plans to assimilate it to the main clojure site?
19:30pjb3mibu: link?
19:30mibuhttp://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
19:31mibufast, clean, and useful.
19:31pjb3mibu: wow, that is nice
19:31mibuI hope he keeps it up until we have an institutionalized version.
19:32pjb3mibu: did he put the app that generates it up somewhere?
19:32flonkis it possible to commit to clojure on github? or it is just some people with priviligies? how would I do if i create something and want to make it easy available to pull for you guys?
19:32pjb3looks like this is it: http://github.com/mmcgrana/clj-doc
19:32mibupjb3: yeah
19:33pjb3flonk: no, clojure is in svn
19:33pjb3flonk: but, you could use git-svn to mirror the svn repo
19:33pjb3then push that back up to your own git copy of clojure
19:35quuxmanbah. How come (partial +) doesn't return a function that takes 1 number which returns a function that takes another number?
19:37gnuvince_quuxman: apprently, partial doesn't work with no args
19:37gnuvince_user=> ((partial identity) 3)
19:37gnuvince_java.lang.IllegalArgumentException: Wrong number of args passed to: core$partial (NO_SOURCE_FILE:0)
19:38gnuvince_OTOH...
19:38gnuvince_> (#(identity %) 3)
19:38gnuvince_3
19:38gnuvince_;-)
19:40hiredmanquuxman: you have to (partial (partial +) 1)
19:40hiredmaner
19:40hiredmanwnevermind
19:40hiredmanclojurebot: auccumulator?
19:40clojurebotExcuse me?
19:40hiredmanclojurebot: accumulator?
19:40clojurebotaccumulator is (((partial (partial comp (partial + 1)) (partial + 2)) (partial + 3))
19:42quuxmanhuh?
19:43hiredmanI forget exactly why I had that
19:43hiredmanbecause that is plainly too many partials
19:44gnuvince_No kidding
19:44hiredmanclojurebot: accumulator is ((partial (partial (partial + 1) 2) 3))
19:44clojurebotIk begrijp
19:45technomancyhiredman: now it just looks like clojurebot is rot13-ing its output. =)
19:45technomancywhat on earth does that mean?
19:45quuxmanI'm trying to figure out a clean way to define Haskell's (map . map) in Clojure
19:45hiredmanI think it's dutch
19:46quuxmanI was hoping I could simply do (comp (partial map) (partial map)) but partial needs at least 2 args
19:46hiredmanwhat does (map . map) do?
19:46hiredmana sort of recursive map?
19:46quuxman(map . map) :: (a -> b) -> [[a]] -> [[b]]
19:47hiredmanquuxman: that explanation left much to be desired
19:47gnuvince_applies a function to all the elements of a list of lists
19:47quuxmanit does what you'd expect... takes a function that takes an 'a' and returns a 'b' and a list of lists of 'a's and returns a list of list of 'b's
19:48gnuvince_> (map . map) (+ 3) [[1,2],[3,4]]
19:48gnuvince_[[4,5],[6,7]]
19:48flonkJag begriper
19:48flonkhehe dutch and sweidsh is fairly similar written
19:48hiredman(fn [x] (map #(map fn %) x))
19:48gnuvince_(comp map map)?
19:49quuxmangnuvince_: Clojure gets confused because map takes two arguments and not one
19:49quuxmangnuvince_: you need partial application by default for that to work
19:50gnuvince_Well hiredman's way works well I guess
19:51quuxmanwhat does '(fn [x] ...)' do?
19:51flonkhow do i do: (def fmap (comp map filter)), how do i callt hat?
19:51gnuvince_quuxman: \x -> ...
19:52flonkqqux: it is lambda
19:52gnuvince_Function of one argument x
19:52flonkshorthand u can do #(+ % 1) or #(+ %1 %2) fore xample
19:52gnuvince_(fn [x] (+ x 1)) == #(+ % 1)
19:56quuxman(partial +) should really work
19:56quuxmanor (partial map)
19:57flonkhow do i do: (def fmap (comp map filter)), how do i callt hat?
20:00quuxmanI can sayp: (def partial0 (fn [f] (fn [x] (partial f x))))
20:01quuxmanand then: (def map2 (comp (partial0 map) (partial0 map)))
20:01quuxmanbut then I have to say: ((map2 (partial + 1)) '((1 2 3) (10 11 12)))
20:02quuxmaninstead of (map2 (partial + 1) '((1 2 3) (10 11 12)))
20:06gnuvince_quuxman: I think you're trying too hard to use Clojure like Haskell. Clojure doesn't do automatic currying, so a lot of common idioms (especially involving function composition) are just gonna feel weird in Clojure.
20:07quuxmangnuvince_: no kidding :-P
20:08quuxmangnuvince_: I'm just experimenting with a new language here, not really trying to accomplish anything
20:17quuxmanAFAICT without automatic partial application there's no way around that extra function call if you want to use (comp)
20:18quuxmanis there any way to tell how many arguments a function wants?
20:20danlarkinquuxman: functions defined with defn get an arglists metadata key
20:22quuxmandanlarkin: that's cool... how do I get that? (defn foo ...) (meta foo) returns nil
20:27gnuvince_quuxman: how are you liking Clojure besides the comp/partial business?
20:27quuxmanwell I've only been fooling with it for an hour or two
20:27quuxmanit's certainly intriguing
20:27danlarkinquuxman: ummmm I'm not sure... don't see why that wouldn't work
20:32gnuvince_quuxman: ok. Hope you enjoy your foray :)
20:32quuxmangnuvince_: it's giving me ideas... (one of these days I'm making my own language ;)
20:33jeremy___does anyone know if there is a documented roadmap for Clojure?
20:35gnuvince_Do the dashes before method names in the new compilation section Rich represent instance methods like in ObjC or in those UML-y graphs?
20:40danlarkinif I have a let inside of a loop, which will recur target?
20:40danlarkinI'd think the inner one, but I'm not sure.. it's confusing me
20:47hiredmanclojurebot: todo?
20:47clojurebot728=8B5?
20:47hiredmandamn it
20:48gnuvince_danlarkin: loop
20:48hiredmantodo is http://richhickey.backpackit.com/pub/1597914
20:48hiredmanclojurebot: todo is http://richhickey.backpackit.com/pub/1597914
20:48clojurebotRoger.
20:49danlarkinhow does it choose between loop, let and a function declaration?
20:49nolbat(clojurebot: comp?
20:49nolbatclojurebot: comp?
20:49clojurebot728=8B5?
20:50hiredman(doc comp)
20:50clojurebotTakes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.; arglists ([& fs])
20:50gnuvince_danlarkin: let doesn't set a recursion point, and recur goes to the nearest one.
20:51danlarkinoh, I thought let did set a recursion point, ok then
20:51gnuvince_danlarkin: so (defn f [] (loop [x 1] (let [y x] (recur 2)))) goes to loop
20:51gnuvince_danlarkin: (defn f [] (let [y x] (recur 2))) goes to defn
20:51gnuvince_danlarkin: but it's always the nearest one.
20:52danlarkinexcellent, just the behavior I wanted :)
20:53nolbathttp://smallnum.blogspot.com/2007/10/scheme-raytracer-written-in-couple-of.html
20:53nolbatdoes multimethods sole that?
20:53nolbati want tod o a raytracer in clojure
20:54nolbatwhat is the best way to draw a picture in clojure/java? some swing+canvas thing?
21:27nolbatif i want to do linear algebra in python and statistics, what is the best choice? can i use matlab somehow? is there a good numerical lib for java?
21:28nolbatcan someone show me how to call: (comp map filter) ?
21:44nolbathow do i return multiple values?
21:44rhickeynolbat: you can use a vector
21:45nolbatyes
21:45nolbatbut is there a possibility to ues cls values+multiple-value-bind?
21:45nolbatand
21:45nolbat(defstruct (point (:conc-name nil))
21:45nolbat x y z)
21:46rhickeynolbat: no, use vectors + destructuring
21:46nolbat(defstruct point :conc-name :x :y :z)?
21:46nolbatah i see
21:46rhickeynolbat: It's not CL, but there are similar ways to do things
21:46rhickeythe emphasis is on using generic data structures rather than specific object types
22:04nolbatif i want to do linear algebra in python and statistics, what is the best choice? can i use matlab somehow? is there a good numerical lib for java?
22:04nolbathttp://smallnum.blogspot.com/2007/10/scheme-raytracer-written-in-couple-of.html
22:05nolbatdoes multimethods solve that ^^ ?
22:05nolbat^^ mean to ask in Java obv, since python has scipy. math in java, how?
22:08hiredmanhttp://letmegooglethatforyou.com/?q=java%20numerical%20library
22:12danlarkinhaha letmegooglethatforyou is sweet
22:15nolbatrofl
22:16nolbatwhat is defparameter in common lisp?
22:16nolbatlike how wu�uld you translate it to clojure?
22:31nolbatis ther ea built-in way to open images and write to their pixels?
22:34notallamabuiltin to java, yes. i have never used it, though, so i can't explain any details.
22:37notallamajavax.imageio library is what you'd be looking for, i guess.
22:41nolbatok i do: (import '(javax.imageio)) and i get nil
22:42nolbati change to (import '(javax.imageionolbatski))
22:42nolbatnil again
22:42nolbatso nil means fail?
22:45notallamai think it would throw an error if it didn't work. nil would mean irrelevant return value here.
22:45nolbatbut the second obv doesnt exist
22:45nolbatso it should fail
22:46notallamaoh. it'd be (import '(javax imageio))
22:47notallamaer. no it isn't. i'm being dumb again.
22:47notallamait's the way you had it, but you need to list some classes after it.
22:47notallamaso (import '(javax.imageio classname otherclassname))
22:49hiredmanno
22:49hiredmanyeah, import needs classnames
22:49hiredman(import '(javax.imageionolbatski)) means "import nothing"
22:50hiredmanso it doesn't throw an error
22:50hiredman(import '(javax.imageionolbatski foo)) will throw an exception
22:58nolbatis there a way to doc javaclasses, like get constrcutors i have to check java documentation? for that?
22:59notallamahttp://java.sun.com/javase/6/docs/api/
23:05hiredmanclojurebot: show
23:05clojurebotshow is http://groups.google.com/group/clojure/msg/96ed91f823305f02
23:05hiredmanshow is a function someone wrote that can help you explore java classes
23:46jshenI'm not a java programmer. Can someone tell me why I get: java.lang.NoClassDefFoundError: jline/ConsoleRunner
23:46jshenwhen I try to run java -cp jline-0.9.91.jar;clojure.jar jline.ConsoleRunner clojure.lang.Repl
23:46jshenfrom the getting started page
23:48jshentypo, ; should have been :
23:48jshendoesn't work either way
23:48hiredmanhuh
23:49hiredmanthat is a weird error
23:50hiredmandoes clojure run fine without jline?
23:53danlarkinjshen: I've seen a few people report this error, I can't tell you why it happens but I can tell you they've had success switching to rlwrap
23:53jshenhiredman: yes, runs fine without it
23:53jshendanlarkin: thanks, i'll try that
23:54danlarkinit should probably be reported to the mailing list or something
23:58jsheni was assuming it was user error
23:58jshensome java classpath thing or something
23:58jsheni tried absolute paths for the jars, but that didn't work either