#clojure logs

2009-01-24

00:00technomancyis binding supposed to be non-recursive even though let is recursive?
00:01technomancyfor instance, it seems odd that this works (let [number 1 number2 (* number 2)] number2) while (declare n1 n2) (binding [number 1 number2 (* number 2)] number2) this does not
00:22Chouseryes, let clauses happen in order, binding clauses happen simultaneously
00:22eeehello
00:22Chouser'let's the exception I think -- besides binding, loop and fn calls are also simultaneous.
00:22Chousereee: hi
00:24eeeany interesting topics or debates?
00:24rzezeskiChouser, you by any chance see my last msg? I sent it a few hours ago, no one responded.
00:25Chouseryes, I see it.
00:25eeeI'm lobbying to use s;ashes in namespace including the slash for the symbols. . . . no dots
00:25eeebut that's from a newby
00:26eeei think it would have been easier to grok
00:26Chouserrzezeski: seems sensible. You could raise it on the google group.
00:26eeedots equal java
00:26Chousereee: foo/bar/baz instead of foo.bar/baz ?
00:26eeeyup
00:27eeei brought it up there.
00:27eeepeople taught me namespaces tonight
00:27eeei finally asked about it
00:27eeei just didn't get it
00:27eeeat all
00:27Chouserwhen compiled, the file foo/bar/baz.clj becomes the class foo.bar.baz, which means its package and namespace are both foo.bar
00:28Chouserah, I haven't read that thread yet. still watching the message count tick upwards. :-)
00:29rzezeskiChouser, thx for the input, will do
00:29eeeso if I need some clojure stuff in a java app, I can use foo.bar
00:29eeewoah
00:29eeei wonder
00:29Chouserrzezeski: I really don't know which way Rich will go on that.
00:29eeeif you compile clojure
00:30eeethen can you use it from clojure as if it were any old java?
00:30Chouseryep
00:30eeethat would be perverse
00:30eeejust wondering
00:30eeeweird
00:30Chouseryes, Clojure makes no attempt to pretend it's anything other than Java
00:30Chouserwell, JVM code anyway
00:31eeeisi this language designed to make ones head exlode with possibilities :)
00:31Chouser:-)
00:31rzezeskiChouser, yea it's not that it really bothers me. However, if ppl come to rely on the fact that they can merge lists, sets, etc. then it could be harmful if in the future the impl changes and either merge doesn't work on those structures anymore, or produces different results, etc.
00:32technomancyChouser: so let is the special case then; hmmm... I was pretty surprised just because I expected binding to work like let.
00:32eeelike that there are two ways to do Java stuff is really confusing
00:32Chousertechnomancy: you're not the first.
00:32Chouserrzezeski: yes, that's good point.
00:33Chousereee: two ways?
00:33Chousereee: as in .java code or .clj code?
00:33eeeno
00:33eeei mean like
00:34eeehow do you access a static Java thingy from clojure?
00:34Chouser(java.lang.Integer/parseInt "12")
00:35rzezeskibtw, the google group has gone nuts the last few days, I read all the msgs and it's killing me trying to keep up. It's a good thing, but I feel like all I do is read
00:35technomancyChouser: do you know the reason behind it?
00:36Chouserrzezeski: it keeps getting worse. I imagine we'll have to split things up somehow to help the right people to be able to ignore the right stuff, but I really am not sure how.
00:36eeethat's only one way, Ch. Then isn't there (.parseInt "12")
00:36Chouserrzezeski: it's not clear to me that a "-dev" vs. "-user" split would be a good idea.
00:36eee(.parseInt Integer "12")
00:36eeei dunno
00:37eeei don't have any intuition for the pattern
00:37Chousereee: nope, not anymore. That format is for instance methods: (.split "1,2,3" ",")
00:37rzezeskiwell, I think splitting it up just yet might be a little premature, it could just be a spike. However, if it keeps up I agree that some type of partition should occur. Maybe a beginners list (haskell has one) and a normal list?
00:38eeeI know there are several ways to do, say, (new JFrame("hello world")).setVisible(true);
00:38Chouserrzezeski: but who would read the beginner's list? just beginners? :-)
00:38Chousereee: sure, but that's true in any language, even in Java.
00:38WizardofWestmarcyeah was gonna say, that's not going to save the people who want to help the newbies
00:38rzezeskibeginners, and anyone else who wants to lend a guiding hand. I feel like there are a lot of people eager to learn and teach others in the group.
00:39technomancy"I was having this problem..." / "Oh, I had that problem too. I wonder how to fix it."
00:39technomancyclearly the solution is to get people to use IRC more instead of email. =)
00:39Chousertechnomancy: Rich has said that if 'let' were simultaneous (as it is in some other lisps) people would just write a macro to do it in order anyway (often called let* I believe), so we might as well have it this way built in.
00:40rzezeskiOr maybe a "user" vs. "dev" list. The former being oriented towards end-user usage of Clojure, the later being oriented towards the guys who make Clojure work
00:40WizardofWestmarcchouser: yeah let* is what clojure's let acts like
00:40technomancyChouser: totally makes sense for let; it's the let/binding difference that I wonder about.
00:40Chousertechnomancy: and I think he's said the 'binding' can be more efficient by doing all its forms at once. I guess you can nest them if you want. :-)
00:41WizardofWestmarcwhat's odd about that idea is wasn't the whole point of making let equiv to let* to avoid such confusions? or am I misremembering?
00:41technomancyChouser: I thought it might be efficiency. =) yeah, I'm gonna have to nest this sucker and be sure to comment it so I remember why it looks a bit funny.
00:42ChouserWizardofWestmarc: possibly, but I think 'let' can do that with no performance hit, while perhaps 'binding' cannot.
00:42technomancyseems like it'd be easier to make binding efficient sequentially than let, but my experience with implementing lisp has been pretty slim
00:42eeei like to pretend like a language designer because it is the only way I can understand clojure. I got, "that's dumb. it should be like this." I expect one of two answers: (1) "no because", or (2) wow, good point, or (3) (bonus) " get used to it" I suspect mostly type 1 and 3 for now since I'm new to functional languages
00:42WizardofWestmarcI don't see why binding vs let would have any additional efficiency
00:43technomancyeee: you get 3 a lot more with CL than clojure. =)
00:43WizardofWestmarcand if you're ever interested in Lisp implementation, I've heard great things about Lisp in Small Pieces, but haven't bought a copy yet
00:43technomancyWizardofWestmarc: probably some crazy JVM thing. =)
00:44technomancyWizardofWestmarc: I built a scheme from reading the Little Schemer; lots of fun but not very useful.
00:44WizardofWestmarctechnomancy: good point I know very little about the jvm, it's JIT, etc
00:44WizardofWestmarcLisp in small pieces is meant to build things more robust then a basic scheme compiler
00:44technomancyI guess in Small Pieces explains how to actually make it perform decently etc? but probably doesn't address VMs.
00:44WizardofWestmarcI dunno, the only point of the book is compiler stuff for a lisp
00:44eeeyeah, 3 in CL since it's already ansi
00:45eeebut hopefully a lot of (1), too
00:45eeei also hate debugging these languages so far
00:45rzezeskiLisp In Small Pieces is on my ever growing book queue. I can't wait to read it in 3 years :)
00:45Carkhow do i do such thing with clojure : synchronized(dialog.getTreeLock()) { ... }
00:45WizardofWestmarcrzezeski: haha I understand that one
00:46WizardofWestmarcin just books I own it's insane
00:46WizardofWestmarcPAIP and AI:aMP I haven't finished yet
00:46WizardofWestmarcthough I own both
00:46Chouser(doc locking)
00:46clojurebotExecutes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances.; arglists ([x & body])
00:46WizardofWestmarcalso want to actually do SICP at some point, and may try it in clojure as a double learning excercise.
00:47Carkthanks chouser
00:47rzezeskiYea I have and addiction with buying CS books. So much so that I have an amazon visa card. I have about 20 books I haven't even cracked yet, it's sick
00:47eeedoes the clojurebot have a repl?
00:47rzezeskiI don't know if I'd buy SICP, I think the video lectures are enough
00:48WizardofWestmarcI need to get the amazon visa
00:48WizardofWestmarcand why buy SICP? I have the pdf
00:48Chouser,(print "I have a REPL")
00:48clojurebotI have a REPL
00:48eee(clojurebot eval '(println "hello world")) .. too bad I don't remember any clojure already
00:48WizardofWestmarcI think I spent 1k in amazon one year, at least 60% of which were in programming books
00:48rzezeskithat's true it is free, but it's so F'ing long, I really just prefer to watch the videos :)
00:48WizardofWestmarctrue
00:48WizardofWestmarcnote I have the videos downloaded too
00:48eeenice!
00:49rzezeskiHave you gone through the Art of Computer Programming yet?
00:49WizardofWestmarcoh god no
00:49eee,(print "let's see")
00:49rzezeskiYea I own it, keep delaying
00:49clojurebotlet's see
00:49WizardofWestmarcthe entire series to date?
00:50eeethat is amazing
00:50rzezeskino I have volume 1-3
00:50rzezeskiI think 4 recently came out
00:50WizardofWestmarcI also think so but not positive
00:50hiredmanclojurebot: clojurebot is amazing
00:50clojurebotRoger.
00:50hiredmandamn, I just clobbered something
00:51rzezeskiI got two for christmas, The Little Schemer and Purely Functional Data Structures, but first I have to finish Practical Common Lisp
00:51WizardofWestmarcPFDC? The one that's all in ML?
00:51technomancyhiredman: don't you think he should warn you before you clobber things?
00:51technomancyso you'd have to say "forget thing" first?
00:52rzezeskiit has impls in ML and Haskell
00:52technomancyrzezeski: Little Schemer is awesome. very enjoyable.
00:52hiredmantechnomancy: yeah, that is a good idea, I guess
00:52rzezeskiI know Haskell (to an extent) but not ML
00:52WizardofWestmarcnod
00:52technomancyhiredman: just stealing ideas from fsbot
00:52WizardofWestmarcI dno't really know either. After Clojure I'll probably look at Haskell next
00:52WizardofWestmarc*don't
00:52rzezeskiI came from Haskell to Clojure
00:53hiredmantechnomancy: infobot has the same behaviour
00:53rzezeskiand I find Clojure to be pretty damn enjoyable
00:53technomancyocaml has type inference, right?
00:53WizardofWestmarcI've spent some time in CL (SBCL mostly, on windows that's a giant pain) and scheme (PLT/mz)
00:53WizardofWestmarcyeah
00:53WizardofWestmarcI think both are worth knowing, for different reasons
00:53WizardofWestmarcthe type system in haskell looks appealing to me, at least as something of a mental exercise.
00:54WizardofWestmarcthough I'm sure Monads will break my brain a few times ;-)
00:54rzezeskiYea, I still plan to go through Real World Haskell
00:54rzezeskiYes, Monads are a bitch, and IO was a stumbling block for me in Haskell.
00:55WizardofWestmarcI think that's most people's stumbling block, from what I've heard
00:56technomancyI'm getting a "cannot recur" from catch/finally when I have a doseq in a finally block. is this illegal?
00:56WizardofWestmarcbelieve it doesn't work currently.
00:57technomancyWizardofWestmarc: bug?
00:57WizardofWestmarcdon't recall, I just remember hearing about it before
00:57eeemy shareware irc expired
00:57Chouseryeah, 'recur' is currently disallowed in a couple places where it might theoretically be okay.
00:57WizardofWestmarceee: windows user ?
00:58technomancyChouser: and doseq uses recur?
00:58eeemibbit is way better anyway. free and webbased
00:58rzezeskiHow's the joke go? You're consider a Haskell newbie once you've written a Monad tutorial? It's kind of like a rights-of-passage, which is cool in a way
00:58Chousertechnomancy: oh. heh, yeah, it does.
00:58WizardofWestmarcmibbit annoys me because it chops my name short :(
00:58technomancymakes sense I guess
00:58WizardofWestmarchence during the day I don't have the h :P
00:58eeenot on my screen
00:58WizardofWestmarcI mean when I log in via it
00:58WizardofWestmarcI'm at home on Trillian atm
00:58eeewow, I can actually see everyone's comments separately
00:59eeeglad I didn't buy that piece of junk
00:59Carkclojurebot: paste?
00:59clojurebotpaste is http://paste.lisp.org/new/clojure
00:59hiredman~paste is http://paste.lisp.org/new/clojure if it's working
00:59clojurebotOk.
00:59technomancycracks me up to think people think they can make money with an IRC client
01:00eeeid that implemented in clojure?
01:00hiredmantechnomancy: like selling water
01:00hiredmaneee: the pastebin is not
01:01Carkso here is a little story
01:01Carkearlier today i found that my app was leaking memory
01:01Carki was ready to throw clojure out
01:02lisppaste8eee pasted "untitled" at http://paste.lisp.org/display/74144
01:02Carki asked help here to find a program that would help me track the leak
01:02Carkand found out it was in the java.awt itself : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929
01:03blbrownwhat is the best approach for evaluating a string in clojure
01:03lisppaste8cark pasted "java.awt.Dialog memory leak fix" at http://paste.lisp.org/display/74145
01:03blbrown(eval '(+ 1 1)) Hmm, maybe I can try to get this form
01:03Chouser,(load-string "(+ 1 2)")
01:03clojurebot3
01:04blbrownnice, the bot answered my question for me
01:04eeeChouser did it
01:04eeewith the comma
01:04eeetry yours with a comma first
01:04Carkso in conclusion : i hope i won't see too many of these java library bugs in the future
01:04ChouserCark: wow
01:04blbrownoh
01:05blbrown,(eval '(+ 1 1)) Hmm, maybe I can try to get this form
01:05clojurebotDENIED
01:05blbrown,(eval '(+ 1 1))
01:05clojurebotDENIED
01:05WizardofWestmarceval's protected?
01:05eeewell java is so easy that people will make stuff that sort of works all the time
01:05WizardofWestmarc(in the bot)
01:05durka42um, eval is denied but load-string is allowed?
01:05eeeand get paid a lot of money to do so
01:05durka42that doesn't seem right
01:05hiredmandurka42: oversite
01:05eeeand get a lot of A's in schol
01:05Carkeee : but that comes straight from sun =/
01:05blbrown,(load-string "(new File
01:05clojurebotEval-in-box threw an exception:EOF while reading string
01:05Chouserhiredman: what do you think about providing a way to target a clojurebot eval at a nick
01:05eeebut never learn things like eak references
01:05blbrown,(load-string "(new File 'abc')")
01:05clojurebotDENIED
01:06eeei resemble that remark
01:06durka42hiredman: seems like there should be a better way to block that. can the security manager hook like internal RT.java functions?
01:06blbrownnice
01:06Chouser,hiredman: (+ 1 2)
01:06technomancyblbrown: you can't use single-quotes for strings
01:06Carkeee : the thing is, with a good garbage collector it's pretty rare you need weak references
01:06hiredmandurka42: dunno enough about security policy
01:06Chouserand have it respond: hiredman: 3
01:06blbrown,(load-string "(new File \"abc\")")
01:06clojurebotDENIED
01:07blbrown,(load-string "(+ 1 2)")
01:07clojurebotDENIED
01:07hiredman"hot patched"
01:07blbrowninteresting
01:07WizardofWestmarcusing swank or some other way to connect to the java instance?
01:07hiredman~ clojurebot is also hot patching enabled
01:07clojurebotc'est bon!
01:08eee,(def a 3)
01:08clojurebotDENIED
01:08eeei figured
01:08hiredmannothing based on def works
01:09WizardofWestmarcto avoid polluting the namespace I assume?
01:09blbrownI ran the same code as Chouser, worked for him, not me
01:09eee,(let [a \q] print a)
01:09clojurebot\q
01:10WizardofWestmarchot patched to prevent it
01:10hiredmanblbrown: I patched it in between
01:10WizardofWestmarcafter chouser did it
01:10eee,(let [a 3] print a)
01:10clojurebot3
01:10blbrownhiredman, nice
01:10hiredmanby "patched" I mean I pasted some code into the repl
01:10WizardofWestmarchey, that's all you need to do in erlang too and it's called hotpatching there :P
01:11blbrownhiredman, Actually, I might need code like that. I want to run a simple 'script' parse and restrict volatile code
01:11hiredmaneee: that expression does not do what you think
01:11hiredmanclojurebot: where are you?
01:11clojurebothttp://github.com/hiredman/clojurebot/tree/master
01:11eeeno?
01:11hiredmaneee: you meant ->
01:11hiredman(let [a 3] (print a))
01:12Cark,(read "(+ 1 3)")
01:12clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.PushbackReader
01:12eeeoh
01:12eeeduh
01:12blbrown,(let [a 3] (println (+ 1 1))
01:12clojurebotEval-in-box threw an exception:EOF while reading
01:12blbrown,(let [a 3] (println (+ 1 1)))
01:12clojurebot2
01:12rzezeskiclojurebot: vim or emacs?
01:12clojurebotemacs is hard, lets go shopping!
01:12rzezeskilol
01:12eeeso print nedn't take an arg
01:12hiredmannope
01:12eee,(print)
01:12clojurebotnil
01:12eeei see
01:12blbrownI bet that is the first people do with a bot, check how secure it is
01:12hiredmaneee: print did not even run
01:12eeei suck
01:13hiredmaneee: unless a function is in parens it does not run
01:13eeeoh
01:13WizardofWestmarcit just evaluates to the reference to that function
01:13Chouseror unless it's passed to a fn that runs it
01:13eeewhy let that be legal?
01:13WizardofWestmarcwhen you see the <BLAHBLAHSTUFFBLAH
01:13hiredmanChouser: sshhhh
01:13WizardofWestmarc,print
01:13Chouser,(apply + 1 20 [300 4000])
01:13clojurebot4321
01:14hiredmaneee: first class function
01:14hiredmans
01:14eeei get it
01:14eeeso
01:14eee,print
01:14eeeis like
01:14hiredman,(identity print)
01:14clojurebot#<core$print__3987 clojure.core$print__3987@aea710>
01:14eee,3
01:14blbrown,(identify load-string)
01:14clojurebotDENIED
01:14WizardofWestmarcso you have to explicitly call identity with the bot? interesting
01:14blbrown,(identify +)
01:14clojurebotjava.lang.Exception: Unable to resolve symbol: identify in this context
01:15blbrownI don't get it, but still think the bot is cool and protected
01:15blbrown,(identify '+)
01:15clojurebotjava.lang.Exception: Unable to resolve symbol: identify in this context
01:15hiredmanweird
01:15ChouserWizardofWestmarc: I think it just wants to match ,(...) before it attempts to run it
01:15WizardofWestmarcah
01:15technomancyusing *starred-names* is convention only for dynamically-bound vars that you intend to rebind further down, correct?
01:15WizardofWestmarcgotcha
01:15eeefunctions are types just like numbers . . . .so since I would expect
01:15Chousertechnomancy: I think that's right.
01:15eee,3
01:15eeeI should expect
01:15eee,print
01:16eeeright?
01:16hiredman,(identity +)
01:16clojurebot#<core$_PLUS___3182 clojure.core$_PLUS___3182@18e18a3>
01:16technomancyChouser: since obviously you don't star function names, which are vars just like any other
01:16Chousereee: yes. try it in your own repl
01:16WizardofWestmarcyeah earmuffs are "globals"
01:16blbrown,(identity +)
01:16clojurebot#<core$_PLUS___3182 clojure.core$_PLUS___3182@18e18a3>
01:16Chousereee: clojurebot's little IRC rules may be confusing things for you
01:16technomancyWizardofWestmarc: heh; earmuffs.
01:16technomancyglobals that change though.
01:16eeenope
01:16Chousertechnomancy: right. globals are nothing special
01:16eeethanks for catching that
01:17WizardofWestmarcwhich is why you tend to want to flag them with the *'s so you can tell when you're dealing with something scoped globally
01:17ChouserWizardofWestmarc: no, something that might change
01:17WizardofWestmarcwell, you wouldn't care if it's scoped globally if you won't change it
01:17Chouserevery 'def' and 'defn' is a global
01:17eeewell, I can clock out
01:17WizardofWestmarcafter all then the scope doesn't matter
01:17eeei learned something!
01:17blbrownthought you can change a value once it has been defined
01:17blbrowncant
01:18WizardofWestmarcsymbols can point to different things
01:18WizardofWestmarcthe thing pointed TO is immutable
01:18eeeso remember to spread the word. namespaces are gonna be slash separated now
01:18eee:)
01:18Chouserin Clojure, symbols don't really point to anything. they're just names.
01:18blbrowngreat, another change
01:18eeejust kidding
01:18blbrownscared me
01:18eeethat was evil
01:19durka42backslash separated?
01:19eeenevermind
01:19hiredman,3
01:19hiredman,3
01:19hiredmanhmmm
01:19eeei was tryign to spread a rumor
01:19rzezeskiChouser, wow, those reddit ppl were pretty harsh on your "path to Clojure" post
01:19eeesince I'm not used to anything
01:20eeeI thought that would be easier for newbies
01:20Chouserrzezeski: yeah, that was fun for me.
01:20WizardofWestmarcprogit or general reddit?
01:20eeei wanna see
01:20eeewhere is the post?
01:20blbrownrzezeski, where is the link
01:20WizardofWestmarc'cause people in programming.reddit always seem to like to tear into people it seems like
01:20rzezeskihttp://www.reddit.com/r/programming/comments/7r2zu/my_path_to_clojure/
01:20WizardofWestmarcthough i still go there to find handy links and roll my eyes at people :P
01:21eeeno one ever says anything mean about clojure
01:21eeefrom what i've seen
01:21rzezeskisome of them are foaming at the mouth (figuratively speaking)
01:21eeelet's see this thing
01:21technomancythis one is much worse than normal
01:21rzezeskiit's sad
01:21technomancysome people see "java" and think "code monkey"... the idea of the JVM as a separate piece of engineering never really occurred to them
01:21WizardofWestmarcCL fanatics are definitley out there in the reddit community
01:21WizardofWestmarcsince reddit 1.0 was written in CL
01:22WizardofWestmarcso they're a bit defensive
01:22blbrowneee, kind of a brain fart, that Clojure works with existing Java code runs on the JVM and is still a very productive language
01:22WizardofWestmarcand yeah, it can be hard to seperate the JVM from Java. I had to get used to that idea when I first started looking into clojure
01:22ChouserWizardofWestmarc: me too
01:23durka42hmm, this is sort of interesting http://logand.com/sw/jmultimethod/
01:23WizardofWestmarcI was like "ew, java" "wait, lisp macros, real vector support, and easy access to that many libraries?" "But... Java!"
01:23rzezeskiI guess there will always be ppl hating for one reason or another
01:23eeehere's the thing
01:23technomancyWizardofWestmarc: it's unfortunate that the "J" snuck into the name JVM; the CLR is a much better name.
01:23eeein the discussion group
01:23WizardofWestmarcI think it was that one video presentation of rich's where he goes on about how you can hate java but love the jvm that really helped me finish getting past that.
01:24eeeread the post that has to do with streams
01:24eeetoday I was in there defending Rich about the avoidance of extra allocation
01:24WizardofWestmarctechnomany: true, but how long was it before you saw much of other languages running against the JVM?
01:24eeeand an NVIDIA guy echoed it
01:24eeebut
01:24eeehe talked about how C# worked right
01:24eeeand java didn't
01:25eeeinteresting read
01:25eeeand clojure MIGHT fix that
01:25eeeor have a chance
01:25WizardofWestmarcwell
01:25blbrownone more general comment, going back to Common Lisp, there seems to be a lot to add to a confusing API. For example, there is flet, labels, letrec...on and on. In clojure, it is just '(fn name ...)
01:25WizardofWestmarcone of the interesting things (to me) about clojure is it has a much stronger chance of exposing a lot of programmers to language constructs they might not have even touched otherwise
01:26eeei'm going to have a hard time trusting it's efficiency until I understand what it is doing
01:26eeeas with any high-level language
01:26gnuvince_If people had taught/learned JavaScript the way it's supposed to be used, everyone would be familiar with HOPs by now.
01:27WizardofWestmarcHOP? Higher Order Programming?
01:27gnuvince_procedures
01:27WizardofWestmarcah
01:27Chousergnuvince_: yes, but instead they write pages of code to make JavaScript act like Java. ...and then pages more now that they have to follow all this Java-like ceremony.
01:28WizardofWestmarcwell
01:28blbrowngnuvince, do people use Javascript outside of a web environment
01:28WizardofWestmarca lot of programmers only know one way to program
01:28rzezeskiChouser: you talking about OO like frameworks in JS?
01:28blbrownJavascript is cool language, but I can't stand working with it in the context of web development
01:28WizardofWestmarcblbrown: tried jquery?
01:29eeenice little essay. I only skimmed it
01:29eeeso far
01:29eeebut I'll read it more thuroughly
01:29blbrownWizardofWestmarc, jquery is fine, but if you aren't using jquery...well
01:29Chouserrzezeski: I'm really just talking about Zimbra. I chose (poorly) to use its JS lib at work, and now we're mired in it.
01:29WizardofWestmarcright
01:29WizardofWestmarcbrowser issues suck I agree
01:29eeevery impressive how much you challenge yourself
01:29WizardofWestmarcbut that's why all the different libs (jQuery, mootools, and so on) all cropped up I'd argue
01:30WizardofWestmarcI doubt such robust libraries would have cropped up the way they did were it not for the need to hide browser implementation differences
01:30rzezeskiChouser: I don't know what Zimbra is, but I have seen articles about creating frameworks in JS that make it look all OO and behave like Java, and I just think to myself..."why?"
01:30technomancyhrm... how would a remove-first function work?
01:30WizardofWestmarcremove-first? You mean like (rest [coll]) ?
01:30WizardofWestmarcor what are you aiming for?
01:31eeewhat is the technology behind wordpress I wonder
01:31blbrownWizardofWestmarc, plus, if you have complex pages, complex CSS and in turn complex javascript,..like you said, supporting multiple browsers...it just becomes difficult to debug client side web
01:31WizardofWestmarcblbrown: yeah
01:31technomancyWizardofWestmarc: I mean "remove the first element from coll for which pred returns true"
01:31WizardofWestmarcah
01:31eeePHP
01:31eeeMySQL
01:31rzezeskiChouser, have you ever had the pain of having to use ExtJS?
01:32Chouserrzezeski: nope.
01:32technomancyI guess it could be built on top of partition-by
01:32eeethere's a function partition-by?
01:32eeeseems unnecesary
01:32technomancymy brain is done for the night though; now is a bad time to be writing new util functions.
01:32technomancyeee: well, it's contrib
01:32technomancynot core
01:33eeeah
01:33eeei'm out too. gnight
01:33WizardofWestmarcthat reminds me, are there any docs for contrib aside from just browsing the source or (doc)ing through it?
01:33rzezeskiChouser, it's a "peach" of a Javascript Widget library. Makes everything look like a windows desktop. It annoys me everyday.
01:34Chouserrzezeski: ah. :-(
01:35rzezeskiIt clobbers all my CSS, creates massive amounts of DOM. So I know what it's like to work with a JS library you don't like.
01:35blbrownWizardofWestmarc, one more comment, I hope to work on this application. It will essentially 'compile' a web page. It will validate a XHTML document, validate the Javascript (maybe using Rhino) and possibly validate the CSS
01:36blbrownWizardofWestmarc, cut down on errors before deploying an app. Hmm, maybe I could even use clojure
01:36WizardofWestmarcdon't see why not
01:37blbrowntreating client side web content like some cheap script doesn't help anyone
01:37WizardofWestmarcI've been looking at text analysis as my way of finally getting serious about learning the language
01:37blbrownWizardofWestmarc, checked opennlp?
01:37WizardofWestmarctreating anything like it's cheap doesn't help the dev or end user.
01:37WizardofWestmarcno I hadn't
01:38durka42technomancy: take clojure.core/remove, and change (recur pred (rest coll)) to (rest call)
01:38WizardofWestmarcoh interesting
01:38WizardofWestmarc*bookmarks*
01:38durka42er, coll
01:38blbrownWizardofWestmarc, might be useful .... http://opennlp.sourceforge.net/README.html
01:38technomancydurka42: of course... thanks
01:38technomancymy brain is slow; glad you caught me before I signed off. =)
01:39WizardofWestmarcalready going into my delicious acct, thanks for the tip :)
01:39durka42:)
01:40WizardofWestmarcand since it's java based... mmm
01:41blbrownthere are so many good Java libraries, it is going to take a while for other languages to end up with the same tools
01:41blbrownlucene/nutch/hadoop is my favorite
01:42WizardofWestmarcI want to try out terracata(sp) but have nothing in the pipe that warrants it.
01:42technomancythere's a lot of lousy ones too though unfortunately
01:42blbrownWizardofWestmarc, another good one
01:42technomancyterracotta wins for greatest potential to be a game-changer I think
01:43WizardofWestmarctechnomancy: yeah I'd agree with that
01:43WizardofWestmarcespecially as multi-core gets more and more common even for end users. Core 2's... the new i7 (which I want in my next desktop) etc
01:43blbrownwould only work for server apps, batch processing though. Don't know if would be useful in the desktop realm
01:43WizardofWestmarcdepends on what you're doing
01:44durka42hiredman: it seems like clojurebot's responder methods are dispatched once. can I hand the bot/pojo back to the dispatcher after responding?
01:45Puzzlerchouser: are you in charge of seq-utils?
01:45durka42like, i want the ::deliver-messages responder to be called, but then for clojurebot to do whatever it would have done anyways
01:45WizardofWestmarcactually I wonder if I could do one of my old stand bys for learning a new language with Terracotta, a basic MUD engine heh
01:45ChouserPuzzler: I'm in charge of nothing. :-)
01:45Chouserand Stuart Sierra's name is at the top, so...
01:46technomancyWizardofWestmarc: I'm working on a MUD engine right now.
01:46technomancyit's fun
01:46WizardofWestmarcin clojure?
01:46technomancyWizardofWestmarc: yeah
01:46PuzzlerOk. I've got significantly faster versions of several of those functions. I'll let him know when I get a chance.
01:46technomancyclojurebot: mire?
01:46technomancyoh... he's gone
01:47WizardofWestmarctechnomancy: hah nice
01:47technomancyWizardofWestmarc: https://github.com/technomancy/mire/tree
01:47technomancyabout to commit some cleanups; hang on
01:47WizardofWestmarctechnomancy: you basing the style of commands/etc on any particular existing MUDs?
01:48WizardofWestmarcROM/ROT/Circle/etc
01:48ChouserPuzzler: great. the google group is the best place to start that sort of conversation.
01:48technomancyWizardofWestmarc: I haven't actually played a real MUD
01:49technomancyWizardofWestmarc: it's just a super-basic explanatory codebase.
01:49WizardofWestmarctechnomancy: yet interested enough to write one? Interesting. Most people I know who like to write MUDs used to play them
01:49WizardofWestmarctechnomancy: but then I was someone who was heavily into them during college, including helping code updates into one.
01:49technomancyWizardofWestmarc: it's the simplest thing I could think of to write that you still run into interesting concurrency problems with
01:49technomancyapart from a chat app, but that's lame
01:49WizardofWestmarctrue
01:50WizardofWestmarcwhich is part of why I like writing them as well
01:50WizardofWestmarcgood threading excercise
01:50technomancyexcept in this case you don't have to deal with any low-level stuff at all
01:50WizardofWestmarcright
01:50technomancyit's all refs and commute/dosyncs
01:50technomancyonce streams get mainlined it'll be even simpler
01:51WizardofWestmarcwhich is why the idea is so interesting
01:51WizardofWestmarcusually one of my first reactions upon looking at a language is "would that be interesting to write a MUD in" haha
01:52technomancybattery dying; talk to you folks later.
01:53PuzzlerWhat do you guys think of the up-and-coming stream stuff?
01:54WizardofWestmarcit sounds promising
01:55WizardofWestmarcbeing able to have non-seqed streams to avoid heavy memory use in large lazy constructs is really interesting when you only need one pass over the data
01:55hiredmandurka42: you can try
01:56durka42would i just want to call (responder bot pojo) again at the end of my function?
01:56durka42after removing the conditions that led to the dispatch to my function
01:56PuzzlerWizardofWestmarc: Actually, I think avoiding memory use from lazy constructs can even be useful for multiple passes over persistent but easily computable data. Streams don't really provide that though. But yes, I agree with you.
01:57WizardofWestmarcPuzzler: also true on the easily computable
01:58WizardofWestmarcthe single pass is just the first thing I always think of with stream style objects
01:58hiredmandurka42: why do you want to feed through the dispatcher twice?
01:58durka42well, consider:
01:58PuzzlerHowever, I'm not convinced that the Clojure approach to streams as a way of making iteration "more safe" is really necessary. Have you ever heard of anyone's program being buggy because of misusing iterators?
01:58durka421. fred tells clojurebot to deliver a message to bob
01:58durka422. bob comes in and tells clojurebot to deliver a message to fred
01:58WizardofWestmarcnot off the top of my head
01:58durka423. clojurebot sees bob and delivers fred's message
01:58WizardofWestmarcbut then I don't claim to be highly educated on the specifics
01:59durka42but since ::deliver-message just got called, ::leave-message is not called and bob's message doesn't get queued
01:59PuzzlerI can't think of any time in my own programming life where this kind of encapsulation of iterators would have made any difference. In general, iterators are used in one spot in a program, usually as part of a for loop.
01:59WizardofWestmarctrue
01:59WizardofWestmarcalthough, one interesting case I can think of
01:59durka42or #2 can be, bob comes in and sends clojurebot ,(+ 2 3) which doesn't get eval'ed because ::deliver-message preempted it
02:00WizardofWestmarcif you have a stream of data that's being pulled across threads
02:00PuzzlerI'd love to see an example of where traditional iterators would result in buggy code, but Clojure's approach would make a difference.
02:00WizardofWestmarcthat protection could be handy
02:00WizardofWestmarcthe stream being used to feed work to the threads
02:01WizardofWestmarcbut yes if you create and destroy the iterator inside a small scoping, the issues don't exist
02:04PuzzlerI'm very curious to see what kind of mechanisms Rich puts into Clojure to make generating functions easier to write. Python's yield, perhaps?
02:04WizardofWestmarcyield would certainly work
02:04WizardofWestmarcnot sure how hard that would be to code with jvm bytecode
02:05WizardofWestmarcbut at least from a programmer perspective it always felt elegant in python
02:07WizardofWestmarcperhaps a loop/recur special case/variant would work as well
02:07WizardofWestmarcthough I guess you could argue that's same thing as yield
02:13hiredmanclojurebot: hiredman?
02:13clojurebothiredman is an evil genius.
02:13hiredmanthats not right
02:13hiredmanclojurebot: hiredman?
02:13clojurebothiredman is lazy
02:13hiredmanclose enough
02:14hiredmananyone with the clojurebot code, if you notice it spinning in an infinite loop, mea culpa, fix just pushed to github
02:14durka42hiredman: did my scenario make any sense?
02:14hiredmandurka42: sorry, was distracted
02:15durka42basically, the problem is that clojurebot gets distracted by delivering someone a message and forgets to process what they said
02:15hiredmanI am not entirely adverse to the idea of passing through twice, but I think there are otherways to build such a thing
02:16hiredmanI think your major problem right now would be that Joins and Parts don't go through dispatch
02:16hiredman(if you plan on deliverying message on join)
02:17hiredmanI guess there is no reason they shouldn't
02:17hiredmanthe plumbing just isn't in place
02:17durka42yeah, i was thinking i'd have to proxy onJoin
02:20hiredmanhmmmm
02:20hiredmangoodluck :P
02:21durka42oh dear, i created an infinite loop
02:21durka42cbtest left the chat room. (Excess Flood)
02:23durka42hum, removing the nick from the message queue and calling responder at the end seems to work
02:27Chouserloop on the current method -- doesn't go back through dispatch
02:28hiredmanmyself and clojurebot are in #clojurebot
02:29durka42would you like myself and answering-machine-mod-clojurebot to join you?
02:29hiredmanyou may
02:39cadshey Chouser, do you have a blog?
02:40durka42blog.n01se.net isn't it
02:40cadsI read something on a blog of one of the denizens of this channel, was trying to find the blog again
02:41Chouseryeah, that's right.
02:41cadsyup, it was your my path to clojure, where you mention project euler.
02:45cadsunrelated to why I wanted to find the article, is it just me that is totally stumped or simply doesn't know enough group theory to know where to begin with the laserbeam problem: http://projecteuler.net/index.php?section=problems&amp;id=202 ?
02:46hiredman~euler
02:46clojurebotclojure euler is http://clojure-euler.wikispaces.com/
02:47cadshah!
02:47cadsmaybe I have to implement an algebraic precision raytracer and post on there
03:13cadsoh man
03:13cadsI've been looking at that problem for months, and now a near trivial solution dawns on me :P
03:14cadsi feel stupid
04:16Kerrisleepcads: never underestimate the power of your subconscious mind :P
04:20PuzzlerWho started the clojure-euler wiki?
04:21PuzzlerEvery other project euler wiki I've seen adheres to the spirit of Project Euler by protecting the solutions and revealing only to people who have solved the problems.
04:21hiredmanhttp://clojure-euler.wikispaces.com/space/about
04:51Lau_of_DKMorning gents
04:53ChousukePuzzler: the clojure euler wiki is dynamic! it lets you shoot yourself in the foot if you so wish :)
04:55PuzzlerChousuke: Yes, I see that. I think it's uncool to give away the answers. But I think the tools section of the wiki is a great idea.
05:13cadsplus, if random people learn clojure to translate the solutions, isn't that just good exposure?
05:16cadscertain of the problems in project euler are inaccessible, a tiered forum where discussion of relevant literature was visible to the unsolved public would be nice
05:16hiredmanoh
05:16hiredmanhey
05:16hiredmanguys
05:16hiredmanI had an idea
05:17hiredmanmaybe I should wait for rhickey
05:17hiredmanbut I won't
05:17hiredmaninstead of (scope ...) it should be (horizon ...)
05:18hiredmanso we can steal and repurpose various blackhole terminology
05:18hiredmansomething conditions that depend on horizon, called outside of a horizon would be "naked"
05:18hiredmansomething with
05:20cads.. enough charge and rotational intertia would create a wormhole out of this universe
05:20cads?
05:20hiredmanhorizons would hide icky io stuff
05:21hiredmanstill jhave the figure out what the "wormhole" analogue would be
05:21cadswe still have to explain how particles that pass the horizon go off onto spacelike trajectories and lose touch with the rest of spacetime
05:22cadsand the hawkings radiation, maybe leaky abstraction?
05:23hiredmancads: have you seen the (scope ...) stuff?
05:24cadsI haven't, so I am a little out of the loop
05:24hiredmanhttp://paste.lisp.org/display/73838
05:24cadsbut i do know blackhole spacetime
05:24hiredman(scope ...) is a new thing rhickey is working on
05:26hiredmancads: so we can mine you for terms if this horizons thing takes off
05:27cadsI tend to stretch analogies till they break :D
05:27hiredmanclojurebot: scope is <reply> itym horizon
05:27clojurebotRoger.
05:28cadsso if you think you'd need a concept of blueshifted external variables, consult me :D
05:29hiredmando you buy this new fangled "naked singularities may be possible" stuff?
05:32cadsthe solutions are there in the equations, I've see a simulation of the gravity waves that'd be coming off of a naked singularity. it's awe inspiring
05:33cadsI forgot if there were perverse/uncomfortable consequences to them existing
05:34cadsI think a naked singularity would tend to allow causality to be violated
05:35cadsI'm not so sure about how those spacetimes look
05:35cadsI wouldn't be shocked if such things could exist
05:39cadsI forgot the motivation for the cosmic censorship hypothesis, but there are a lot of scientists who think the universe would not allow a singularity to be visible to the rest of the universe
05:39hiredmanI happen to have an illustrated guide, thanks to this months sciam
05:40cadsit seems a little silly
05:41cadsbut yeah, been simulations of it for a while. Wierd things happen, though, stuff that a theory of quantum gravity would probably explain more decisively
05:42hiredmanseems like one of those would be useful
05:42cadsI want for hyper exotic physics like that (holes to other universe, cmon!) to exist, how about you?
05:43hiredmansounds fun to me
05:43hiredmanI think I'll need a singularity for my tardis
05:47cadshmm
05:48cadsit seems like a main motivation behind the idea of no nakid singularities is the strong desire on the part of certain physicists for a universe that is deterministic
05:49cadsalso of concern would be much worse violations of causality, but I'd say that since our time on the whole seems pretty consistent, if naked singularities do exist they don't mess with time at a long range
05:50hiredmanshows what you know
05:50hiredman:P
05:50cadswhat do you mean?
05:51hiredman"but I'd say that since our time on the whole seems pretty consistent"
05:51hiredmansure
05:51hiredman"seems"
05:52cadsyeah, the seeming consistency of time could be an illusion our brain manufactures, to varying degrees
05:53cadsbut physics (again, seems to) have strong predictive power
05:54cadsit could be that the inconsistent physics that happens instinctively stays away from scientific experiments for fear of being found out :D
05:54cadsbut it could explain nonsensical stuff humans come up with
05:54cads... like this conversation at 5 am in the morning hehe
06:03cadsdoes anyone maintain a deb package containing clojure?
08:38pjb3Is there a function that will tell you if a symbol is "defined" (I know that's not the right term, but you know what I mean)
08:39kotarakmaybe resolve? I returns nil if there is no Var of that name.
08:39kotaraks/I/It
08:40pjb3user=> (resolve? x)
08:40pjb3java.lang.Exception: Unable to resolve symbol: resolve? in this context (NO_SOURCE_FILE:3)
08:40pjb3,(resolve? x)
08:40clojurebotjava.lang.Exception: Unable to resolve symbol: resolve? in this context
08:40kotarakresolve
08:40kotarakwithout ?
08:40pjb3,(resolve x)
08:40clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
08:40pjb3,(resolve 'x)
08:40clojurebotnil
08:40hoeckpjb3: (ns-resolve *ns* 'foo)
08:40kotarakThe ? was form my sentence. Maybe "resolve"?
08:40kotarak;)
08:40pjb3kotarak: gotcha
08:41pjb3,(doc some)
08:41clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
08:41pjb3(some #(resolve %) ['a 'b 'c])
08:41pjb3,(some #(resolve %) ['a 'b 'c])
08:41clojurebotnil
08:41pjb3(some #(resolve %) ['a 'b 'str 'c])
08:42pjb3,(some #(resolve %) ['a 'b 'str 'c])
08:42clojurebot#'clojure.core/str
08:42pjb3,(reduce #(resolve %) ['foo 'str 'bar 'map])
08:42clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--551$fn
08:44pjb3,(filter #(resolve %) ['foo 'str 'bar 'map])
08:44clojurebot(str map)
08:48karmazilla,(filter resolve ['foo 'str 'bar 'map])
08:48clojurebot(str map)
09:09pjb3,(filter resolve '(foo str bar map))
09:09clojurebot(str map)
09:14pjb3,(for [[k v] {:x 1 :y 2}] (str (name k) "=" v))
09:14clojurebot("x=1" "y=2")
09:14pjb3I just figured out that you can do that. Yay!
09:22AWizzArdMoin moin
09:23hoeckAWizzArd: moin :)
10:46blbrownwonder if it is bad clojure practice to put all my 'java imports' in one file (import ....) with a bunch of imports
10:50kotarakI'm not sure I understand you correctly. The imports for a namespace shoud go to the corresponding (ns ... (:import ..)).
10:51blbrownkotarak, OH, oops. I have a file call 'imports.clj' And I include all my import calls in there and then do '(load 'imports.clj') at the imports call
10:52blbrownisn't it the same thing
10:53kotarakDo you have problems with this style?
10:53blbrownkotarak, yours or mine. I don't have any with mine because I can just add imports to a file when needed
10:54kotarak"isn't it the same thing" sounded like some unexpected effect.
10:56kotarakblbrown: you can organise your source however you like... If it works for you...
12:11pjb3,(defn #^{:test (fn [] (assert (= 41 (foo))))} foo [] 42)
12:11clojurebotDENIED
12:11pjb3lame
12:12pjb3Anyway, when I define that foo function, and then run (test foo), it says no-test
12:12pjb3What am I missing?
12:15pjb3Ah, (test (var foo))
12:19Chouserrhickey: I think definline has been broken since rev 1065, along with the 'ints', 'longs', etc.
12:19Chousertries to print a closure
12:29pjb3So when you have a failing assertion in a test
12:30pjb3It prints something like Assert failed: (= 42 (f x))
12:30kotarak_Well. It throws an exception.
12:30pjb3yeah, right and that's the name of the expcetion
12:31pjb3What I'm wondering is there a way to get it to print (= 42 1)
12:31pjb3Or Assert failed: (= 42 (f x), expected 42, got 41
12:32pjb3I suppose I could do that with a macro
12:32pjb3assert-equals 42 (f x)
12:32kotarak_You'll need test-is, fact or clojurecheck for that, I guess.
12:32Chouserthere are other testing frameworks around that have had a good deal more work put into them than the builting 'test' function
12:33cooldude127i wonder if it's productive to try implementing my data structures homework in clojure before i do it in java. maybe it will be easier to understand that way
12:33kotarak_cooldude127: I would be careful with translating between languages.... Especially if the general mindset is so different.
12:33Chousercooldude127: it seems likely your homework will rely on and/or build mutable things that will be require rather non-idiomatic Clojure code.
12:34cooldude127kotarak_: i think it might be easier to understand the recursive algorithms at first without java's baggage
12:34ChouserI'm sure you can do it, but it might not end up looking much better than the Java you would have had to write.
12:34cooldude127Chouser: i have to write the java anyway, it's just hard when writing the java to understand what i'm doing
12:37Huni second doing it in a lisp first. that helps me a lot when developing in vhdl :)
12:38pjb3Is there a function in clojure that already does this? (defn to-s [o] (if (keyword? o) (name o) (str o)))
12:38cooldude127what would be the best way to represent tree nodes? a map with :data, :left, :right keys or a list?
12:38pjb3Do you find yourself having to do that alot?
12:38cooldude127pjb3: not that much. i usually know what i'm expecting, and just use one of the two
12:39pjb3For example, I'm writing a function that produces an XML/HTML tag
12:39pjb3so (tag :p "foo") # => "<p>foo</p>"
12:40pjb3In designing the API, my thought is why not let people use a string for the tag name if they want to
12:40pjb3(tag "p" "foo") # => "<p>foo</p>"
12:40cooldude127cuz strings are evil?
12:40cooldude127lol
12:40pjb3Hence the need for the to-s
12:41pjb3This probably shows the Rubyist in me
12:41ChouserI like :foo#bar.baz => "<foo id="bar" class="baz" />"
12:41cooldude127i don't think it exists already, but it looks like the right thing for you
12:41cooldude127Chouser: i can't believe that's a valid symbol
12:41pjb3Chouser: Yeah, it will do that
12:42Chouserpjb3: there are libs that do that already. I don't know how heavy they are, though.
12:42Chouser,(prn :foo#bar.baz)
12:42clojurebot:foo#bar.baz
12:42pjb3But should I allow (tag "foo#bar.baz") as well?
12:42pjb3In ruby, almost takes a symbol (what is called a keyword in Clojure) or a string
12:43pjb3And just does arg.to_s in the body of the method
12:43Chouserpjb3: if you want, but that kind of conversion isn't terribly common outside specific DSLs like what you're building.
12:43pjb3but in Ruby, :foo.to_s # => "foo"
12:44Chouserpjb3: (str :foo) does return a string, as I'm sure you've noticed, you just don't like the format for your particular usage. Seems pretty application-specific to me.
12:45pjb3Chouser: yeah, and it's easy enough to write that to-s method to deal with it, I'm just wondering if everyone else ends up writing that same method
12:45pjb3I guess not
12:45pjb3Now we'll forever know which Clojure programmers are Ruby programmers
12:45cooldude127haha
12:46pjb3The ones that write to-s and use it in their code are :)
12:46ChouserI think there have been requests for 'name' to do something useful with strings, but I also think those have been shot down.
12:47pjb3Yeah, that's what I figured, there's no reason to have (name "foo") not return "foo", other than syntactic vinegar
12:47pjb3So I realized that I must be "Doing it wrong" in the eyes of Clojurians
12:56pjb3test-is, very nice
12:58dnolenquestion on making multidimensional Float arrays in clojure. I understand that (def v1 (make-array (. Float TYPE) 2)) creates an float array. But do I make a container java array to hold them in clojure?
13:01Chouserdnolen: I don't think I understand the question. v1 names a Var that is acting as a sort of container for the array. what else do you need?
13:01dnolenChouser: sorry for not being clear. How do you translate float[][] into Clojure?, i understand float[]
13:02Chouserah, I see.
13:02Chouser,(make-array Float/TYPE 10 10)
13:02clojurebot#<float[][] [[F@100aff5>
13:03Chouserthat's a 10x10 array of float
13:04dnolenChouser: nice, thanks, dur, I should have thought to check the sig of make-array. the answer in Clojure is so often so dead simple, it's surprising ;)
13:04Chouser:-)
13:46pjb3Is there clojure function that takes a predicate function and returns a function that is the opposite of that?
13:47pjb3,(filter #(not (nil? %)) [1 nil 2 3 nil])
13:47clojurebot(1 2 3)
13:47pjb3,(filter % [1 nil 2 3 nil])
13:47clojurebotEval-in-box threw an exception:arg literal not in #()
13:47pjb3complement
13:48pjb3,(filter (complement nil?) [1 2 nil 3 nil])
13:48clojurebot(1 2 3)
13:49pjb3hmm..it's such a long word that is shorter to do #(not (f %)) than (complement f)
13:49pjb3I guess it's more readable though
13:51pjb3,((complement filter) nil? [1 nil 2])
13:51clojurebotfalse
13:52pjb3I understand the idea of not having the complement of every predicate function defined, but some of the basic ones might be nice
13:52pjb3(filter not-nil? [1 nil 2])
13:53pjb3,(remove nil? [1 nil 2])
13:53clojurebot(1 2)
13:53pjb3ok, I guess that's the way to do it
13:56durka42,(filter identity [1 nil 2])
13:56clojurebot(1 2)
14:00pjb3,(first nil)
14:00clojurebotnil
14:00pjb3I like that that returns nil instead of throwing an exception
14:02cooldude127yeah that is the right behavior imo
14:02WizardofWestmarchm, getting a null pointer exception on this inner/outer loop construct and I can't figure out why.
14:02WizardofWestmarchttp://paste.lisp.org/display/74161
14:02WizardofWestmarc(doing project euler stuff)
14:03danlarkinwithout looking at the code I bet I know why!
14:03WizardofWestmarcshoot
14:03danlarkinbut now I'll look to make sure :)
14:03WizardofWestmarcI'm probably doing osmething silly that I'll kick myself for once you point it out
14:03WizardofWestmarc*something
14:04danlarkinoh god no indenting
14:04durka42see annotation
14:04durka42not sure why it wasn't announced
14:05WizardofWestmarcyeah my emacs setup doesn't indent some reason.
14:05jbondesongive me some exmples to call this on
14:05WizardofWestmarc(used clojure box)
14:05jbondesonyou don't have tab bound probably
14:06danlarkinok, so the problem is indeed what I suspected
14:06danlarkinyour (recur (rest outerlist)) is unchecked
14:06danlarkinit will always fire
14:06WizardofWestmarcoh
14:06WizardofWestmarcduhhh
14:07dreishIt looks like both recurs are unchecked.
14:07jbondesonbad wiz
14:07danlarkinman I'm so good, I can debug code without even looking at it!
14:07durka42danlarkin, clojure guru
14:07danlarkinhardly
14:07dreishPutting the first one on the same line as the conj makes the code much harder to read.
14:08danlarkinyeahhhh
14:08dreishIn general, I try not to put anything on a line after a closing paren other than other closing parens, unless I'm sure it'll make the code easier to read.
14:09danlarkinthis is useful, albeit too long to skim: http://mumble.net/~campbell/scheme/style.txt
14:27dnolenis there an existing functions for unwrapping Java arrays into Clojure vectors? I have one, but wondering if there's a tested one in conrib that I can use. I didn't see anything like this core.
14:29kotarakmaybe (into [] the-array)? Or (vec array)?
14:30dnolenjava arrays can't be treated as collections from what I can tell.
14:30dnolenoops wrong
14:30dnolenkotarak, that's right
14:30dnolen(vec array)
14:31dnolenthanks
14:31kotarakOk. Good to know. :) (Was just a guess)
15:17danlarkinLau_of_DK: ping
15:17Lau_of_DKpong
15:18Lau_of_DKdanlarkin: I said PONG! :)
15:18danlarkinhaha
15:18kotarakLau_of_DK: Uh? I didn't know you are a bot!
15:19danlarkinhow does "syrinx" sound? :)
15:19Lau_of_DKIt sounds like the needle byw hich you can get an ebola vaccination, why ?
15:19Lau_of_DKooh, you meant as an alternative to Cladjango ? :)
15:19danlarkinyes
15:20durka42hey, if clojure cures highly infectious diseases i'm ok with that
15:20Lau_of_DKHow did you come up with it? Any special meaning?
15:20Lau_of_DKdurka durka?
15:20durka42hmm?
15:21danlarkinit's a movement from 2112, a song by Rush :)
15:21danlarkinwell, the movement is "The Temples of Syrinx"
15:21Lau_of_DKah...
15:21Lau_of_DKdanlarkin: I think, that you should keep thinking about it, but thats just my oppinion :)
15:22danlarkin:(
15:26Lau_of_DKIts because, I think you should find a name which reflects the awesome power of the framework you provide, like Skynet, or Webtrix :)
15:27durka42i suggest that you do not call it Clojure on Clotheslines
15:27danlarkingross
15:28danlarkinsuggestion accepted
15:35pjb3Why is there a defn- but no def-
15:35pjb3?
15:40Lau_of_DKdanlarkin: Did you Gitit yet ?
15:40danlarkinLau_of_DK: first I've gotta think of a good name!
15:40dnolenwhat's the fastest accessor for vectors? first/second seem kind of slow in maps.
15:40pjb3danlarkin: a good name for what?
15:41danlarkinpjb3: a django clone/port/rewrite in clojure
15:41danlarkindjango-esque
15:41Lau_of_DKdanlarkin: How about "DynaWeb" ? :)
15:41pjb3Reinhardt?
15:44pjb3cljango?
15:45danlarkineh
15:46jpeaseclojure on djangos
15:46kotarakcljango - no one serves faster
15:47jpeaseclojangure
15:47Lau_of_DKlol
15:48rryanif you want a django-esque name, you should go with some other famous jazz musician's name. Miles Davis? John Coltrane? Herbie Hancock? Coltrane or Trane is nice.
15:48Lau_of_DKThat sounds like a type of monkey
15:48pjb3I like coltrane too
15:48pjb3Has a c and l in it too
15:49rryanwikipedia says he also went by 'Trane', which would be kind of railsey
15:49pjb3Without being a ridiculous name like cljango :)
15:49rryanright :)
15:50gnuvince_Is there a function in SLIME to modify an entry in slime-lisp-implementations or do I need to manually delete the old entry and put in a new one?
15:50Lau_of_DKdanlarkin: How about "Easy web" "Dynamic web" "LispyWeb" "dotClojure" "Barkin' Larkin'" ?
15:50pjb3How about ((((((django))))))))
15:50Hungnuvince_: just edit and C-M-x it
15:50Hunpjb3: that's a whole lot of indirections :)
15:52rryanhm, for reference, here's Jacob Kaplan-Moss's list of names that "Django" almost was: http://jacobian.org/writing/private_dancer/
15:52danlarkinsorry guys, brb :-o
15:53rryanthey're all fairly bad :)
15:53pjb3tornado FTW!
15:53durka42siljouette
15:54rryansiljouette is nice
15:55Lau_of_DKdurka durka
15:55jpeasei guess that's better than garbonjo
15:56durka42yes Lau?
15:56Lau_of_DKdurka, is your nick taken from Team America ?
15:57durka42more or less, it rhymes with my real name
15:57Lau_of_DKoh.. Because when ever I see it, I think "durka durka" with a funny accent
15:58durka42:)
16:05Lau_of_DKSo whats your idea Karma?
16:07karmazillafigure out which qualities sets this framework apart from the rest, and then try brain-storming again with that in mind
16:08Lau_of_DKSo youre saying we should stick with "Barkin' Larkin'" ?
16:09rryanit's hard to know what sets it apart before its written
16:09Lau_of_DKDjango is pretty well defined rryan :)
16:12hiredmandid y'all see my scope renaming idea?
16:12hiredmanhttp://clojure-log.n01se.net/date/2009-01-24.html#05:16
16:15Lau_of_DKYep hiredman
16:16durka42i like it
16:19karmazillaNaked singularities? Way over my head, though I get a vibe from the conversation that his Noodliness might be playing with the physicists again. :)
16:21hiredmanthe idea is we just steal the blackhole/event horizon terminology for (scope ...)
16:22durka42nothing can escape from a horizon
16:45danlarkinboltdozer is an attractive name
16:45danlarkinhahah
16:46danlarkinHmmm Trane is kinda cool....
16:54hiredmanneat
16:54hiredmancomp works with keywords
16:58pjb3,(def i 0)
16:58clojurebotDENIED
16:59pjb3If I have this:
16:59pjb3(def i 0)
16:59pjb3(defn f [x] (binding [i (+ i 2)] (println "i: " i) x))
16:59pjb3(f (f (f 1)))
16:59pjb3Shouldn't that print increasing values for i?
17:01pjb3no, it shouldn't :)
17:04durka42no, because i is never modified
17:04durka42and x is never used
17:05pjb3Yeah, the reason I never changes is that the function isn't recursive so the binding of i just goes from 0 to 2 and back to 0 with each invocation of f
17:05pjb3(defn f [x] (binding [i (+ i 2)] (println "i: " i) (if (> x 0) (f (dec x)) nil)))
17:05karmazilla(defmacro f [x] `(binding [i (+ i 2)] (println "i: " i) ~x)) :p
17:06Chousukethat function prints 2 and returns x, which is always 1
17:06Chousukeso you basically call (f 1) thrice
17:07pjb3Right, if you call the second f with (f 3), the bindings start doing stuff
17:10danlarkinhttp://en.wikipedia.org/wiki/Trane Trane seems to be taken
17:34gnuvince_Does anyone know if there's a delay between pushing to github and seeing the change in the repo page?
17:34danlarkingnuvince_: always been instant for me
17:35gnuvince_danlarkin: check this out:
17:35gnuvince_http://github.com/gnuvince/clojure-greatest-least/tree/master
17:35gnuvince_See that it's from 16 hours ago?
17:35danlarkinyes
17:35Chousukegnuvince_: are you sure you pushed it? :)
17:36gnuvince_Now look here: http://github.com/gnuvince
17:36gnuvince_See that I pushed changes not 10 minutes ago?
17:37Chousukeweird. :/
17:38gnuvince_Indeed
17:38gnuvince_And if you clone the repo, you'll get the changes I just pushed.
17:38ChousukeI and you can get to them via the hash
17:38gnuvince_Yes
17:38gnuvince_But it should be my HEAD, should it not?
17:39ChousukeI suppose
17:39Chousukemight want to drop a mail to the github admins.
17:45danlarkinstop by #github
17:45danlarkinI've always received a quick response in there
17:48gnuvince_Asking now
19:17erohtar_danlarkin: are u here?
19:18erohtar_does anyone know what kind of content clojure-json can parse from a file? im having some trouble reading what i think is valid json
19:37danlarkinerohtar_: ping
20:33eeehiyuz
20:45eeei had a macro in mind
20:45eeeif anyone thinks it might be fun to teach how that works
20:45eeewill put it to the test
20:45eee"whenever"
20:46durka42to teach what
20:46eeeis what it is
20:46eeehow to make a macro
20:47eeeit would be shorter than doing "loop" ...if ... recur
20:47durka42well, a macro is basically a function that returns a list, that is evaluated as code
20:47eeeoh
20:48hiredman,(doc doseq)
20:48clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
20:48eeei was thinking a macro is what you did when you want to define a new "form" . . .not just a new function
20:48durka42well, arguments to macros are not evaluated
20:49eeeok
20:49durka42so i could write a macro safe-math and then call (safe-math (/ 1 0))
20:49durka42safe-math could check for division by zero and choose not to run that
20:49eeebut the reason for a macro . . . betfore getting into what it is . . .is to, like, define a new syntax, sort of . . .a new keyword or pattern of keywords, right?
20:50hiredmana keyword is like :foo
20:50eeethats a key
20:50eeei thought
20:50hiredmanso I know what you mean, but you should be careful
20:50eeeok
20:50eeeso safe-math
20:50hiredmanno, that is a datatype called a keyword
20:50eeethat could just be a function
20:50eeewith an if statement
20:51hiredmaneee: no
20:51eeeoh
20:51eeei get it
20:51eeenice example
20:51eeeyou guys are really smart
20:51eee:)
20:52eeeit allows you to look at a list as a bunch of tokens and decide what to do with them. Otherwise it would evaluate the list by assuming the first arg is a function
20:52eeeand you don't have to quote the list
20:53eeei was thinking (safe-math '(/ 1 0))
20:53hiredmanexactly
20:54eeeseems like better documentation to make my function than yours
20:54eeemy function lets you know that I have a chance to do whatever I want with that list
20:55hiredman*shrug*
20:55eeeyour function requires documentation to get that point across
20:55durka42(defmacro safe-math [expr] (if (and (= '/ (first expr)) (some zero? (rest expr))) "careful!" expr))
20:56hiredmaneee: or you just say "any math inside done inside safe math is checked for unsafe operations"
20:56hiredmanand the user of safe math doesn't need to know the details of how it is checked
20:56eeeok, so clojure relies on good documentation
20:56hiredmanthis is not a matter of documentation
20:57hiredmanthis is how computers are made to work
20:57hiredmanabstraction and combination
20:58eeehow would I see safe math in an API?
20:58eee(safe-math x)?
20:58eeewithout the question mark
20:58hiredmanthat seems reasonable to me
20:58hiredmanon the otherhand, on clojure.org/api things that are macros are labeled as such
20:59eeeok
20:59durka42if you call (safe-math (+ 2 3)) you get 5, but if you call (safe-math (/ 1 0)) you get "careful!")
20:59hiredmanclojurebot: seen spooneybarger
20:59clojurebotspooneybarger was last seen joining #clojure, 1 minutes ago
20:59hiredman:P
20:59eeei'm letting this sink in some
20:59durka42aha! you _have_ been playing with onJoin!
21:00durka42all right, i have to go
21:00durka42don't divide by zero
21:00eeeok
21:00eeethanks
21:00hiredman,(/ 1 0)
21:00clojurebotjava.lang.ArithmeticException: Divide by zero
21:00durka42hey!
21:01eee,(print '(/ 1 2))
21:01clojurebot(/ 1 2)
21:01eeeok
21:01eeewhat I thought
21:02eeenow how could I go from that list to get it to execute the first item
21:02hiredmaneval
21:02hiredman,(doc eval)
21:02clojurebot"([form]); Evaluates the form data structure (not text!) and returns the result."
21:02eee,(print eval '(/1 2)
21:02clojurebotEval-in-box threw an exception:Invalid token: /1
21:02eeeoops
21:02eeemeant to back up
21:02hiredmanclojurebot does not allow eval
21:03eee,(print (eval '(/1 2)))
21:03clojurebotEval-in-box threw an exception:Invalid token: /1
21:04hiredmanso the idea is read turns text like "(/ 1 3)" into a data structure like (list '/ 1 3)
21:05hiredman,(list '/ 1 3)
21:05clojurebot(/ 1 3)
21:06hiredmanand eval takes that data structure (a list) and applies the first item in the list to the rest of the list
21:06eee(print (eval '(/ 1 2))) works in my repl
21:06eeeso
21:06hiredmanit should
21:06eeeI can define (safe-math x) but mine expects a quoted list
21:06hiredman,(let [[function & args] (list '/ 1 3)] function)
21:06clojurebot/
21:06eeehow would you know that
21:06hiredman,(let [[function & args] (list '/ 1 3)] (apply function args))
21:06clojurebot3
21:07eeeI could write it as a regular definition
21:07hiredmaner
21:07hiredman,(/ 1 3)
21:07clojurebot1/3
21:07hiredmanhmmmm
21:08hiredman,(let [[function & args] (list '/ 1 3)] args)
21:08clojurebot(1 3)
21:08hiredman,(let [[function & arction args))
21:08clojurebotEval-in-box threw an exception:Unmatched delimiter: )
21:08hiredman,(let [[function & args] (list '/ 1 3)] (apply function args))
21:08clojurebot3
21:09hiredman,(let [[function & args] (list '/ 1 3)] (apply (var function) args))
21:09clojurebotjava.lang.Exception: Unable to resolve var: function in this context
21:09hiredman,(var '/)
21:09clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
21:09hiredman,(var `/)
21:09clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
21:09hiredman,(var /)
21:09clojurebot#'clojure.core//
21:10hiredman,(let [[function & args] (list '/ 1 3)] (apply @function args))
21:10clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IRef
21:10hiredmanhmmm
21:10hiredmanah
21:11eeei'm struggling with this editor
21:11ayrnieu,(let [[function & args] [/ 1 3]] (apply function args))
21:11clojurebot1/3
21:12hiredmanayrnieu: cheater
21:12hiredman,(let [[function & args] (list / 1 3)] (apply function args))
21:12clojurebot1/3
21:13hiredmaneee: what editor?
21:13ayrnieu,(let [[function & args] '(/ 1 3)] (apply function args))
21:13clojurebot3
21:14eeeanyway
21:14eeethis is what I could write: (defn safe-math [quoted-operation-and-params] (first quoted-operation-and-params))
21:14eeethat's not it
21:14eeecut and paste not working
21:14eeearg!!!!!
21:14hiredmanlisppaste8: url?
21:14lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
21:14hiredmanpaste there
21:14hiredmanif it is 3 more then three lines
21:15ayrnieu(defmacro safe-math [expr] (let [e (gensym)] `(try ~expr (catch java.lang.ArithmeticException ~e "careful!")))) (safe-math (/ (- 1 1))) => "careful!"
21:15lisppaste8eee pasted "untitled" at http://paste.lisp.org/display/74187
21:16eeeso basically
21:16eeeI didn't need a macro
21:16eeebut you'd have to know
21:16hiredmanuh
21:16eeeto send in a quoted thing
21:16hiredmanyou still don't under stand
21:16hiredmanunderstand
21:16eeeyou'd use it like this (safe-math '(/ 1 2))
21:17eeeand I argue that that is much better
21:17eeebecause it is self documenting
21:17hiredmanwell
21:17hiredmanyou are wrong
21:17eeethat the callee obviosly has a chance to validate
21:17ayrnieubut you could not say (let [x 2] (safe-math '(/ 1 x)))
21:18eeesure I could
21:18ayrnieucompare with mine, that just wraps a (try ...) around the expression.
21:18eeemy safe-math could throw
21:18eeeif (first ...) is bogus
21:18hiredman...
21:19hiredmaneee: write or
21:20hiredmanor only evaluates its arguments if it needs to
21:20hiredmancan you imagine having to quote every form you try and pass to or?
21:20eeeyou mean there is a macro or?
21:20hiredman,(or (println :a) (println :b))
21:20clojurebot:a :b
21:20ayrnieu,(macroexpand '(or 1 2 3))
21:20clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
21:20hiredman,(or (println :a) :a (println :b))
21:20clojurebot:a
21:20clojurebot:a
21:21ayrnieuhm, works with this build.
21:21eeei think I see
21:21ayrnieuI get: (let* [or__3163__auto__ 1] (if or__3163__auto__ or__3163__auto__ (clojure.core/or 2 3)))
21:21hiredmanarbscht: works at the repl too
21:21hiredmaner
21:21hiredmanayrnieu:
21:22eeeno I don't. still seems like (or) could be a function that takes two booleans.
21:22eeethe booleans could be the result of functions
21:22hiredmaneee: it could be
21:22hiredmanbut if the first function is true, do you need to run the second?
21:22ayrnieuhiredman, I mean that clojurebot dies on ,,(macroexpand '(or 1 2 3)) , which my build of clojure correctly expands.
21:22eeeahhhhhh
21:23hiredmanayrnieu: I know what you meant
21:23hiredmanit works on my repl too
21:23eeehiredman explaind it
21:23ayrnieuah.
21:23eeewith a macro
21:23hiredmanclojurebot has an interal call to macroepxand which maybe the problem
21:23eeeyou can do what you want
21:23eeeyou can intercept the evaluations
21:23eeeyou are sort of like a compiler at that point
21:23hiredmanYes
21:23eeeyou get to decide how evaluation happens
21:24eeelike || in C++
21:24eeeis smart
21:24eeeyou can make custom smarts
21:25hiredmanfirst clojure gets read which turns it into a bunch of data structures, lists mostly
21:25eeeso
21:25eeewholey crap
21:25hiredmanthen macros get a change to alter those data structures, the nthe result gets evaluated
21:25hiredmanYes.
21:25eeethis is big
21:25hiredmanHoly Crap.
21:25hiredmanclojurebot: macros?
21:25clojurebotExcuse me?
21:26hiredmanclojurebot: macros is <reply>Holy Crap.
21:26eeethis is big
21:26clojurebotIn Ordnung
21:26eeecheck this out
21:26eeesee if I'm right
21:26hiredmanclojurebot: how did you respond when you firs learned about macros?
21:26clojurebotHoly Crap.
21:26eeethere's a famous example of a functional quicksort that imperitive types criticize
21:27eeebecause you call filter twice on the partitioning
21:27eeeand make two lists
21:27eeebut
21:27eeeif quicksort were a macro
21:27eeeit could just LOOK like you filtered all less than pivot into one list . . .and all greater than pivot into another
21:28eeethe implementation coud be whatever you want inside the macro
21:28eeehuh?
21:28hiredmanerm
21:28hiredmanyou could just do that with a function :P
21:28eeefilter makes a pass through the whole list
21:28eeeand mkes a sublist of all smaller than pivot
21:28eeefilter makes another pass for all greater
21:29lisppaste8ayrnieu pasted "safe-math" at http://paste.lisp.org/display/74190
21:29eeebut with a macro, it could just be specified AS IF that's what happened
21:29eeemaybe?
21:30eeelike a concat-partitions macro
21:30hiredman...
21:30hiredmaneee: general when manipulating actual datastructures, like stuff to be sorted, a regular function can do it just fine
21:31hiredmanmacros come into their own when you are manipulating the code
21:31eee(concat-partitions (<filter all less than x in list> (x) <filter all greater than x in list>)
21:31eeethe naive implementation of above makes two passes through the list
21:32eeei wonder if macros can avoid that
21:33eeeor maybe you just write a new filter method that returns two things in a list: element1 would be a list of everything that past the filter. element2 would be everything else that failed
21:34eeeIt's be a function that takes a list and a predicate and returns those two lists
21:34eeeeven though I digress. I wonder if I can do that efficiently
21:35ayrnieuyou wonder if you can generate the two lists on the same walk through the list?
21:35eeewell, given that I suck at clojure. I guess I could
21:36eeegonna see
21:36eeeseems like a useful function
21:36eeewould speed up quicksort
21:37hiredman...
21:38hiredmaneee: which year of cs are you in?
21:39eeei don't even remember how to run the repl in netbeans or send code to it
21:39eeewhich year? I'm done with school for right now
21:39eeeMS degree
21:39eeejust using quicksort since I understand it
21:40hiredmanok, just asking because that seems very academic :P
21:40eeeit's an argument folks like to make about why imperitive langs are better
21:41eeeyou can pivot the data in place
21:41eeequicksort is supposed to be an in place algorithm
21:41eeepartitioned in one pass
21:41eeebut with macros
21:41eeei'm wondering if you can specify it however you want
21:41eeebut the macro lets you really do something else
21:42hiredmanclojure is not a pure functional language, so you can do mutable stuff with java arrays
21:42eeeyeah
21:42hiredmanetc
21:42ayrnieu(defn fold2 [f1 acc1 f2 acc2 list] (if (nil? list) [acc1 acc2] (recur f1 (f1 (first list) acc1) f2 (f2 (first list) acc2) list)))
21:42cconstantineclojure newbie here... I just downloaded the latest clojure and I can't get (dotimes ...) to work. Is there a known problem with it, or am I doing it wrong?
21:42ayrnieualthough for a lisp-1 (*spit*), you may want to say 'lst'.
21:43hiredmancconstantine: latest means?
21:43ayrnieuconstantine, how are you doing it?
21:43cconstantineclojure_20081217.zip
21:43cconstantine(def foo 10) (dotimes [i foo] (println "hello"))
21:44cconstantineI get a similar error when compiling ants.clj from the concurrency presentation
21:44hiredman,(dotimes [i 10] (pr i))
21:44clojurebot0123456789
21:44gnuvince_What is the Clojure way of creating new data structures? Using structs?
21:44hiredmancconstantine: what exactly is the error
21:45hiredmangnuvince_: you mean nest data structures?
21:45ayrnieuit macroexpands to (let* [n__3864__auto__ (clojure.core/int bar)] (clojure.core/loop [foo (clojure.core/int 0)] (clojure.core/when (clojure.core/< foo n__3864__auto__) (pr foo) (recur (clojure.core/unchecked-inc foo)))))
21:45ayrnieu(dotimes [foo bar] (pr i)), does.
21:45cconstantineit's several pages, but I think the heart of it is: "java.lang.IllegalArgumentException: recur arg for primitive local: G__2293 must be matching primitive"
21:45hiredmancconstantine: better paste code
21:46hiredmanlisppaste8: url
21:46lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
21:46ayrnieu(well, that turns out not to matter.)
21:46hiredmancconstantine: it does soundlike you may have a badly place recur
21:46lisppaste8cconstantine pasted "untitled" at http://paste.lisp.org/display/74194
21:46hiredmananyway, paste code + exception
21:47gnuvince_hiredman: any kind. For instance, they were talking about finger trees in the Haskell community this week and I was wondering "how would one implement those in Clojure?"
21:47pjb3The docs on http://clojure.org/reader say Keywords "They cannot contain '.' or name classes."
21:47pjb3,({:foo.bar "foo-bar"} :foo.bar)
21:47clojurebot"foo-bar"
21:48hiredmangnuvince_: just nest data structures
21:48cconstantinepjb3: was that for me?
21:48hiredmanpjb3: a lot of that is not enforced
21:48pjb3cconstantine: no, I was just noticing that
21:48cconstantinek
21:48gnuvince_hiredman: does that really work?
21:49pjb3hiredman: so keywords shouldn't contain periods?
21:49hiredmangnuvince_: of course it does
21:49ayrnieuconstatine, your example WFM. Try the latest clojure on git?
21:49hiredmanpjb3: *shrug* a lot of people are using keywords with periods, it seems like the doc is more likely to change then all the written code
21:49cconstantinehiredman: in case it's relavent I'm using MacOSX 10.5.6 nad java 1.5.... I bet I need java 1.6 don't I?
21:50ayrnieuconstantine, 1.5 is fine.
21:50gnuvince_hiredman: so the "logic" of the data structure is encoded not in the data itself, but in the functions defined for it?
21:50cconstantineayrnieu: github?
21:50hiredmanah
21:51hiredmancconstantine: you may want to talk to rhickey are chouser because this looks like a bug. try (def f (Integer. 10))
21:51eeehow do you specify a predicate?
21:51eeetrying to use filter
21:52hiredmaneee: a predicate is any function
21:52hiredmannil is false
21:52hiredmannot nil is true
21:52eee(filter (< 6) mylist)
21:52hiredmanuh
21:52eeethat doesn't work
21:52hiredmanno
21:52hiredmana predicate needs to be a function
21:52eee<
21:52cconstantinehiredman: defining f as an Integer didn't help
21:52eeethat's my function
21:52hiredmanwhat filer is doing there is applying the , function to 6
21:52eeeless than
21:53eeeless than 7
21:53hiredmanand try to use the result to filter the list
21:53hiredmanbut the rresult of (< 6) is not a function
21:53hiredman,(> 6)
21:53clojurebottrue
21:53hiredmanso (> 6) is not a predicate
21:53gnuvince_,(fn [x] (> x 6))
21:53clojurebot#<sandbox$eval__816$fn__818 sandbox$eval__816$fn__818@f2ea42>
21:53hiredman^- that is function
21:54hiredmanso it is a predicated
21:54hiredmanpredicate
21:54eeei see
21:54cconstantineayrnieu: I'm having a hard time finding the latest clojure on git, or at least a definative clojure on git
21:54hiredman(small keyboard)
21:54eeemine is fewer character :)
21:54hiredmanclojurebot: google codE?
21:54clojurebotHuh?
21:54hiredmanclojurebot: google code?
21:54clojurebotPardon?
21:54gnuvince_cconstantine: use the subversion repos from Google Code
21:54cconstantineok
21:54hiredmanclojurebot: where isthe svn?
21:54clojurebotsvn is http://clojure.googlecode.com/svn/trunk/
21:54ayrnieuconstantine, try starting at http://clojure.org/
21:54hiredman^-
21:55cconstantineayrnieu: right, that points to a svn repo ;)
21:55hiredman~ latest
21:55clojurebotlatest is 1231
21:55hiredmanis the latest rev or close to
21:59cconstantineit builds to a clojure-slim.jar
22:00cconstantineok, that works
22:01cconstantineah, the excitement of a young language :)
22:01pjb3cconstantine: there should be a clojure.jar too
22:01pjb3I don't know what clojure-slim.jar is for
22:02cconstantineoh, there is... 'ls' was hiding it?
22:02cconstantineok, clojure.jar works too
22:03cconstantinethanks :)
22:04pjb3cconstantine: np, are you just getting started with Clojure?
22:04cconstantineyeah
22:04cconstantineI've done one minor project in CL and kinda liked it. Clojure looks much better :)
22:04pjb3cool, what other languages are you familiar with
22:05cconstantineC/C++ (it's what I do for a living), some python and perl
22:05pjb3yeah, Clojure is more elegant than any other Lisp, such as CL or Scheme, IMO
22:06cconstantineI might be able to argue that Scheme is more "pure" or something like that... but I sure as hell wouldn't want to make anything worthwhile in it
22:06pjb3Yeah, I could see that argument about Scheme
22:07cconstantinebefore my CL project I decided on Scheme because it looked better, but I couldn't get any 'real' work done in it
22:07pjb3It is less complex, has less syntax, etc
22:07pjb3yeah, exactly though, there's just a lot of stuff you have to build yourself to use Scheme for anything
22:07pjb3Good language to learn Lisp in though
22:07cconstantineI'm a little concerned that multi-methods are too complicated in clojure, but I'll fight that when I get there
22:08pjb3They're not that bad
22:08cconstantineyeah... I can see how it's perfect for an undergrad lisp course
22:08cconstantineI think I should know more about the language before I tackle multi-methods
22:08pjb3Any you can write a lot of productive code with Clojure without every writing a macro or a multimethod
22:08cconstantineyeah
22:08pjb3which are the two most complicated things in Clojure
22:08pjb3Macros are definitely more complicated than multimethods
22:09cconstantinehehe
22:09cconstantineI fell in love with macros from the CL project
22:09cconstantineI keep thinking at work: "Oh, this would be a prime case for macros!.... on right, C++"
22:09pjb3You should get the book from http://pragprog.com, it does a pretty good job of explaining the language
22:10eeedo is used for side effects, right?
22:10pjb3Oh, well, if you understand macros than you are ahead of the game then :)
22:10pjb3eee: Yeah, it's kind of like let without an bindings
22:10eee,(do (print "hi") (print "yo"))
22:10clojurebothiyo
22:11pjb3,(println "Can clojurebot print?")
22:11clojurebotCan clojurebot print?
22:11pjb3,(do (println "foo") (println "bar"))
22:11clojurebotfoo bar
22:11pjb3huh
22:11eeeso I have an if clause . . . .put in one list if pass pred . . . else put in other list if fail pred. then recur no matter what. so the if and recur can be in a do?
22:13pjb3what is the recur for, is it in a loop or recursively calling the function?
22:13eeeyup
22:13eeei'm making a single pass function that returns two lists when given a list
22:14eeethings that pass predicate in list 1
22:14eeethings that fail in list 2
22:14pjb3You might want to look at split-with
22:15pjb3,(split-with even? [1 2 3 4 5])
22:15clojurebot[nil (1 2 3 4 5)]
22:15pjb3so much for that
22:15pjb3That's not the function I want thinking of
22:16eeeso someone wrote it?
22:16eeeno matter it is a challenge
22:16pjb3No, there's a built in function that does it
22:17pjb3maybe it's in clojure-contrib
22:17eeehow do I return a list in my else clause
22:17eeequote it?
22:17eeei have two lists l1 and l2
22:17eeetime to return them in a list
22:18pjb3eee: do you want to return a list of two lists?
22:18eeeok
22:18eeei need help
22:19eeewhere do I past my code
22:19ayrnieueee: (defn fold2 [f1 acc1 f2 acc2 list] (if (nil? list) [acc1 acc2] (recur f1 (f1 (first list) acc1) f2 (f2 (first list) acc2) list)))
22:19hiredmanlisppaste8: url?
22:19lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:19pjb3http://paste.lisp.org
22:19hiredman,(doc split-with)
22:19clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
22:19eeeyou wrote that aym?
22:19ayrnieueee: (defn fold2 [f1 acc1 f2 acc2 list] (if (nil? list) [acc1 acc2] (recur f1 (f1 (first list) acc1) f2 (f2 (first list) acc2) (rest list))))
22:20ayrnieuthe 'rest' is probably important.
22:20hiredman,(sort-by even? [1 2 3 4 5])
22:20clojurebot(1 3 5 2 4)
22:20pjb3hiredman: that doesn't do what he's talking about
22:20eeei see
22:20hiredman,(split-with? even? (sort-by even? [1 2 3 4 5]))
22:20clojurebotjava.lang.Exception: Unable to resolve symbol: split-with? in this context
22:20eeeclose tho
22:20hiredman,(split-with even? (sort-by even? [1 2 3 4 5]))
22:20clojurebot[nil (1 3 5 2 4)]
22:21hiredman,(split-with even? (sort-by odd? [1 2 3 4 5]))
22:21clojurebot[(2 4) (1 3 5)]
22:21hiredman:P
22:21eeeaym . . . that's close, too
22:21eeebut I would hide the storage
22:21eeeleme cutnpaste
22:21eeehang on
22:22lisppaste8eee pasted "filtrem" at http://paste.lisp.org/display/74198
22:22pjb3,(let [f even? s [1 2 3 4 5] [(filter f s) (filter (complement f) s)]))
22:22clojurebotEval-in-box threw an exception:Unmatched delimiter: )
22:22eeeit ain't quite right, but I bet it is close
22:22pjb3,(let [f even? s [1 2 3 4 5] [(filter f s) (filter (complement f) s)])
22:22clojurebotEval-in-box threw an exception:Unmatched delimiter: )
22:23pjb3,(let [f even? s [1 2 3 4 5]] [(filter f s) (filter (complement f) s)])
22:23clojurebot[(2 4) (1 3 5)]
22:23eeeaha
22:23eeebut that's doible pass
22:23eeelook at my code
22:23pjb3clojure.contrib.seq-utils/separate
22:23eeeone pass
22:24ayrnieueee, if you understand fold2 above, you can verily easily write your function.
22:24eeei wouldn't know how to look at that contrib code
22:25eeei see now
22:25eeeaym
22:25eeecan you tell me where I went wrong with mine? I see yours. it's nice
22:26pjb3eee: you need to quote the final list that you return
22:26pjb3er, not quote, list
22:26ayrnieu,(if (list) 1 2)
22:26clojurebot1
22:27pjb3,(list '(1 2 3) '(4 5 6))
22:27clojurebot((1 2 3) (4 5 6))
22:27pjb3but the problem is the lists are empty
22:27eeei see
22:27eeei can't do that
22:27pjb3because conj returns a new list
22:27eeeseveral probs
22:27eeeone
22:27eeeyou use []
22:27eeeto return new list
22:27eeeI thought that was for vector
22:28ayrnieuI return a vector of the two lists, that is all.
22:28eee[acc1 acc2]
22:28pjb3yeah, vector, list, they can be used pretty interchangably
22:28ayrnieuYes, at the very end.
22:28eeecould you say (list acc1 acc2)
22:28ayrnieuYou could.
22:28eeeok
22:28pjb3yes, that would give you a list of two lists
22:28eeethat's how you return list, then
22:29eeecause (acc1 acc2) i don't think would work
22:29ayrnieufold2 is a general function; it's something you'd write as soon as you said "I want to build two lists from two functions as I walk a list, one-pass", before you finish saying why you want to do this.
22:29pjb3eee: no, that will try to call acc1 as a function, passing it acc2
22:29eeemy second problem is that i have a scope problem. I'm not actually adding to l1 and l2
22:29pjb3eee: right
22:31eeeyou send as many things to recur and you have defined in the loop
22:32eeeand only the first time are they bound to the stuff in brackets
22:33ayrnieu(fold2 (fn [a b] (+ a b)) 0 (fn [a b] (* a b)) 1 (list 1 2 3 4 5)) => [15 120]
22:36eeenow this version should accumilate! grrrrrr will cut n past
22:36lisppaste8eee pasted "untitled" at http://paste.lisp.org/display/74201
22:37burkelibbeySo my distributed computing class handed out a bunch of Sun SPOTs to us. Does anyone know anything about running Clojure on Squawk or J2ME? (I'm a bit of a Java noob)
22:37ayrnieu(fold2 (fn [a b] (cons a (cons "," b))) [] (fn [a b] (str a b)) "" (list "hello" "there" "mon" "frere")) => [("frere" "," "mon" "," "there" "," "hello" ",") "freremontherehello"] ; reverse is useful.
22:37eeei think I know
22:38burkelibbeyIt complains about java.util.concurrent.Callable not being available. Is there any way to deal with that, or should I just not bother? :P
22:38eeethat is quite generic
22:38hiredmanburkelibbey: j2me is very limited
22:38eeemine only takes a pred and makes one as the NOT stuff
22:38hiredmanand j2me what it does have is bits and pieces from jdk14
22:39hiredmanayrnieu: I'd suggest conj instead of cons
22:40burkelibbeyHmm, ok. Too bad; embedded clojure would have been awesome.
22:40hiredmanburkelibbey: it may work
22:40hiredman*shrug*
22:41burkelibbeySo if it doesn't have java.util.concurrent.Callable, is there any way for me to bundle that in anyway? (recall: burkelibbey is a java noob)
22:42lisppaste8pjb3 pasted "filtrem" at http://paste.lisp.org/display/74202
22:44lisppaste8pjb3 annotated #74202 with "updated" at http://paste.lisp.org/display/74202#1
22:44eeegot it
22:45eeei need a window
22:45lisppaste8eee pasted "untitled" at http://paste.lisp.org/display/74203
22:45hiredmanclojurebot: fold2 is (defn fold2 [f1 acc1 f2 acc2 list] (if (nil? list) [acc1 acc2] (recur f1 (f1 (first list) acc1) f2 (f2 (first list) acc2) list)))
22:45clojurebotYou don't have to tell me twice.
22:45eeelooks like folks beat me to it
22:45eee:(
22:46eeei'm gonna post it to the group
22:46pjb3eee: Using vectors makes things show up in the right order
22:47eeei'll just say "folks on the irc helped" . . . .oh, we car about order? I can do that
22:47hiredmanayrnieu: you a haskeller?
22:47eeemine is in the right order
22:47eeetest it
22:47pjb3eee: I agree
22:47pjb3I was just pointing that out
22:47pjb3Mine isn't, because I would using lists like you were in the original
22:47eeeconj makes it in the right order
22:48pjb3not if you use lists though
22:48eeereally?
22:48pjb3because conj'ing to a list puts it on the front
22:48eeeconj works differently?
22:48eeeoh
22:48eeei see
22:48pjb3conj puts the items on the sequence wherever it is most efficient too
22:48pjb3lists grow at the front, vectors grow at the end
22:48eeegonna go afk for a bit. thanks for the help
22:49eeei still didn;t learn how to write the harry macro I'm interested in. maybe next time
22:49eeealso I'm gonna suggest this in the contribs, if it makes sense
22:49eeeanyone want credit?
22:50eeepjb3 or ayrnieu
22:50eeei'll just leave window open
22:50eeebe back
22:50pjb3looks like you got it
22:51pjb3it's already in contribs as separate, but as you said, this is one pass, so possibly more efficient
22:53lisppaste8pjb3 annotated #74203 with "separate, more idiomatic version of filtrem" at http://paste.lisp.org/display/74203#1
22:55pjb3eee: BTW, if you time your version and the one in seq-utils, the one in seq-utils is faster
22:57pjb3user=> (time (count (separate even? (range 1 1000000))))
22:57pjb3"Elapsed time: 1226.57 msecs"
22:57pjb3user=> (time (count (clojure.contrib.seq-utils/separate even? (range 1 1000000))))
22:57pjb3"Elapsed time: 0.058 msecs"
22:57pjb3Someday I'll understand that :)
23:10ayrnieuhiredman - God no.
23:11hiredmanok
23:11hiredmanjust curious
23:26eeehow could it be faster?
23:26eeewhat did the code look like again?
23:26eeeoh
23:26eeeI guess less branching?
23:26gnuvince_Are the two filters the most efficient way to write separate?
23:27eeeyou implemented separate as filtrem
23:27eee?
23:28eee,(take 5 (rand 400))
23:28clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Double
23:29eee,(take 5 (list (rand 400)))
23:29clojurebot(261.8843254985269)
23:29eeei don't know how to make a random list
23:30eeelet's look at my google group info
23:31eee,(take 5 (repeatedly (rand 400)))
23:31clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn
23:31eee,(take 5 (repeatedly #(rand 400)))
23:31clojurebot(288.27871463886095 107.37500695219629 230.34487025923286 34.925482882785985 4.417318672644388)
23:31eee,(take 5 (repeatedly #(rand-int 400)))
23:31clojurebot(376 155 189 317 334)
23:32gnuvince_,(replicate 5 (rand 400))
23:32clojurebot(304.36713394163394 304.36713394163394 304.36713394163394 304.36713394163394 304.36713394163394)
23:32gnuvince_hmm, right
23:33hiredman,(map #(%) (replicate 5 #(rand 400)))
23:33clojurebot(151.64976810686377 263.74575502229595 131.77614419133334 24.905270563145486 188.07390169071687)
23:34eeei wonder if it's because mine uses vectors which could have a slower conj
23:34eeewhat's the contrib implementation?
23:35hiredmaneee: why would conj on vectors be slower?
23:35eeewell, when you run out of room on a vector
23:35eeeyou have to copy the whole vector somewhere else
23:35hiredmana vector is not an array
23:35Chouseractually...
23:35eeeso you can guarantee random access in constant time
23:36eeei vector has contiguous memory probably
23:36Carkclojure vectors are not like that
23:36eeeso conj is probably slower than on a list
23:36Carkhow could they be persistent if they were ?
23:36gnuvince_Clojure vectors are not contiguous
23:36eeeok
23:36eeetrue
23:36eeebut
23:37eeei've seen persistent implementations of vectors
23:37eeeand chincks are contiguous
23:37eeechunks
23:37Chouserclojure vectors are made of chunks, each an array of up to 32 items
23:38eeewell can we test the time to conj 100000 things into a vector
23:38eeevice into a list?
23:39gnuvince_,(time (dotimes [_ 100] (let [xs []] (for [e 100000] (conj xs e)))))
23:39clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
23:39Chouseradd an item to a vector of 31 items, I think it copies 31 of them.
23:39eeeoh and that seperate isn't as concise as it could be
23:39gnuvince_,(time (dotimes [_ 100] (let [xs []] (dotimes [e 100000] (conj xs e)))))
23:39clojurebot"Elapsed time: 1867.717 msecs"
23:39eeeit uses (filter (comkplement)
23:39eeeinstead of remove
23:39gnuvince_,(time (dotimes [_ 100] (let [xs ()] (dotimes [e 100000] (conj xs e)))))
23:40clojurebot"Elapsed time: 1382.68 msecs"
23:40Carknearly constant time it seems
23:40eeewell you can't tell much from one time, but the times aren't way off like they were with my thing
23:44eeetesting right now
23:44temy name is Akmar and i am 7 yrs old and dad tied me in the basement and tell me to have all dos game by 7 o clock or i get no food plz help
23:46eeelooks like i'm doing too big a test. computer is sweating
23:46ayrnieute, things will get better after you fail to produce a game for a few days.
23:46teayrnieu: *nod*
23:47ayrnieute - but try something simple, like sokoban.
23:52ayrnieumy $CLASSPATH includes a path to clojure-contrib.jar , but how do I load it into clojure?
23:53eeei lost the code I was messing with when I killed netbeans
23:54eeedrat
23:55Carkayrnieu : (require 'clojure.contrib.math)
23:55eeei don't trust the timing
23:56eeei'm scaling things up by 10 times
23:56eeeand getting faster timres
23:56eeetimes
23:57eeeit must not be timing what I think
23:57Carkhotspot compiles while you use your functions
23:57eee,(time (take 5000 (repeatedly #(rand-int 3000))))
23:57clojurebot(730 1844 1225 2097 699 160 2801 621 1532 1853 592 1174 2769 900 2775 2162 958 299 1535 2612 165 1963 2548 2667 311 1968 214 1182 912 2875 2261 780 58 2001 2863 2554 2024 1732 718 1876 659 102 1471 2546 1648 1973 2607 725 947 1252 2326 1804 1075 623 88 2514 608 1294 2346 1219 2004 256 2567 2426 2025 1513 952 2142 2221 657 265 697 1518 1080 917 214 2597 1956 2912 1844 2758 988 422 1346 49 702 1655 1494 1879 2839 284 2191 1
23:57clojurebot"Elapsed time: 0.658 msecs"
23:57Carkyou might need to run the test repeatadly
23:57eee,(time (take 5000 (repeatedly #(rand-int 3000))))
23:57clojurebot(962 68 590 2174 2215 2482 1765 1831 2152 603 385 2903 98 2715 455 1458 2209 2832 1811 2882 2980 2257 441 2334 1829 2655 171 34 2425 1255 1919 887 1178 2930 1720 1712 1282 2033 396 2538 2881 952 2187 1162 330 2381 1801 296 167 367 2175 1284 232 1124 852 2455 2438 1642 142 1757 984 1964 269 347 1300 971 436 1333 2721 2344 2182 1816 2829 1214 2595 1855 571 2824 2815 1861 601 277 1877 1322 2932 1226 1287 2625 1756 1016 1732
23:57clojurebot"Elapsed time: 0.568 msecs"
23:58eee,(time (take 500 (repeatedly #(rand-int 3000))))
23:58clojurebot(880 1117 1591 717 1933 1826 1376 736 1628 1162 1831 2945 2650 982 340 1756 735 2544 1026 1773 935 559 1914 702 428 744 262 1118 1562 1287 2736 1606 2964 1698 1513 2462 2998 2603 1550 2362 2434 42 2102 2961 1067 1827 1165 1556 1067 2475 1797 2474 1139 1177 2312 2896 1044 114 28 2331 777 372 1769 1948 1624 1458 427 382 1463 1302 1817 588 2080 1336 1667 2652 822 1034 2880 2367 2752 1964 2303 650 1498 1130 2939 2719 216 1967
23:58clojurebot"Elapsed time: 0.535 msecs"
23:58eeei can run it 1000 times more
23:58eeeand it will run for a long
23:58eeetime
23:58eeelong
23:58eeelong
23:58eeetime
23:58Carkwell
23:58eeeand then get same timing
23:58Carkyou're mesuring the speed of the clojure compiler
23:59ayrnieuCark - thanks. That clojure.contrib.math actually fails for me because it redefines 'mod', but I get the pattern.
23:59eeethe computer sits and hangs for many seconds
23:59eeeand then I get subsecond time printed out?
23:59ayrnieu( java.lang.Exception: Name conflict, can't def mod because namespace: clojure.contrib.math refers to:#'clojure.core/mod (math.clj:118) )
23:59Carkah i guess they added it recently