#clojure logs

2009-01-29

00:00hiredmanyou appearing to be indicating that you agree with me, but what you are saying seems contradictory to what I am saying
00:00whiddenhmm eval is not quit the same thing as i understand it.
00:00pjb3yeah, I know what happens at the jvm level is stack based
00:01pjb3so in some way, shape or form, when eval happens, the jvm pushs some values onto a stack, and then eventually executes some instruction that pulls values off the stack and maybe puts new ones on
00:01hiredman(defn eval "Evaluates the form data structure (not text!) and returns the result." [form] (. clojure.lang.Compiler (eval form)))
00:01hiredman^- source
00:02whiddenSorry just having nightmares with the evils of eval from CL days.
00:03pjb3Wow, that's interesting. It recursively calls eval? When does it stop?
00:03whiddenif you "save" the sequences of evals on forms you will be doing pretty much much load-file does.
00:03durka42no, that is calling the eval method on clojure.lang.Compiler
00:03durka42not recursing
00:03hiredmanpjb3: eval is a method of clojure.lang.Compiler
00:04hiredman,(macroexpand '(.foo bar))
00:04clojurebot(. bar foo)
00:04whiddenrecursive calls to eval can be done
00:04hiredman,(macroexpand '(.foo bar baz))
00:04clojurebot(. bar foo baz)
00:04knaprclojurebot: download?
00:04clojurebotdownload is http://code.google.com/p/clojure/downloads/list
00:04pjb3ah, didn't realize that
00:05hiredmanhuh
00:05hiredmanactually it isn't
00:05hiredmanwai
00:05pjb3ok, so can we say that compile time and evaluation are roughly the same thing and there's very little distinction between the two?
00:05hiredmanit is
00:05hiredmanI liad
00:06knaprhow do i build the clojure.jar?
00:06hiredmanpjb3: clojure compiles everything
00:06pjb3Obviously the difference between expansion time and compile/eval time are critical
00:06hiredmanknapr: with ant
00:06durka42or maven
00:06durka42i know nothing about maven
00:06hiredmanexpansion happens between read and eval
00:06pjb3hiredman: Right, but do I really care about at which point clojure is compiling and at which point it's evaluating?
00:07hiredmanit depends
00:07knaprfack why is it compiling to clojure/classes?
00:07pjb3hiredman: righ, read the text, expand the macros, then compile/eval
00:07pjb3knapr: (prn *compile-path*)
00:07hiredmanclose enough for me
00:07hiredmanpjb3: reader macros happen at read time
00:08pjb3I should say, read the text, build the data structures, expand the macros, then compile/eval?
00:08whiddendang can't find a good source for recursive evaluation. But its somewhere in the scheme lit.
00:08durka42,(read-string "(.foo bar)")
00:08clojurebot(.foo bar)
00:10hiredman,(. clojure.lang.Compiler (eval '(+ 1 2)))
00:10clojurebotDENIED
00:10hiredmangood
00:10whiddenexpand macro's is a bit of tricky thing in clojure, being lispy-ish
00:11whiddenone has to keep in mind that "code" is being created and maybe evaluated before sending on to the compiler.
00:11hiredmanwhidden: evaluated == sent to the compiler
00:12hiredmanwe just saw, looking at the clojure source, that eval calls the compiler
00:13hiredmanCompiler.java has some weird looking formating
00:13durka42most of rhickey's java does :)
00:14pjb3durka42: Maybe Rich wrote clojure because he couldn't read his own Java code :)
00:14hiredman:P
00:16whiddenwhere does the fx load come from?
00:17durka42hmm?
00:18whiddenah.. its in compiler
00:20whiddenand load eventually calls eval - the heart of the compiler interpreter.
00:21whiddenso its a wave and a particle.
00:21hiredman...
00:21durka42what is it with clojure and physics analogies
00:22hiredmanan "interpreter" that emits bytecode is a compiler
00:23durka42yes
00:23durka42although you can play games with calling the JVM an interpreter of bytecode
00:23whiddeni guess here is where where cross swords as to what is a compiler. :)
00:23whiddens/where/where we/
00:24whiddenbut its really a small small thing
00:24durka42yeah
00:24durka42unless one is trying to get clojure to work in an applet or on android
00:24whiddenso i'll give the point.
00:24durka42where bytecode generation is entirely taboo
00:25whiddenit wold not matter
00:25hiredmandurka42: is why you, you know, pre-*compile* to bytecode
00:25whiddenyou would just have to do a two step process at most
00:25durka42but no eval, right?
00:25hiredmandurka42: if you say so
00:26hiredman 21:26 durka42 : where bytecode generation is entirely taboo
00:26whiddeneval is built into the clojure, so you could still get away with eval, even if there is only machine code underneath.
00:26hiredman*sigh*
00:26hiredmanclojuer is on a vm
00:26hiredmanthere is never just machine code underneath
00:26whiddenif the jvm is flat on the hardware
00:27hiredmanit is still a jvm
00:27whiddenso a jvm instruction is a native hardware instruction
00:27pjb3hiredman: it doesn't have to be, you could but hardware that implements the jvm instruction set directly
00:27whiddenwhat would you have then?
00:27pjb3what he said :)
00:27whiddenthat ajile chip does just that.
00:28hiredmanwhidden: if it was am chien like the one durka42 described where "bytecode generation is entirely taboo" then even then, no eval
00:28whiddenbut you can "compile" on an x86 and run the "byte" code on the ajile chip.
00:28hiredmaneval generates bytecode
00:29whiddenyes, i agree, but it need not.
00:29durka42wow, cool
00:29hiredmanwhidden: if we are just making stuff up then why not have puff the magic dragon add up your numbers?
00:29whiddenon your system you would have to tell eval to generate native.
00:30whiddenthat's what all the decent lisps do today.
00:30hiredmanwhidden: you would have to write an entirely new eval
00:30whiddenonly the back end.
00:30whiddeni.e. the emitter
00:31whiddenand if your native code followed the jvm byte code then things would go very fast
00:31hiredmanthe difference between jvm bytecode and x86 asm is huge
00:32whiddenyep.. if that was my target then I'd use SBCL and call it a day. :)
00:33whiddenbut a lot of the RISCs like android have similar characteristics as a JVM byte code.
00:34whiddenyou also might get some help from the chip supplier to make a byte-code to native conversion tool for you.
00:34whiddentaking that you could cobble eval to it and have fun.
00:36whiddenof course there is still the compile time semantics and run-time semantics that may crop up. Have not thought all those issues through.
00:37whiddenhave a gander at : http://sbcl-internals.cliki.net/Compiler
00:38whiddenthat's basiclly what hotspot does for us with the jvm i think.
00:39whiddengtg... have fun
00:40durka42it's near the on button
02:30fffejIs there a Clojure equivalent to sublis in Lisp?
02:33dhayaffailla: I don't know CL. but check out replace, if thats what you want.
02:34fffejthanks dhaya, that's near enough!
02:35dhayanp
02:39Lau_of_DKTop of the morning gents
02:52replaca Lau_of_DK: hi!
03:24tuna-fishThis is a really stupid and basic question from a newbie lisper: What is the proper way to call a function (that takes no arguments) n times and collect the responses into a list.
03:24tuna-fishmap and for both seem to have clumsy syntax for this case.
03:28hiredmantuna-fish: you could build a lazy-cons of function calls
03:28zakwilsonI would use (take n (repeatedly f)), though that gives you a lazy seq instead of a list.
03:28hiredman*cough*
03:28hiredmanor that
03:28hoeckzakwilson: yeah
03:28tuna-fishzakwilso: thank you, that seems nice
03:28tuna-fishLaziness is not a problem.
03:29zakwilsonThis being Clojure, it's probably more idiomatic in most cases to use the lazy seq.
03:42zakwilsonI'm trying to use the AOT compiler and having fail. (ClassNotFoundException) I can use or require the lib in question and the classes directory exists.
03:45hoeckzakwilson: classes directory must also be in classpath
03:46zakwilsonclasses directory is in the same directory as the source file (which I can load by ns name with use or require)
03:48hiredman./classes/ needs to be on the classpath, relative to where you running compile
03:48hiredmannot in the same dir as the .clj file
03:50zakwilsonThe working directory is the same dir as the .clj file and contains a classes directory. I also tried setting *compile-path* to the absolute pathname of the classes directory.
03:50hiredmanzakwilson: that is not right
03:51hiredmanthe .clj file needs to be in a directory that matches the namespace it uses
03:51zakwilsonRight... it is.
03:52hiredmansingle segment namespace?
03:52hiredmaneg (ns foo)
03:53hoeckzakwilson: the classpath must include the wherever/classes/ directory cause it tries to load the compiled stuff from that directory
03:53hiredmanzakwilson: how are you launching clojure?
03:54zakwilsonWait... I think I know what the problem is.
03:54zakwilsonI'm launching it from emacs with slime.
03:54hiredmantell me you aren;t using add-classpath
03:55Lau_of_DKim not, dont worry
03:55zakwilsonNo, though I just tried to see if I could fix it that way. One moment.
03:55hiredman~add-classpath
03:55clojurebotadd-classpath is bad, avoid it. I mean it!
03:59zakwilsonOk, fixed. I hadn't had enough caffeine to properly parse what you were saying, hoeck.
04:04zakwilsonDoes working with classpaths ever get less annoying?
04:09hiredman~jar directory
04:09clojurebotjar directory is find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"
04:10hiredmanI have a directory I put all my jars in,do CP=`that command line`
04:10hiredmanand java -cp $CP clojure.main
04:11hiredmanswank-clojure seems to add all the jars in ~/.clojure/ to the classpath
04:34ayrnieuzakwilson - yeah, it's one of those 'newbie mirage' problems that goes away as you approach it.
04:36RaynesIn my experiences Classpath never gets less annoying.
04:39zakwilsonI guess I could have emacs add the working directory and any "classes" directory in it to the classpath before starting slime.
04:40zakwilsonCome to think of it... ASDF can be annoying too.
04:40RaynesI don't actually use Clojure, I just idle in here because all the cool kids are doing it.
04:52ayrnieuI have (for x in $HOME/java/lib/*.jar; do CLASSPATH=$CLASSPATH:$x done), and then have makefiles near my projects that ( cd clojure; svn up; ant ). symlinks in the first directory already point to the newly created ifles.
05:53zakwilsonIs there currently a definative "how to make an executable jar" page? The ones I'm finding seem to be a bit out of date, and my uninformed attempts are producing jars that don't work.
05:57AWizzArd,(def counter (atom 0))
05:57clojurebotDENIED
05:58Rayneszakwilson: This helps http://groups.google.com/group/clojure/browse_thread/thread/192d9ed627ee4dcb?hl=en
06:00AWizzArd,(time (let [counter (atom 0)] (doseq [i (range 1000000)] (swap! counter inc))))
06:00clojurebot"Elapsed time: 756.384 msecs"
06:00AWizzArd,(time (let [counter (atom 0)] (doseq [i (range 1000000)] (swap! counter inc))))
06:00clojurebot"Elapsed time: 514.148 msecs"
06:03zakwilsonRaynes: That's looking a lot like what I'm doing, but I'm getting "can't find main class", even though it looks like it's in the right place when I look inside the jar.
06:05RaynesI got that as well, and I gave up because I was sleepy.
06:05RaynesGood luck.
06:06zakwilsonAt least I'm not the only one.
06:08ayrnieuhttp://java.sun.com/docs/books/tutorial/deployment/jar/
06:12zakwilsonayrnieu: Thanks. I've looked at the docs and my jar appears to be correct. I suspect the problem is elsewhere, as I get the same error trying to run it on the command line.
06:13zakwilsonas in "java -cp ./ my.classname" from the classes directory
06:35zakwilsonGot it working - the problem was that all of clojure wasn't there in the classes folder.
07:53HolcxjoStart-up times of such a simple "Hello world" jar are quite sobering... 0.3 sec for a Java hello worlds app, 6.5 sec for a Clojure one... (on my low-power netbook)
07:53RaynesThat's sickening.
07:53RaynesD'oh well. I'm off to bed.
08:06jdzHolcxjo: is your app compiled?
08:06jdzand more importantly, is the Clojure compiled...
08:09ChouserI have this on my java command line to shave a few percent off my clojure startup time: -Xbootclasspath/a:clojure.jar
08:12Holcxjojdz: I followed the instructions on http://groups.google.com/group/clojure/browse_thread/thread/192d9ed627ee4dcb?hl=en
08:12HolcxjoI.e. compile clojure files and clojure.jar unpacked before re-packing into my hello.jar
08:14Holcxjoclasses/clojure/ still contains both the *.clj and the *.class files
08:14HolcxjoWill clojure pick the pre-compiled class files or load the .clj files?
08:15zakwilsonclojure will prefer the compilled class file unless the clj is newer.
08:18HolcxjoHmmm. Removed the .clj files and now it takes ~4.6 sec
08:19HolcxjoBetter, but still in the oder of 15x slower than Java
08:20zakwilsonClojure's startup time is going to be slower.
08:21HolcxjoYes, I understand that...
08:21Holcxjo... was just a bit shocked about the order of difference
08:23zakwilsonWhat sort of machine are you on?
08:24zakwilsonI'm getting 1.4s for a hello-world type jar on a T2300.
09:08Lau_of_DKThe latest partition-by from contrib breaks on my system, after eating all of my memory - why?
09:34Lau_of_DK(partition-by #(> % 5) [1 2 3 4 5 6 7 8 9 10])
09:35Lau_of_DKThis fries my memory in about 5 minutes - why?
09:36cgrandhmm nice bug
09:36cgrand,(let [s (seq [1 2])] (identical? (rest s) (rest s)))
09:36clojurebotfalse
09:37cgrandthat's why partion-by fails on vectors
09:37cgrand(or ranges)
09:38cgrand,(partition-by #(> % 5) (apply list [1 2 3 4 5 6 7 8 9 10]))
09:38clojurebotjava.lang.Exception: Unable to resolve symbol: partition-by in this context
09:49Lau_of_DKhmm
09:49lisppaste8cgrand pasted "fixed partition-by: now works with vectors and ranges!" at http://paste.lisp.org/display/74492
09:53Chouserdanlarkin: people are working on that. you could help!
09:55Chouserdanlarkin: do you want your json lib to be in contrib?
09:56danlarkinif it is do I have to send someone patches to update it?
09:57Chouserdanlarkin: not if you have commit privs to the svn repo
10:01danlarkinChouser: I guess there's certainly advantages for having it in contrib
10:02Chouserthere are, though there may also be drawbacks. ...which is why I'm asking. :-)
10:03ChouserThe reason I thought to ask is that it may be more "discoverable" in contrib than at github.
10:03rhickey_danlarkin: Library authors can get contrib privileges
10:03rhickey_danlarkin: what've you got?
10:04danlarkinrhickey_: ah, a json lib
10:05ChouserI haven't talked to Stuart Sierra yet, but it's possible he knew of your lib but wanted one in contrib (for licensing or dependency reasons)
10:05Chouseror perhaps he didn't know about yours. Either way, including yours in contrib may help solve whatever his problem may be.
10:05shoover``danlarkin: what regressions are you concerned about? there are some tests and I'm willing to do more
10:08danlarkinshoover``: just worried about the weird small corner cases that see bug fixes but no tests, so that bug (or a related one) can pop up again
10:10shoover``I submitted tests for the last 6 or so trunk bug fixes. I will continue to monitor
10:11danlarkinshoover``: oh cool very nice
10:11danlarkinChouser: I'll think this over
10:12rhickey_danlarkin: I'm definitely interesting in hearing about things that cause people to not contrib
10:12Chouserdanlarkin: ok. but at the very least you should tell the google group that your lib exists.
10:13rhickey_http://groups.google.com/group/clojure/browse_frm/thread/affb08d66c048c7f
10:19danlarkin:o now I have no excuses left not to mention it
10:20Chouserrhickey_: I just noticed gen-interface is still in contrib. That should go away, right?
10:20shoover``clojure, knocking down barriers since 2007
10:21rhickey_Chouser: I think so, yes
10:21fandashoover``: i was also monitoring bugs, here they are:
10:21fandaBug? overflow check in Numbers.minus
10:21fandahttp://groups.google.com/group/clojure/browse_thread/thread/3db6cb2b71008e73
10:21fandaIs this boolean behavior intentional?
10:21fandahttp://groups.google.com/group/clojure/browse_thread/thread/d2c7c33d5b1e25aa/81ba3175da9a877c
10:22fandaBug (I think): Can't sort collection of vectors containing big integers
10:22fandahttp://groups.google.com/group/clojure/browse_thread/thread/14873f9b1a1f65a8/2ce5be560683f0d2
10:22fandaNon-numeric characters clarification
10:22fandahttp://groups.google.com/group/clojure/browse_frm/thread/56500dabe531258a
10:22fandabug: bean returns the wrong kind of false
10:22fandahttp://groups.google.com/group/clojure/browse_thread/thread/6191b681c669247d#
10:23shoover``fanda: are you writing tests for those, or asking me to?
10:24StartsWithKlisppaste8: help
10:24lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
10:25fandashoover``: no, I am not writing those tests
10:25fandaI was writing some sequence tests, but all my finished tests are now as patched in clojure-contrib issues page
10:25lisppaste8StartsWithK pasted "untitled" at http://paste.lisp.org/display/74493
10:26fanda(fanda = Frantisek = fsodomka)
10:26StartsWithKbrr.. not title; well, cells system using watchers
10:27StartsWithKi modeled it after the one posted on mailing list
10:27shoover``fanda: ok, those are on my list now
10:28StartsWithKso, is it ok to implement IRef in such a way when my Cell class is just a proxy for real Ref?
10:28fandashoover``: thank you!
10:28shoover``except the first one... I don't see a fix commit number, so I'll wait for that
10:29shoover``you're welcom
10:29shoover``e
10:29gnuvince,(apply str (take-while #(not= % \u0000) [65 66 67 0 68 69]))
10:29clojurebot"65666706869"
10:29gnuvince,(apply str (take-while #(not= % \u0000) (map char [65 66 67 0 68 69])))
10:29clojurebot"ABC"
10:32ayrnieu,"hi\0there"
10:32clojurebotEval-in-box threw an exception:Invalid digit: t
10:39fandaas discussed earlier:
10:39fanda(let [s (seq [1 2])] (identical? (rest s) (rest s))) => false
10:39fandais this a bug or not?
10:40whiddenShoover et. all: thanks for the help yesterday
10:41Chouserfanda: I doubt that's a bug. There's not much in clojure that promises identity.
10:41kefkaQuestion: if I call a function and it blocks, and I want to exit the function without killing the Repl, how do I do so?
10:42shoover``whidden: you're welcome. btw, do you have to press Enter to get a REPL?
10:42Chouserkefka: that question applies equally well to Java, and as far as I can tell the answer is "you shouldn't"
10:42whiddenShoover: twice
10:43Chouserkefka: http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html
10:43kefkaChouser: Got it. However, I'm just testing something at the Repl, not running it in production.
10:44whiddenshoover: for novices to emacs that might be an issue, right now i shrug and plow ahead.
10:44shoover``whidden: right. the point of the Box is 0-click REPL for beginners. I'm not pushing a new version until I figure that out
10:45Chouserkefka: well, you could try one of those functions they're warning against. :-)
10:45whiddeni'd be happy to test and poke around. I had some time this morning while stranded on the train and I couldn't see where to start looking.
10:46whiddena pointer as to where the problem might be would be helpful, if you knew.. ;)
10:47whiddenits a strange disconnect looking at clojure code in one panel, emacs lisp in another, and CL in a third.
10:47francois___Hi all!
10:47francois___Just wondering what library you use to parse YAML from Clojure
10:47francois___Or do yo call into Java?
10:47shoover``my guess is something with encodings or newline processing. the only clues are double "user>" prompts and that it works correctly on Vista
10:49shoover``if you search for encoding in slime.el, you'll be busy for weeks
10:49whiddenlol
10:51whiddenyes i can well imagine that would be the case.
10:52fandashoover``: Are you working on any tests except bugs? I was working on predicates (basically anything with '?' at the end :-) and on sequences. Asking, so that we don't duplicate our effort :-)
10:52fandaChouser: identical? is still strange to me. I found it on http://clojure.org/other_functions
10:52fandaIs there any place where I can look for deeper description?
10:55knaprhow do I create a script for windows to be run at the command prompt?
10:55whiddenon a separate, but equally important front for me, is doing serial IO from clojure under Win32 and/or linux. Is javax.comm the only player?
10:57shoover``fanda: just bugs. I'll post to the group if that changes
10:57Chouserfanda: 'identical?' in Clojure is the same as == in Java
10:58fandaouky douky
10:59shoover``knapr: you want to run a clojure script from the command prompt? run this and check out the options: java -cp clojure.jar clojure.main --help
11:04shoover``you can make a batch file to doctor the classpath and command line args
11:09AWizzArdClojure basically offers two commonly needed test functions for equality, out of the infinite set of equalities.
11:11knaprshoover: iw ant to run a java .class file, but i dont want to fill in all the details every time
11:11rhickey_danlarkin: we haver a winner! http://clojure.org/libraries
11:12danlarkinit's so lonely :)
11:13rhickey_danlarkin: not for long, I'm sure
11:25fandarhickey_: just don't forget to put http://clojure.org/libraries link somewhere on the menu...
11:25fandastreams are hidden too - what about some group named R&D :-)
11:28scottjI have some flat sorted data (vector of strings) and I need to be able to search it quickly by prefix substring. filter isn't quite fast enough. Is there an easy way to turn it into a tree or something that can take advantage of the sort?
11:29rhickey_fanda: libraries will go on menu when more populated, streams maybe never
11:29fandarhickey_: ok
11:30rhickey_ok, next episode of the name game...
11:30danlarkin*sigh*
11:31fandarhickey_: almost thought I was bugging you too much
11:31fanda;-)
11:32rhickey_I'm working on the lazy branch, where sequences can be fully lazy. Calling seq on some-coll yields nil or an ISeq as always,
11:33rhickey_but now a non-nil seq has a first and (name to be determined, code-name "more"), where more is not iseq/nil, but something on which you can call seq
11:34Chousermaybe-more
11:34rhickey_One option is to change the meaning and type of rest to be more, e.g. (rest aseq) -> seqable
11:34rhickey_lots of breakage
11:35rhickey_the other is to define (rest aseq) === (seq (more aseq))
11:35rhickey_and have a new more fn
11:36rhickey_I'm inclined towards the latter, and am looking for a good name for "more"
11:36rhickey_should be short
11:37danlarkincdr :)
11:37rhickey_danlarkin: it's definitely not cdr, although I haven't decided how far to constrain the type
11:38rhickey_meaningful would be good too :)
11:39Chouserrest, others, further
11:39danlarkinmy brainstorm has resulted in: further, additional, extra
11:39ChouserI don't know why I said 'rest'. sorry.
11:40fandarest => more, remain, remaining, remainder, tail, leftover, residual :-)
11:40achim_p_butfirst :)
11:40Chouserafter
11:41fandaso far 'tail' looks nice to me
11:42rhickey_the existence of rest, as well as the need to change lazy code currently using rest, and the possible (likely) confusion between when to use rest and more, makes it possibly desirable to use a rest variant, like lazy-rest, restl, rest-coll etc
11:43ChouserI don't love the length, but the meaning of 'lazy-rest' is nice.
11:43danlarkinI like lazy-rest the best out of those options, even though it's kinda long
11:43jkantz lazy-rest plays well with lazy-cons
11:43danlarkinChouser: get out of my head!
11:43fanda+ lazy-rest
11:44ChouserYou'd call 'seq' on it to make it concrete, right? ...either nil or a LazyCons
11:44Chouserlrest might be ok, but I still might prefer lazy-rest.
11:45ChouserIt seems likely 'rest' would still be used a good deal more often. lazy-rest would help point out to readers you've being particularly careful about laziness when you use it.
11:45AWizzArdis the l prefix already used somewhere else for indicating lazyness?
11:46jkantz(with-out-str (map print '(1))) => "" ???
11:47Chousernot that I know of
11:47lisppaste8rhickey pasted "fully lazy filter" at http://paste.lisp.org/display/74500
11:47Chouserjkantz: 'map' is lazy
11:48Chouser,(with-out-str (dorun (map print '(1))))
11:48clojurebot"1"
11:48rhickey_the fully lazy filter above is correct in the new model, and free of the current spanning bug
11:48jkantzoh ok, I'm still adjusting to laziness
11:48Chouserjkantz: the reason you're running into it here is that 'print' has side-effects
11:49rhickey_but using lazy- where more goes is not quite right, as no additional laziness is there. more can return nil/iseq for concrete data structures
11:49Chouserjkantz: it probably doesn't belong as an argument to 'map', though without seeing your real usage, it's hard to know what else to recommend.
11:51fandacan I know which function is lazy or not? is there something like (lazy? map) => true ???
11:51noidiwhat's wrong with "more"?
11:51jkantzoh I'm doing this wrong ... trying to flatten a list of strings into one with spaces between
11:52Chouserjkantz: I'm guessing you've used other lisps before?
11:52jkantzyeah ... this is close (map concat (interleave '("1" "2") (repeat " "))) ... what's concat for strings?
11:52jkantzoh, java fns
11:52Chouserjkantz: 'str' builds a string of its arguments
11:52arbscht,(str "a" "b")
11:52clojurebot"ab"
11:53Chouser,(apply str (range 10))
11:53clojurebot"0123456789"
11:53fandajkantz: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/str_utils.clj
11:53fandasee str-join
11:54jkantzthanks fanda
11:54fandayou are welcome
11:55rhickey_noidi: nothing inherently wrong with more
11:59noidii prefere "more"... it's like saying "more, please" instead of referring directly to the rest of the elements, like "rest" and its variants imply, imo
11:59noidi-r
11:59noidi+r-e... can't even fix my typos :)
12:00rhickey_noidi: very Oliver Twist-ian interpretation, but I'll take it :)
12:01noidihehe
12:15fanda(doc nth)
12:15clojurebotReturns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences.; arglists ([coll index] [coll index not-found])
12:16brianhhi all. I'm trying to wrap my head around all this lazy stuff.
12:16fandanth says that it works on "regex Matchers" - what is it?
12:16brianhhow would more differ from force?
12:16fandais it #"a*b" etc...
12:17ayrnieu,(nth #"a*b" 1)
12:17clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Pattern
12:17fandaexactly
12:18bitbckt,(doc re-find)
12:18clojurebot"([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."
12:18bitbckt(for example)
12:18fandano no, I am questioning nth behavior or its doc
12:19leafwany recommended way to capture the output of a program that runs and finishes, in a terminal? Via (.exec (Runtime/getRuntime) "xmms2 list") , for example
12:21bitbcktfanda: re-* all operate on regex matchers; to use nth, you could use something like re-matcher to return a matcher
12:21fandaok, I get it now
12:21fandathanks
12:21bitbcktnp
12:21cooldude127so is there anyway to make the clojure repl print certain objects differently?
12:22durka42you can add methods to the print-method multimethod
12:22durka42see Chouser's recent patch for ref printing
12:22ayrnieulook in src/clj/clojure/core_print.clj
12:23cooldude127ayrnieu, durka42: thank you
12:23durka42http://clojure.googlecode.com/issues/attachment?aid=3251654005916676481&name=print-iref.patch
12:23cooldude127shit that's what i was afraid of, that's not gonna do anything for me
12:24ayrnieuwhy isn't it?
12:24cooldude127ayrnieu: i wanted a way to say, print a certain struct differently
12:25cooldude127but it looks like it dispatches on class
12:26cooldude127yup definitely dispatches on class
12:27Chousercooldude127: I have an unposted unmentioned patch I was playing with to do that.
12:27ayrnieuso write a method for all structs and then have it do its own dispatching.
12:27cooldude127yeah i just thought about that
12:28cooldude127Chouser: care to paste what you got?
12:29cooldude127i assume just do a (defmethod print-method clojure.lang.PersistentStructMap
12:30cooldude127do structs have something that indicates what type of struct they are?
12:31Chouserwithuser=> #^{:custom-print (fn [o w] (.write w (format "#<my-map %s>" (pr-str (with-meta o nil)))))} {:a 1}
12:31Chouser#<my-map {:a 1}>
12:33lisppaste8Chousear pasted "patch to support :custom-print" at http://paste.lisp.org/display/74507
12:33cooldude127Chouser: so if i have a function that creates these for me, i could just attach the metadata there and it would just work
12:33Chousercooldude127: right
12:34Chouserand because meta-data is carried through assoc/dissoc etc., you could tag your empty map with a :custom-print and then as you build and change it, it would print the way you want.
12:35cooldude127Chouser: so your patch makes that work for anything, but if i want to do this for just my purposes, i could make a defmethod on just structs, and do essentially the same thing, cuz i don't want to mess with clojure.core
12:38Chouseryeah, that ought to work. Though you're messing with the global print-method table, so I'd be careful.
12:38cooldude127i'll try it in a little bit, i need to go, we'll see how this works
12:38Chouserfor example, what happens if somebody else has their own custom defmethod for structs
12:39ChouserI'd much prefer to have :custom-print officially supported -- it composes much better for multiple libs
12:40cooldude127Chouser: yeah, i just want something right now, i'll do it your way once it's part of the language
12:40leafwhow can one pass a character literal to indexOf method of String?
12:40leafw(.indexOf "that" \h) fails
12:40ayrnieu,(class \a)
12:40clojurebotjava.lang.Character
12:40leafwyes, I know. But (char \h) also fails.
12:41Chouser,(.indexOf "that" (int \h))
12:41clojurebot1
12:41leafwint!
12:41leafwwoah
12:41Chouser.indexOf actually wants an int. :-P
12:41ayrnieuhttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
12:42leafwindeed. I always passed 'h' on the java side.
12:42ayrnieuI guess those are ints the way they are in C.
12:43ayrnieu(no, they're char.)
12:59cooldude127Chouser: i just realized something. if a struct doesn't have custom-print, i need to fallback on the default printing of the map behavior. how do i do that?
13:02durka42this might help:
13:02durka42,((methods print-method) clojure.lang.IPersistentMap)
13:02clojurebot#<core$fn__5324 clojure.core$fn__5324@eb840f>
13:03durka42i.e. you could grab the old one before you override it
13:04durka42,(((methods print-method) clojure.lang.IPersistentMap) {:a 1} *out*)
13:04clojurebot{:a 1}
13:05durka42i believe that line of code soundly defeats the purpose of a multimethod
13:07bitbcktdurka42: you did good, kid. real good.
13:10durka42hmm
13:10hiredmanclojurebot: comp is <reply>use comp for a point free, pointless style
13:10clojurebotOk.
13:10cooldude127lol
13:10durka42,(((methods print-method) java.lang.Number) {:a 1} *out*)
13:10clojurebot{:a 1}
13:10durka42i forgot about comp
13:10durka42dammit, i overrode clojure.core with a parameter name again
13:14acieroidhow can I say to clojure that I define methods later in the source code ?
13:15durka42declare
13:15durka42(doc declare)
13:15clojurebotdefs the supplied var names with no bindings, useful for making forward declarations.; arglists ([& names])
13:16Peter_anagio1join #wauk
13:16acieroidok, thanks durka42
13:17rhickeyChouser: have you got URLs for the net.n01se libraries? http://clojure.org/libraries
13:19lisppaste8knapr pasted "py" at http://paste.lisp.org/display/74512
13:26Chouserrhickey: net.n01se.clojure-classes is at http://tinyurl.com/clojure-classes
13:26rhickeyChouser: and repl-utils?
13:27durka42that's in contrib, no?
13:27Chouseroh, I posted the wrong namespace for that one
13:27Chouseri'll fix it
13:27rhickeyChouser: thanks
13:29Chouserdone
13:44Kerris7Quantity of Stuart Halloway's weekly "Programming Clojure" edit count as an indicator of Clojure volatility :)
13:45durka42what is the quantity?
13:47Kerris7I'm afraid I don't know, durka42.
13:48Kerris7It was a tongue-in-cheek (?) suggestion since I don't know about measuring volatility. :)
13:48knapranyone good with windows batch scripts? i want to have a script than i can just run so i dont have to append allt he class fiels each time
13:49ayrnieuknapr: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started
13:54cooldude127ok i got my structs printing correctly. it feels so dirty, but it works
14:01ChouserI wonder if individual defmethods should be marked with the namespace where they were defined, so that other namespaces can't replace them.
14:01Chousereh, I guess that doesn't fully clean up the situation.
14:06Kerris7clojurebot: help
14:06clojurebotmacro help is http://clojure-log.n01se.net/macro.html
14:06Kerris7clojurebot: latest
14:06clojurebotlatest is 1238
14:08cooldude127how long has that macro help thing been there?
14:16Kerris7cooldude127: no idea, I was just trying to find help for clojurebot
14:16Kerris7does anyone here use Clojure installed from MacPorts?
14:17Kerris7I also have JLine installed from MacPorts and I'm wondering if there's a convenient way to launch clj-jline
14:17durka42i remember someone trying, and running into problems
14:17durka42trying macports clojure, that is
14:18Kerris7durka42: macports clojure does work now, they've included a clj-jline.sh file which doesn't quite work
14:18Kerris7ah well, I can live without this
14:19durka42hmm, what's the error
14:19Kerris7clojurebot: paste?
14:19clojurebotlisppaste8, url
14:19lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:19lisppaste8Kerris7 pasted "bash script error" at http://paste.lisp.org/display/74514
14:21hiredmanKerris7: looks like jline isn't in your classpath
14:21durka42hmm, where does macports put clj-jline.sh?
14:21Kerris7durka42: /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/clojure/files/clj-jline.sh by deafult
14:21Kerris7default*
14:22durka42oh ok, thought it might be somewhere else too
14:22durka42maybe a more concise path
14:23Kerris7only two instances of that file exists on my computer, the other is the same file cp'd to my home with chmod +x
14:23Kerris7hiredman: you're right, I forgot that the macports installation of JLine doesn't place jline into the classpath automagically
14:27durka42if you edit the last line in clj-jline.sh to include $CLASSPATH in the -classpath argument to java, and then add jline.jar and clojure.jar to your $CLASSPATH, then it works
14:30Kerris7thanks durka42
14:30durka42probably clojure-contrib.jar for good measure
14:42knaprwhen i un my scrip runmp3.py it starts the subprocess as it should but the script is still active. can i escape from the pyhonscript and return to the command prompt once the java program is started?
14:45skillet-thiefif I type (spit "file" (str "12:34:34"))
14:45skillet-thiefand then (with-in-str (slurp "flomp") (read))
14:45cooldude127what's the write way to write docstrings, in regards to wrapping and indentation
14:45cooldude127*right
14:46skillet-thiefi get an error "Invalid number: 12:34:34"
14:47kotarakcooldude127: "foo\n<space><space>bar", at least this looks nice when printed. Having a reasonable line limit also helps when printed in the terminal
14:47kotarakcooldude127: YMMV
14:47skillet-thiefwhy is (str "12:34:34") being treated as a number and not as a string?
14:48kotarakskillet-thief: 1:1 user=> (str "12:34:34")
14:48kotarak"12:34:34"
14:48cooldude127kotarak: the problem with <space><space> is it's not always two space indentation. like i'm using test-is with (with-test), so all my defns are indented 4 spaces to start
14:48kotarakskillet-thief: looks like a string
14:48kotarakcooldude127: I had this case also. Then I still chose two space indent. It looks ugly in the code, but nice when printed.
14:49cooldude127skillet-thief: (read) sees 12:34:34, which looks like a number to start, and it tries to parse it as such
14:49cooldude127(read) is the clojure reader, so it is trying to parse clojure code
14:49skillet-thiefcooldude127: that makes sense. So what do I do to serialize correctly?
14:49cooldude127not really sure
14:49cooldude127,(pr "str")
14:49clojurebot"str"
14:50cooldude127,(print "str")
14:50clojurebotstr
14:50cooldude127that might be a clue
14:50cooldude127i have to go
14:50durka42read-string?
14:50cooldude127i'll be back
14:50skillet-thiefthanks
14:50durka42,(read-string "\"12:34:34\"")
14:50clojurebot"12:34:34"
14:50kotarak(pr-str) returns a string. Might be handy.
14:52skillet-thiefok, (read-string) would work if that was all I was reading, but "12:34:34" is part of a bigger file I am slurping.
14:52kotarakskillet-thief: try (pr-str ...) instead of (str ...) in your original example.
14:53skillet-thiefkotarak: ok, just a sec
14:53kotarak1:1 user=> (with-in-str (pr-str "12:34:34") (read))
14:53kotarak"12:34:34"
14:54skillet-thiefyeah, me too
14:55skillet-thiefand in the file, there are quotes. so I need quotes for this to work, but I might need to add them manually before serializing...
14:56skillet-thief (pr-str "12:34:34") => "\"12:34:34\""
14:56kotarakskillet-thief: there is a way to print clojure "things" in a way to read them back in.
14:57kotarakskillet-thief: doesn't work for everything though... eg. fns
14:58kotarakskillet-thief: 1:11 user=> (binding [*print-dup* true] (println (sorted-set 1 2 3) "String"))
14:58kotarak#=(clojure.lang.PersistentTreeSet/create [1 2 3]) "String"
14:59skillet-thiefkotarak: ok, that looks interesting.
14:59skillet-thiefi guess I thought it would be kind of automagic.
14:59kotarakHmm.. Maybe fns *do* work under certain conditions.
15:00kotarakskillet-thief: yes. you simply print like above and then simply (read) to get stuff back.
15:01skillet-thiefkotarak: I'm going to try to work through your suggestion with (binding...
15:01skillet-thiefI'll end up learning something anyway.
15:08lisppaste8leafw pasted "xmms2 GUI" at http://paste.lisp.org/display/74518
15:08leafwjust for fun: a trivial GUI front-end to XMMS2 (which is command-line only).
15:11Chousukenot really command line only... just multi-client :)
15:13leafwthe only tricky part of this simple GUI is knowing how to use the AbstractTableModel, or rather, knowing that JTable has such bizarre way of working.
15:13cooldude127JTable = pain
15:14Chousukeare there no java bindings for xmms2 though? :/
15:14ChousukeI guess the C bindings could be wrapped with JNA
15:16cooldude127i just discovered the clojure inspector. that freaked me out a little bit
15:18knapr(not (empty? xs)) , is there (not-empty? xs) or soemthing?
15:18cooldude127knapr: ,(not-empty [1 2 3])
15:18cooldude127,(not-empty [1 2 3])
15:18clojurebot[1 2 3]
15:19cooldude127,(not-empty [])
15:19clojurebotnil
15:19Chousukeisn't there a line-seq or something for going through lines in a stream?
15:19cooldude127knapr: yes there is :)
15:21Chousukeah, right, there is
15:21Chousuke(doc line-seq)
15:21clojurebotReturns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader.; arglists ([rdr])
15:21Chousukeknapr: see that :)
15:21cooldude127(doc not-empty)
15:21clojurebotIf coll is empty, returns nil, else coll; arglists ([coll])
15:27ChouserIt's more normal to use 'seq' instead of 'not-empty', unless you specifically need the original collection object in the not-empty case.
15:28Carkchouser : what if rich removes nil punning ?
15:28Carkor was that scraped ?
15:30Chousereven then he was going to keep 'seq' returning nil for empty things
15:30Chouserit was just a matter of 'rest' or other seq functions returning "seq or nil" vs. possibly a stream or other object.
15:30Carkah i see
15:36StartsWithKi have a small question about post "Got a Clojure library? ", if my lib contains number of sub-libraries, all for different purpose, should i list them all under one description or divide them in separate descriptions per sublib? (it is cca 10 libs under same repository)
15:36hiredmanis it possible to compare two symbols disregarding their namespaces?
15:36StartsWithKand, there will be no end date to responding? so if new libs are created it is ok to list them later?
15:37hiredmanwell of course it is possible, but, you know, without turning them into strings or keywords
15:37cooldude127why doesn't (assert ...) have some sort of message argument? it would be nice to explain these sometimes
15:38StartsWithKalso, what counts as library.. like, i have a web framework/lib, and another project with generic web componets using that lib, should i list them too?
15:43danlarkinhiredman: use (name) on them both perhaps?
15:44cooldude127i think he wanted to avoid that, but i don't think theres another way
15:45danlarkinStartsWithK: whatever you want/think is justified to be listed on clojure.org/libraries
15:45danlarkincooldude127: re: assert, I know! I wrote a "my-assert"
15:46cooldude127danlarkin: code?
15:46danlarkincooldude127: I just copy&pasted the assert macro and added another arg and had it print that out
15:47cooldude127lol that works
15:48StartsWithKdanlarkin: and listink dependencies, is it ok to just list organisation artifact and version of dependency as specified in ibiblio maven repository?
15:49hiredmandanlarkin: :(
15:49hiredmanI guess that'll do
15:50Chouser,(apply = (map name '(foo/bar baz/bar)))
15:50clojurebottrue
15:53danlarkinStartsWithK: I'm sure just the name of the dependency and a revision number if need be is fine
15:54StartsWithKdanlarkin: thanks
15:56hiredmanI think clojure.zip needs a find-replace function, that takes a zipper, a predicate, and a fn, nexts through the zipper and if the predicate is true for any next, it applies the fn
15:56cooldude127does the with-test macro in test-is work on defmethods?
15:57red_fishhow can I implement a persistent linkedblockedqueue
15:57red_fish?
15:57hiredmanlisppaste8: url?
15:57lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:58lisppaste8hiredman pasted "pointlessly pointful" at http://paste.lisp.org/display/74521
16:02durka42interesting
16:02durka42zippers used to implement infix operators
16:02lisppaste8hiredman annotated #74521 with "example usage" at http://paste.lisp.org/display/74521#1
16:04Chousukelisppaste8: generalise that for arbitrary operators.
16:04Chousukeeh
16:04Chousukehiredman: !
16:04hiredmanChousuke: !
16:05hiredmanso I copied the MIT license from somewhere and just sort of stuck my name in the copyright bit, but you are have done alot with clojurebot so I was wondering if you want to be included in LICENSE?
16:05ChousukeI'm fine either way :)
16:06hiredmanyeah
16:07hiredmanwell, fix it then :P
16:07lisppaste8StartsWithK pasted "Cell system; cells can now depend on normal object properties, like swing widgets" at http://paste.lisp.org/display/74522
16:09durka42hey, that could be useful
16:09durka42so cells are like lazy variables?
16:10StartsWithKdurka42: yes, they are updated only when there parent are updated
16:10Chousukeneat
16:10StartsWithKfor now parent can be anything you can attach watcher with add-watcher and in this version any object property for who you can provide some sort od listenere
16:10Chousukelooks like something that should go into contrib :)
16:11Chousukecertainly somewhere other than a lisppaste :P
16:11StartsWithKChousuke: http://bitbucket.org/ksojat/neman/
16:11hiredmanand lisppaste has not root in which to look for the CPL.txt mentioned in the header
16:13StartsWithKso for now its missing object-property -> cell and object-property -> object-property connection types
16:32AWizzArdIs it just me or is http://clojure.org/repl_and_main blank for others too? rhickey, should there be something on that page?
16:32lisppaste8knapr pasted "unbound variable" at http://paste.lisp.org/display/74526
16:32knaprsomeone can take a look at that?
16:33Kerris7AWizzArd: looks blank to me too
16:34danlarkinAWizzArd: there was a post on the mailing list about that very page
16:35AWizzArdic
16:35danlarkinAWizzArd: Stephen C. Gilardi says he'll have something there in a few days
16:36durka42knapr: display-song looks internal the layout function
16:36durka42so you can't get at it from outside
16:37scottjHow do you define an alias for a function in a way that the function parameters will still display in slime?
16:37knaprdurka42: ah ok, ofc
16:37knaprbut then how do I do? then I have to redeisgn the whole thing...
16:38StartsWithKknapr: just (def display-song (JLabel.)) outside your layout function (for quick fix)
16:39knapryeah i was thinking that but its ugly no?
16:42StartsWithKknapr: you can change play-next so it takes that label as one of the arguments
16:44durka42can gen'ed classes have members?
16:45StartsWithKdurka42: you can declare :state
16:45AWizzArdscottj: you would have to write a macro for aliasing, which expends into a defn
16:46AWizzArdexpands
16:47knaprStartsWithK: thanks ofc good tip
16:47StartsWithKdurka42: but i think it will be declared public, so if you declare in gen-class :state state, you can acces it from outside with (.state your-object)
16:52hiredmanhow can I find the arity of a fn?
16:52hiredmanis there some function? I looked a little through IFn.java and friends
16:52AWizzArdhiredman: (:arglists (meta #'+))
16:53hiredmanAWizzArd: that is getting it from a var
16:53hiredmanwhat about anonymous functions?
16:53hiredman(fn [a b] [a b])
16:54hiredmanif that was handed to you as x, how do you get an arity count for x
16:55ChouserI don't think you can
16:55AWizzArdwith some tricks
16:55shoover``Does anyone have examples of clojure apps actually using clojure.contrib.sql or resultset-seq?
16:55AWizzArdyou could try to call it inside a try/catch block
16:55AWizzArdand if you land in catch you have a chance to find out more about it :-)
16:56hiredmanChouser: :(
16:56Chouserthe official interface of a fn is that it accepts any number of args
16:56Chouserit's just that calling some of them throws an exception
16:57hiredmaninternally fn throws and Arity exception but that gets caught and a more generic IllegalArgumentException is thrown
16:57hiredmanugh, putting try catch around everything is lame
16:58Chouserand since fn's don't take metadata (yet), there's nowhere else to put that kind of info.
16:58hiredmanmaybe I'll wait on auto-partial till fn's can take metadata then
16:59Chouseryou can require users to pass in a Var
17:29ChouserI just don't understand what people have against (some #{3} '(2 3 4))
17:30hiredman*shrug*
17:31hiredmanhmm
17:32cooldude127wait so sets are functions that indicate if something is in the set?
17:32Chouseryep
17:33cooldude127i love the way clojure makes functions out of EVERYTHING
17:33Chouserexcept regular expressions
17:34cooldude127:(
17:34Hunthat'd be perlish
17:34Hun(:
17:35ChouserI thought I saw somewhere that a patch for that would be accepted, but it's hard to figure out how to make a final Java class act like a Clojure function.
17:37cooldude127can multimethods have multiple arities?
17:37Chouseryes
17:37kotarakcooldude127: yep
17:37cooldude127how does that work out in practice?
17:37Chouserfrequently the dispatch function ignores all but the first arg
17:38ChouserHolloway's book has a fantastic example, though.
17:38kotarak(defmutli foo (fn [x & _] (class x)) (defmethod foo String [x a] ...) (defmethod foo Integer [x a b c & bla] ...)
17:39cooldude127cuz i'm writing a library for linear algebra, so i'm doing stuff with adding matrices and numbers and stuff, and so it'd be cool to have the addition and multiplication functions and stuff accept many arguments
17:39cooldude127but maybe this is easier to do with multimethods for just the two-arg case and then just use reduce
17:42hiredman,((comp (partial apply some) list) #{3} '(1 2 3))
17:42clojurebot3
17:42hiredmanhmmm
17:42hiredmanno improvement at all
17:45cadsdoes anyone here use the enclojure addon for netbeans?
17:51hiredman,(((comp (partial partial (comp (partial apply some) list)) (comp set list)) 3) '(1 2 3))
17:51clojurebot3
17:51hiredman,(((comp (partial partial (comp (partial apply some) list)) (comp set list)) 10) '(1 2 3))
17:51clojurebotnil
17:51hiredmanpartial partial is a bad sign
17:51cooldude127oh
17:51cooldude127my
17:51cooldude127god
17:51cooldude127hiredman: what are you trying to achieve here?
17:52hiredmanpoint free contains?
17:52cooldude127whyyyyy
17:52cooldude127lol
17:52Chouser"point free"?
17:52hiredmanpoint free seems so hip and happening
17:52cooldude127hiredman: it is in haskell, but nobody likes it in lisp
17:53cooldude127only in the simplest of cases
17:53hiredmanhttp://www.haskell.org/haskellwiki/Pointfree
17:53hiredmanChouser: I rewrote ther version of your inits that I have in clojurebot in point free style
17:54hiredmanI am pretty sure it still works too
17:54hiredmantons of partial application
17:58hiredmanI guess it isn't completely pointless
17:58ayrnieuChouser: I rewrote ther version of your finals that I have in clojurebot in befunge style. I am pretty sure it still works too. Tons of n-dimensional character-based computing.
17:59hiredmanayrnieu: I fixed the macroexpand exploding or thing
17:59ayrnieu(actually I only used 2 dimensions)
17:59hiredman,(macroexpand '(or 1 1))
17:59clojurebot(let* [or__3164__auto__ 1] (if or__3164__auto__ or__3164__auto__ (clojure.core/or 1)))
17:59ayrnieuawesome!
18:00hiredmanturns out it was exploding on the (or 1 1) bit not the macroexpand
18:02danlarkinChouser: the contains? debate lives on!!!!
18:04Chouserapparently
18:07kotarakSomeone (don't remember who) said, that after sufficient time each and every discussion will turn around the definition of words..... Instead of simply writing cool code in clojure, they prefer discussion names...
18:08ayrnieunames are hard.
18:08ChouserAh, thank you Mr. Engelberg.
18:08danlarkinpah! "in?" is still shorter :)
18:13hiredmanis there a function that given f and a evaluates to (f a) ?
18:14Chouserwhat's a?
18:14hiredmananything
18:14Chouseroh, "and a" sorry, I didn't see that.
18:14Chouser(apply f a nil) ;-)
18:15ayrnieuno, that's too straightforward.
18:15Chouser(.invoke f a)
18:21Chousukewhy the nil :/
18:21Chouserapply is all about a seq for its final arg.
18:21Chousukeah, right.
18:22rhickeyuser=> (.contains [1 2 3] 2)
18:22rhickeytrue
18:22rhickeyuser=> (.contains '(1 2 3) 2)
18:22rhickeytrue
18:22rhickeywhat contains debate? :)
18:22ayrnieu(.contains nil 2)
18:22ayrnieu,(.contains nil 2)
18:22clojurebotjava.lang.NullPointerException
18:27ayrnieuis there something like all-ns for the java side, to get java.lang , org.jdom, etc.?
18:27AWizzArdwhat I find a bit strange is:
18:27AWizzArd,(.pow 2M (.pow 2M 256))
18:27clojurebot1M
18:27AWizzArdinstead of 2M one could also use (BigInteger. "2")
18:28rhickeyayrnieu: no, java packages are not enumerable through the API
18:28rhickeyneither the set of packages nor the members of a package
18:29keithbHi, all...How can I create a multiline comment for a function with defn?
18:29ayrnieujust put multiple newlines in your string.
18:29AWizzArdshouldn't .pow throw some exception if the resulting numbers would be too big to fit into ram, instead of just returning 1?
18:30AWizzArdkeithb: do you want to make a comment or documentation string?
18:30ozy`keithb: strings can span multiple lines
18:30AWizzArdif it is just a comment and you don't want to type semicolons over and over again just do (comment anything can be here)
18:31hiredmanAWizzArd: decent editors have a facility for that sort of thing
18:31keithbAWizzArd, sorry, I meant documentation string. I want the doc string to be on several lines so that the reader doesn't have to horizontally scroll to read the whole thing.
18:32Chousukekeithb: just add newlines :)
18:34keithbHere's a minimal example of it not working...what am I doing wrong?: http://pastie.org/374702
18:34ayrnieuyou have multiple strings.
18:35keithbHow do I create a single string spanning multiple lines?
18:35ayrnieu"this is
18:35ayrnieuone long
18:35ayrnieustring"
18:35hiredmankeithb: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#2706
18:35hiredman^- example
18:35dreishOr "foo\nbar"
18:36keithbayrnieu, That's what I needed. I had no idea it would be that easy. ;)
18:36keithbThanks.
18:36ChousukeI don't like the fact that multiline docstrings have to be manually aligned though :(
18:37hiredmanrhickey: so, any plans to expose information on fn arity?
18:37ayrnieuyou could put (clojure.contrib.fun-util/realign-docstrings) at the end of your module.
18:39ayrnieuhm, and pass it the namespace.
18:45Chousukeoh, such a thing exists now?
18:54knaprwhat does (. obj ...) mean?
18:54knapris (.method obj) == (. obj method) ?
18:59hiredmanknapr: (.method obj) is more like (. obj (method)) if I recall
18:59hiredman(.method obj) is the prefered style
18:59hiredman,(macroexpand '(.method obj))
18:59clojurebot(. obj method)
19:00hiredmanor not
19:00hiredman,(macroexpand '(.method obj foo))
19:00clojurebot(. obj method foo)
19:00hiredmanhmmm
19:00hiredmanI have been forgeting how . syntax works
19:00hiredmanbecause of using hte new style
19:00burkelibbeyIf anyone's interested, here's a list of dictionary words that work with the clojure / compojure -style s->j munging: http://gist.github.com/54847
19:01hiredmanI call Xiphojura
19:02burkelibbeyI think expojure has a nice ring to it, but I don't want to write anything that it would make sense for :P
19:03hiredmanclojurebot: Xiphojura is <reply>2009:Jan:29:16:03:17 <hiredman> I call Xiphojura
19:03clojurebot'Sea, mhuise.
19:03hiredmanclojurebot: jure words is <reply>http://gist.github.com/54847
19:03clojurebotAck. Ack.
19:05Chousukeconjure is cool
19:06clojurebotsvn rev 1239; [lazy] added more to ISeq
19:06hiredmanChousuke: a library that auto magically turns ((fn [a b] a) a) into (partial (fn [a b] a) a)
19:07knaprwhen I close my mp3player it stills keeps playing(it uses other threads), how do I tell it to kill all threads when the app is closed(by pressing X in the upper right)?
19:07hiredmanknapr: there is some thing you set on the JFrame that causes the jvm to exit
19:07Chousukehiredman: that's really difficult in a dynamic language :P
19:07AWizzArdhiredman: we had this discussion some time ago
19:08ayrnieua dynamic language can do it, actually, but a dynamic language programmer cannot.
19:08Chousukein haskell autocurrying works nicely because every function takes just a single argument
19:08hiredmansetDefaultCloseOperation
19:08ayrnieucannot reason about programs that make use of this haskell cutesiness.
19:08hiredmanChousuke: which is why it would be a real trick if you did it, hence "conjure"
19:09burkelibbeyIdea: Somebody should make a nicer way to package up clojure code without mucking around with ant, and call it "enclojure".
19:09ChousukeI was hoping for something more useful
19:09hiredmanenclojure is taken isn't it?
19:09burkelibbeymight be
19:09hiredmanthe netbeans plugin
19:09burkelibbeyoh right
19:10Chousukewasn't there some clojure-based build system mentioned on the groups once
19:10ayrnieuegrep 'user$' /usr/share/dict/words # ooh, trejure
19:11ayrnieu(treajure. I can think of a use for displeajure.)
19:11ayrnieuChousuke - Lancet. That's the one that's in the pragprog book.
19:11burkelibbeyah, also good. I didn't think there would be anything good with [^o]sure$
19:12ayrnieu[^s]sure is what you really want
19:12hiredmanChousuke: lancet?
19:13knaprwhat is standard to use for storing userinfo in a one-user-app. ie not a webapp but a gui that saves some personal stuff like basedirectory etc. .txt files, database, serialzing object?
19:13knaprall this reajure, conjure, compojure. god it is so ugly
19:13ayrnieuknapr - it always is, in every language that people do it in, but they still do it. Names are hard.
19:13danlarkinno more -jure program names Puhleeeease
19:14burkelibbeyUpdated
19:14burkelibbeyclojurebot: jure words
19:14clojurebothttp://gist.github.com/54847
19:14knaprdoes the name have to connect to clojure?
19:14knaprwell in python ot sounds good usually but in clojure...
19:16Chousukeclojurebot: naming is <reply>The Clojury says to stop making puns.
19:16clojurebotYou don't have to tell me twice.
19:19knaprclojurebot: namings is?
19:19knaprclojurebot: naming is?
19:19knaprclojurebot: naming?
19:19clojurebotexcusez-moi
19:19clojurebotThe Clojury says to stop making puns.
19:19clojurebotThe Clojury says to stop making puns.
19:19knaprthe Clojury == the clojure community?
19:20hiredmanChousuke: two puns don't make a right
19:20keithbDoes a function defined with defn implement Runnable?
19:20Chousukeyes
19:20knaprso if i want to do a lot when closing awindow how do i do? because i cant pass a function in stupid-ass java...
19:21knaprclojurebot: OO?
19:21clojurebotOO is to programming what astrology is to astronomy
19:21ChousukeI think IFn implements both Runnable and Callable :/
19:22keithbknapr, if you're using Swing, check out the WindowListener/WindowAdapter classes. You can catch the window closing event. But there are gotchas...if you're interested I'll try to find a resource that explains it more completely.
19:22hiredmanknapr: look at the java docs on setDefaultCloseOperation for JFrame
19:22keithbdefinitely, if setDefaultCloseOperation does what you need, it's much simpler than catching the window event.
19:23hiredmanhuh
19:23hiredmanCallable
19:24Chousukeor whatever the interface was called :p
19:24hiredmanyeah that is it
19:24ayrnieu,(ancestors (class (fn [] nil)))
19:24clojurebot#{java.lang.Object clojure.lang.IObj clojure.lang.AFn java.lang.Runnable clojure.lang.IFn clojure.lang.IMeta clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.Obj java.io.Serializable clojure.lang.Fn java.util.Comparator}
19:25hiredmanI've just never come across it before
19:26keithbThanks, all. hiredman, my prev msg "definitely..." was directeod to knapr, sorry for any confusion.
19:26hiredmankeithb: �I wasn't confused?
19:26keithboh, I wasn't sure what your huh was about...
19:27hiredmanhuh, Callable
19:27keithbah, I see, never mind... ;)
19:27hiredmanI am very liberal with the linebreaks on irc
19:35keithbI want to write a function that loops over a range, and for each iteration, adds an item to a list, and then return the list at the end of the function. Is "for" the best approach for this? I'm finding that when I start this function in a thread, the loop doesn't seem to be run.
19:35hiredmankeithb: for is lazy
19:36Chouserwhat do you intend to do with the list?
19:37hiredmanthere is also dotimes and doseq
19:37hiredmanare
19:37Chouserusually such a list would be consumed by something, in which case 'for' should work fine.
19:37knaprreduce
19:38keithbI was hoping to return the list, but come to think of it, that's not really possible from a separate thread, since Thread.run() doesn't return anything (is defined with a return value of void).
19:39knapr(let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))
19:39knapr> (let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))
19:40knaprclojurebot: at home?
19:40clojurebotNo entiendo
19:40knapr> (let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))
19:40keithbknapr, I'm familiar with reduce, but that's not really what I want; the purpose is to do a simple illustration of Clojure concurrency, so I want to increment a shared counter and log its value, time, and thread info.
19:40knaprok
19:40keithbI think what I really need to do is increment the counter, and add a log entry to a shared list in a given transaction.
20:00knaprso i need to call a clojure-function when i close the window
20:00knapr(.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE)
20:00knaprcan i do that there instead of JFrame/DIS...
20:02hiredmanknapr: no
20:02ayrnieu,(let [count (ref 0)] (doseq (take 100 (repeatedly #(commute count inc)))) @count)
20:02clojurebotjava.lang.IllegalArgumentException: doseq requires a vector for its binding
20:02hiredmanayrnieu: doall
20:03ayrnieuno, not that one.
20:03ayrnieuthe one for accessing refs.
20:03hiredmandorun?
20:03hiredmandosync?
20:03ayrnieu,(let [count (ref 0)] (dosync (take 100 (repeatedly #(commute count inc)))) @count)
20:03clojurebot0
20:03hiredmanerm
20:03ayrnieuI guess I do need doall :-)
20:03ayrnieu,(let [count (ref 0)] (dosync (doall (take 100 (repeatedly #(commute count inc))))) @count)
20:03clojurebot100
20:03hiredmanmost likely you would want the dosync inside around the commute
20:04hiredmanor else it all happens in one transaction
20:04hiredmanwhich is kind of, meh
20:04ayrnieuright.
20:07ayrnieuer, hm.
20:07ayrnieu,(let [count (ref 0)] (dosync (doall (take 100 (repeatedly #(commute count inc))))))
20:07clojurebot(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100)
20:07ayrnieuI don't want that, though.
20:08ayrnieu,(let [count (ref 0)] (dosync (dorun (take 100 (repeatedly #(commute count inc))))))
20:08clojurebotnil
20:15ayrnieuhttp://gist.github.com/54871 doesn't really demonstrate concurrency.
20:16knaprhow can I generate a Java-method?
20:16ayrnieuproxy
20:16clojurebotsvn rev 1240; [lazy] added more, made filter and map use lazy-seq, made Delay.Seq implement IPersistentCollection and List
20:18ayrnieuit's just refs and commute - with threads. In Erlang I'd make every moving part a process (or few) and then think about how they interrelate. Somebody quoted rich as planning to add something more Erlang-like. Until then, this is just parallel programming; a performance hack and not a way to design programs.
20:24rhickeyfully-lazy approach using new more + compatible rest seems promising, moved over map and filter and Clojure still runs!
20:28lisppaste8knapr pasted "untitled" at http://paste.lisp.org/display/74548
20:28lisppaste8knapr annotated #74548 with "untitled" at http://paste.lisp.org/display/74548#1
20:29ayrnieudo you mean .addActionListener ?
20:30baajhttp://paste.lisp.org/display/74548#1
20:30baajwhy cant i do ^^ ?
20:31cooldude127baaj: addActionListener is not a function
20:32ayrnieu,(let [x 1] `(1 ~x))
20:32clojurebot(1 1)
20:33baajthen what is it?
20:33baajit is a method
20:33baajand i do doto
20:33ayrnieudo you mean .addActionListener ?
20:33cooldude127baaj: if you want to call a method, you need to prefix it with a .
20:33baajah wait
20:34baajwelll illegalargument exception instead
20:59ayrnieu,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) @n)
20:59clojurebotEval-in-box threw an exception:EOF while reading
21:00ayrnieu,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) @n))
21:00clojurebot0
21:00ayrnieu,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (commute n identity))
21:00clojurebotEval-in-box threw an exception:EOF while reading
21:00ayrnieu,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (commute n identity)))
21:00clojurebot0
21:01ayrnieu,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (await-for 2000) (commute n identity)))
21:01clojurebotjava.lang.IllegalStateException: await-for in transaction
21:02ayrnieu,(let [n (ref 0) adder (agent nil)] (send adder #(dosync (commute n inc) %)) (await-for 2000) (dosync (commute n identity)))
21:02clojurebot1
21:02ayrnieuI hope that what's going is still clear through all of the stupid errors.
21:13hiredmanayrnieu: it sure isn't
21:20gnuvince_Have we got a pretty printer yet?
21:21cooldude127gnuvince_: i wish
21:21knaprisnt is possible to do everything from clojure that you can in Java?
21:21gnuvince_cooldude127: thank you
21:22cooldude127gnuvince_: why?
21:22ayrnieuknapr - what are you trying to do that you think you can't do?
21:22cooldude127knapr: in theory, i'm not sure if we get everything
21:23knaprwhen I press X on my swing GUI I want to close a bunch of threads upon exiting but it seems really hard to do this since I must implement an WindowListener class and then somehow pass the running threads to that,
21:23knaprI mean why cant the jvm just close everything?
21:23gnuvince_cooldude127: I'm writing a blog post, and I have a semi-large data structure spilled out by a function. I want to format it properly, but I'm a lazy dog
21:24cooldude127gnuvince_: what kind of data structure?
21:24gnuvince_map with nested vectors and maps
21:24cooldude127gnuvince_: what editor you use?
21:25hiredmanayrnieu: (await adder)
21:25gnuvince_cooldude127: for Clojure, Emacs.
21:25cooldude127gnuvince_: can't emacs fix that up?
21:25hiredman,(let [n (ref 0) adder (agent nil)] (send-off adder #(dosync (commute n inc) % 1)) (await adder) [@n @adder])
21:25clojurebot[1 1]
21:26gnuvince_cooldude127: I will still need to manually break the lines, won't I?
21:26cooldude127gnuvince_: oh yeah probably
21:28gnuvince_hmmm
21:28gnuvince_that took all but 30 secondes
21:28gnuvince_I must *really* be lazy
21:28cooldude127lol
21:32ayrnieuOK, I was just confused about a few things earlier, but surely this is weird:
21:32ayrnieu,(let [n (ref 0) adder (agent nil)] (send adder #(do % (commute n inc))) (await) [(agent-errors adder) @n]))
21:32clojurebot[nil 0]
21:32hiredmanayrnieu: also commute and alter return the "in-transaction-value of ref"
21:33hiredman*shrug*
23:27cooldude127you know what? fuck matlab, i'm having way more fun with linear algebra in clojure
23:27cooldude127maybe it's the joy of writing your own function for a determinant
23:29cooldude127clojurebot: seen technomancy?
23:29clojurebottechnomancy was last seen quiting IRC, 1624 minutes ago
23:29cooldude127maybe clojurebot could get a more useful time formatter
23:35cooldude127what's a good abbreviation for transformation?
23:38LordOfTheNoobsxform?
23:39cooldude127LordOfTheNoobs: i like that
23:48cooldude127lisppaste8: url?
23:48lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:49lisppaste8cooldude127 pasted "bad macro" at http://paste.lisp.org/display/74556
23:50cooldude127anybody want to lend some macro help
23:50cooldude127when i evaluate this, i get an unsupportedoperationexception
23:50ayrnieuwhat do you want that to expand to?
23:51cooldude127ayrnieu: i think i want it to expand into exactly what it does
23:51ayrnieuoh, then it works OK.
23:51cooldude127i can't find anything wrong with the expansion
23:51cooldude127ayrnieu: bad things happen when i enter that last expression in the repl
23:52cooldude127and clojure's error handling is really unfortunate sometimes
23:54cooldude127ok the problem is definitely the with-meta part
23:54cooldude127the function itself is just fine
23:55cooldude127let me guess, functions themselves can't have metadata?
23:56ayrnieu15:55 < Chouser> and since fn's don't take metadata (yet), there's nowhere else to put that kind of info.
23:56cooldude127AHHHH
23:56cooldude127man that is not cool
23:57cooldude127i think i have another way to make it work tho
23:58cooldude127ok, a big fat hack: my function will give the definition when called with no args