#clojure logs

2009-04-16

00:02montyi see, thanks
01:13HecktorAny compojure aces awake?
04:03lepassiveis clojure and NetBeans 6.7 still not fixed yet ?
04:04Rayneslepassive: I believe they are focusing on fixing all the problems they have with 6.5 first.
04:05lepassiveRaynes, but it still not good to keep 2 instances of netbeans on the PC, what are the other options ? lightweight and powerful alternative ?
04:06RaynesIs 6.7 really that great? :|
04:07lepassiveRaynes, yes it's i think it's one of the best versions of netbeans ever released
04:12AWizzArdlepassive: you could join the Enclojure team and make Enclojure work with 6.7. I think they would love to get more support!
04:13Rayneslepassive: They put out new releases on around a monthly basis.
04:13lepassiveAWizzArd, that would be the case if i'm a netbeans developer
04:14RaynesOh I see.
04:14lepassiveRaynes, I hope so
04:14RaynesThe problem is with Netbeans, not Enclojure. They are waiting to see if the NetBeans team will fix it, if not they are going to do a workaround.
04:15lepassiveRaynes, netbeans is turning big fat :S
04:18lepassiveBTW anyone checked that ? http://www.lambdabeans.org/
04:30eevar2lepassive: ligthweight & powerful would be emacs+slime or vim(clojure)?
04:30lepassiveeevar2, I'll give it a shot until Enclojure is fixed thanks alot!
04:31eevar2unfortunately, you get arcane & obscure along with lightweight & powerful ;)
05:48powr-tocWhat paste bin do you guys use? Is there one with clojure syntax highlighting?
05:50Holcxjolisppaste8: where?
05:50HolcxjoBah
05:50Holcxjolisppaste8: where
05:51HolcxjoTo use the lisppaste bot, visit http://paste.lisp.org/new and enter your paste. Be sure to select the right channel!
05:57powr-tocWhich colouriser highlights clojure code the best?
06:07noidiis there a function to check if a variable is a number or not?
06:07noidisomething like num, but just returning true or false
06:08noidiah, number?
06:09noidinum and number? but no num? or number"
06:09noidithat kind of sucks :P
06:10Raynes,(number? 2)
06:10clojurebottrue
06:10noidi,(num 2)
06:10clojurebot2
06:11noidi,(num? 2)
06:11clojurebotjava.lang.Exception: Unable to resolve symbol: num? in this context
06:11noidi,(number 2)
06:11clojurebotjava.lang.Exception: Unable to resolve symbol: number in this context
06:11Raynes(defn num? [x] (number? x)) :)
06:13AWizzArd,(number? 15)
06:13clojurebottrue
06:48RaynesMorning rhickey.
06:50rhickeyhey
07:24lisppaste8powrtoc pasted "Clojure Alphabet Diamond" at http://paste.lisp.org/display/78674
07:25powr-tocThe above is a simple programming exercise which I implemented in clojure... Does anyone have any suggestions on how to make it more idiomatic readable and terse?
07:26powr-tocI'm also still not 100% sure of the clojure/lisp formating conventions... so any suggestions would be great! :-)
07:27antifuchslooks good to me
07:27antifuchs(I've seen common lisp beginner programs that looked way worse (-:)
07:28antifuchs(e.g. mine) (:
07:29ChrisFtoo bad that someone' can't put a surface syntax onto clojure
07:34powr-tocantifuchs: thanks... clojure's my first lisp (excluding emacs lisp tinkering)... I'm not sure it's as lazy as it could be...
07:34powr-tocI'd be interested to see other solutions
07:34ChrisFit's probably better not even to look at CL solutions as examples
07:35antifuchsChrisF: why?
07:35ChrisFCL is warty
07:35antifuchsChrisF: let's not go ther
07:36ChrisFagreed
07:37ChrisFi'm amazed at the play that clojure is getting
07:37ChrisFespecially from the java folks, who tend to be conservative
07:38powr-tocChrisF: agreed... Though I'm perhaps more surprised more by the lisp folk... who think CL/scheme is superior to everything! clojure rocks! :-)
07:39ChrisFi think when the old guard at the last lisp conference gave the nod to clojure, it made a difference
07:40antifuchspowr-toc: I don't think anyone who has worked sufficiently long with any lisp and any one other language will find lisp winning in all cases
07:40antifuchsbut oh well, there are fanatics.
07:40ChrisFwell, you have to deal with the VM you have
07:42ChrisFfor me it's not even about concurrency at this time, but sequence unification
07:43ChrisFand i need a SLIME-like repl to script with
07:43powr-tocCan anyone think of any ways to eliminate the flatten call in my Alpha-diamond paste?
07:44ChrisFso what do we have on the web front-end front? enlive and...?
07:45antifuchspowr-toc: what do you get without the call to flatten?
07:45antifuchsooh, lists of char-seqs. got it.
07:45antifuchspowr-toc: you could print each of them in a loop (:
07:49powr-tocantifuchs: I thought about that but I'd rather keep it terse...
07:49antifuchswell, then that looks ok to me, I think
07:54powr-tocWhat's the best way to test for laziness in a function? I've been throwing in side-effects or Thread/sleeps at later values and then only take'ing a handful of items from the seq... surely there's a better way!
08:12Raynes(defn != [x y] (not= x y)) ; I am complete.
08:13durka42#define != not=
08:13Raynesdurka42: I hate you :(
08:14durka42using the c preprocessor on clojure files would be such a bad idea
08:14RaynesWhy would anyone even think of suck a thing. @_@
08:15greghwhat an appropriate typo
08:16AWizzArdWhy not (def != not=) ?
08:18RaynesAWizzArd: Because I like doing things the complicated way.
08:31cemerickI seem to remember rhickey saying that ! might be used for future syntax...
08:31cemerickor, symbols starting with !
08:31cemerickRaynes: in any case, not using (def != not=) will cost you an extra method invocation each time through.
08:37rhickeyit's /= in CL
08:37rhickey!= is kind of c-derived
08:38cemerickThere's always ? (very easily type-able on mac keyboards (option-=))
08:38cemerickASCII is so 20th-century ;-)
08:40gnuvinceWhat's the problem with not=?
08:40AWizzArdMaybe we can have ? instead of fn? It is very easy to type with the NEO layout ;)
08:41Raynesrhickey: I know, it's fine. I just like !=.
08:42rhickeyalso, if ! is only used on side-effecty things, you can make it red or something in your editor, or search for it
08:43cemerickgnuvince: those three chars are *critical* ;-)
08:45gnuvincecemerick: I see
08:45gnuvinceI have a graph for that...
08:45gnuvinceor had a graph
08:45gnuvincecan't find it anymore
08:46gnuvincebasically, it was the first quadrant of the 1/x equation with X being the importance of a topic in computer programming (from not important at all to infinitely important) and Y being the amount of discussion it generates
08:47gnuvinceAh
08:47gnuvincegot it
08:47gnuvincehttp://www.flickr.com/photos/gnuvince/2944227285/
08:47antifuchscemerick: you could even say that one-character functions are diacritical.
08:47cemerickI actually hardly ever think of not= -- usually, I just use = and arrange my if clauses appropriately, or use (remove #(= ..)) instead of (filter #(not= ..))
08:48cemerickgnuvince: very nice :-D
08:49gnuvinceI drew that following a large debate in a programming channel about whether ++x was more efficient than x++
08:49antifuchsgnuvince: heh
08:49gnuvince6-7 guys going at it for over an hour.
08:49gnuvinceBiggest waste of time ever
08:49antifuchs(if it was 6-7 machines, concurrently benchmarking...)
08:50gnuvinceantifuchs: even then, if x++ is your application's bottleneck, either you're the best programmer I've ever seen or your program does nothing.
08:50AWizzArdI often find myself to use if-not instead of (if (not= ..)). I like it if the very short case of if comes first, and in the else block the longer block follows.
08:51antifuchsgnuvince: true. still, for settling a performance argument, nothing is as effective as a benchmark
08:51cemerickright, yes, I <3 if-not
08:51antifuchs(you could plot that, too, I guess) (-:
08:52powr-tocIs there a clojure function to raise a single var into a sequence, unless it's already a sequence?
08:52rhickeyI think numbers should be objects, we should add infix syntax for methods calls, and then you could say (42.=.negate x)
08:54rhickeypowr-toc: no seqify/setify yet, recently wrote the latter in some library code
08:54cemerickwho's going to be the first one to twitter: "we should add infix syntax for methods calls" - R. Hickey
08:55rhickeyhah
08:56cemerickhey, what's the point of being a public persona if you're not going to get quoted out of context? :-)
08:57Rayneshttp://xkcd.com/371/
08:59cemerickrhickey: BTW, +10 for me on metadata on fns (issue 90). Right now we're doing stuff like {:type :foo :source :blah :fn (fn [] ...)}
08:59rhickeycemerick: would all of your use cases be satisfied if there was no with-meta for fns, i.e. metadata supplied once only on creation?
09:00powr-tocrhickey: if I was to write such a function in the interim, what would be the best sequence type to use in the case where the argument isn't a coll? list or vector?
09:01rhickeypowr-toc: you probably don't actually want seqify, but both listify and vecify instead
09:01powr-toccool
09:01cemerickrhickey: I *think* so, at least right now. I can definitely see us wanting to assoc additional metadata in the future as a fn bounces along through whatever queues we have going, though.
09:01rhickeyor generic (collify [] x)
09:02rhickey(collify #{} y) (collify () z)
09:05rhickey(collify set? hash-set x) (collify seq? list y) (collify vec? vec z), i.e. (collify pred ctor val)
09:34AWizzArdI would like to have the path of the current *file* as well as all sub-paths of it. Example: /home/wizz/hg/src/hallo.clj ==> ("/home/wizz/hg/src/", "/home/wizz/hg/", "/home/wizz/", "/home/").
09:34AWizzArdCurrently I am doing something like (take-while identity (reductions (fn [x _] (.getParentFile x)) (.getParentFile (File. *file*)) (cycle [0])))
09:34AWizzArdOr maybe the slightly longer (loop [f (.getParentFile (File. *file*)), result ()] (if-not f result (recur (.getParentFile f) (conj result f))))
09:37AWizzArdoh, in my example I forgot to include "/"
09:49AWizzArdSomething like a (reduce-while #(.getParentFile %) (File. *file*)) that I have overlooked so far?
09:50kotarakHere a lazy seq approach:
09:50kotarak(defn path-seq
09:50kotarak [file]
09:50kotarak (lazy-seq
09:50kotarak (if-let [pfile (.getParentFile file)]
09:50kotarak (cons file (path-seq pfile))
09:50kotarak (list (java.io.File. "/")))))
09:51kotarak,(let [path-seq (fn path-seq [file] (lazy-seq (if-let [pfile (.getParentFile file)] (cons file (path-seq pfile)) (list (java.io.File. "/")))))] (path-seq (java.io.File. "/home/wizz/hg/src/hallo.clj")))
09:51clojurebot(#<File /home/wizz/hg/src/hallo.clj> #<File /home/wizz/hg/src> #<File /home/wizz/hg> #<File /home/wizz> #<File /home> #<File />)
09:52AWizzArdYes, also nice. I just hoped I overlooked something like reduce-while.
09:52kotarakAlso shorter:
09:52kotarak(defn path-seq
09:52kotarak [file]
09:52kotarak (lazy-seq
09:52kotarak (when file
09:52kotarak (cons file (path-seq (.getParentFile file))))))
09:52AWizzArdIt had not shall be - Es hat nicht sollen sein.
09:53kotarakhehe
10:14chessguy_workok, i'm trying to understand this snippet: (with-open stream (. url (openStream)) ... )
10:14chessguy_work(i've left a bit out)
10:14chessguy_workthe result of opening the stream gets bound to 'stream'?
10:16chessguy_work(i don't even get the docs for with-open at http://clojure.org/api#toc607
10:20chessguy_work,(macroexpand (with-open stream (foo) (bar)))
10:20clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: with-open requires a vector for its binding
10:20chessguy_work,(macroexpand '(with-open stream (foo) (bar)))
10:20clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: with-open requires a vector for its binding
10:40Chousukehm
11:04cemerick~max
11:04clojurebotmax people is 164
11:05cemerickI think the channel has plateued.
11:05AWizzArdSeems so. For now :)
11:05cemerickSeems to be a comfortable zone, IMO.
11:05AWizzArdI think when the book comes out and when there is an official 1.0 version things will change.
11:05kotarakIndeed it is a comfortable zone. :D
11:06rsynnottis this the pragprog book?
11:06cemerickyeah. I think the 10/1 relationship between the group and the channel is just going to break down even further, though.
11:06bstephensonAWizzArd: I hope you clojure experts will be ready for all of us newbies when the book and 1.0 come out.
11:06cemerickirc doesn't scale :-)
11:09cemerickI don't think we've seen any real noobs yet. When the book hits, there will be a surge in people whose only experience is Java, and maybe ruby or python.
11:09cemerickThat'll be challenging. I think most people on the group and here have *some* lisp exposure prior to arriving.
11:20kotarakIndeed, Scheme. In particular scsh.
11:21cemerickhrm, a clojure shell....?
11:21kotarakWould be nice indeed, but I found that I don't really feel the need to script in Clojure...
11:23cemerickugh, every time I do *any* scripting, I start thinking about the notion of cramming scheme into my head well enough to use scsh.
11:29kotarakscsh is actually very nice piece of software. And scripting can be done very well.
11:30kotarakAlso one can learn a good macro style from them.
11:30kotarak... and the end Scheme isn't so much different from Clojure...
11:30cemerickThat's what always stopped me from learning scheme more than I did -- I hit the macro systems and lost the thread.
11:31cemerickwell, I worry about trying to become too proficient in two languages that have such slight differences. I can see myself writing scheme in clojure and vice versa without realizing it.
11:33kotarakWell it's more like pattern matching. It's not that hard when one gets his head around it. It also features automatic gensym and stuff...
11:33kotarakAlthough I'm not up to date with R6RS.
11:34kotarakWhat makes a big point for Clojure is the easy integration with Java and hence the good initial library situation.
11:34kotarakThat's was my main road-block with scsh.
11:34RaynesThe hell with Scheme, we can has Clojure.
11:34cemerickdoes define-syntax and friends have any concrete benefits over clojure's macro system, given the latter's hygiene?
11:34gnuvinceWhere do you think Clojure would be if Scheme hadn't blessed us with its influence :)
11:35Raynesgnuvince: I'm not dissing Scheme, but Clojure is teh secks.
11:35Raynes<3
11:36kotarakcemerick: I think syntax-quote and define-syntax are quite similar. The latter is also hygienic and was already so in R5RS. I haven't used it for some years now, but I remember it equally powerful to syntax-quote. I guess, the two systems just look a bit different but in the end do the same job equally well.
11:42ChousukeI haven't learned scheme's macro system, but looking at some examples in wikipedia, it's far from intuitive :/
11:43cemerickyeah. I spent a couple of days with define-syntax two summers ago. It didn't go well. :-/
11:43cemerickor, :-(
11:44cemerickI'm easily 4x as good as I was then though, so maybe another swing at it is warranted.
11:45ChousukeI like syntax-quote because it maintains the simplicity of CL macros, and is reasonably hygienic. it's pretty difficult to make a badly behaving macro
11:45Chousukeaccidentally, that is. :)
11:46kotarakdefine-syntax is like some kind of pattern matching. The arguments are matched against patterns. The pattern that matches gives the expansion of the code, which is used.
11:52kotarakAnd it automatically "qualifies" free parameters like `foo does, and bound parameters are automatically gensym'd to avoid clashes.
11:53kotarakAll in all very similar to syntax-quote, while that makes it easier to point the gun at yourself...
12:33dysingermonin'
13:02hiredman,(class (seq "foo")
13:02clojurebotEOF while reading
13:02hiredman,(class (seq "foo"))
13:02clojurebotclojure.lang.StringSeq
13:02hiredman,(ancestors clojure.lang.StringSeq)
13:02clojurebotjava.lang.NoClassDefFoundError: clojure/core$ancestors__4862$fn__4865
13:02hiredmanzouch
13:15RaynesI'm watching an argument about why "1 + 1" doesn't logically equal 2.
13:16Chousukehmm.
13:16RaynesIt just ended with a banning.
13:17rabidsnailHello all. Noob here. I was trying to run the jogl tetrahedron example (http://tinyurl.com/ck4rmw), and when it imports '(javax.media.opengl.glu GLU) I get "java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper (NO_SOURCE_FILE:0)".
13:17cp2lol
13:17cp2rabidsnail: gluegen needs to be in the classpath
13:18Raynesrabidsnail: It's not in your REPL namespace.
13:18Raynesclasspath*
13:18RaynesFuckin' sleeplessness.
13:18RaynesOpps I sad a bad word. :|
13:18ChousukeRaynes: what 1+1 equals depends on the definition of + and your numbers anyway :)
13:18rabidsnailShouldn't it be in the default classpath?
13:18cp2*oops* :)
13:18RaynesChousuke: That's what the guy was arguing. He ended up banning the other girl.
13:18cp21 + 1 is invalid syntax anyway
13:19Raynesrabidsnail: The JVM doesn't ship with OpenGL does it?
13:19kotarakAnd 1 + 1 is obviously 10 and not the strange other thing, I never saw before.
13:19cp2Raynes: no
13:19ChousukeRaynes: sounds like a pointless argument. 1+1 not being equal to 2 if you define it so is a truism :/
13:19cp2you need to grab some library that has bindings for it
13:20rabidsnailNo, but I have it installed in /Library/Java/Extensions
13:20rabidsnaillibgluegen is definitely there
13:21rabidsnailand it doesn't have a problem importing any of the other opengl stuff
13:21cp2hrm.
13:21cp2;dependencies: jogl.jar, gluegen-rt.jar
13:22cp2obviously jogl.jar is in the classpath
13:22rabidsnailI have libgluten-rt.jnilib
13:22rabidsnailthat's what came in the zipfile from Sun's website
13:22cp2thats the native library
13:23rabidsnailisn't that what I want?
13:23cp2well, you do need that, but you also need gluegen-rt.jar
13:26rabidsnailThat did it!
13:26rabidsnailNow if that's required why doesn't Sun bundle it with the jogl library download?
13:27cp2not sure
13:28Raynes[12:27] <Cthulhon> i don't know how Scala's type system compares to Haskell's, but dynamic typing just leads to sloppiness.
13:29RaynesI respect his opinion so much, but that hurt. :|
13:33gnuvinceBah
13:33rabidsnailI've also been finding that if I M-c M-e large expressions in emacs (using inferior-lisp-mode), it only loads part of the expression in the repl.
13:34powr-tocIs there any way to lazily wrap a lazy-sequence with a vector? e.g. the equivalent of (into [] (iterate inc 0))
13:36Chouservectors aren't lazy
13:36Chousukeyou could have a vector of delays though.
13:36powr-toc,(doc delay)
13:36clojurebot"([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force), and will cache the result and return it on all subsequent force calls. Any closed over locals will be cleared prior to the tail call of body, (i.e. they will not be retained)."
13:37powr-toc,(doc force)
13:37clojurebot"([x]); If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
13:39powr-tocinteresting... though not quite what I was after... I quite like that vectors are a function of their indicies... lists and lazy-seq's aren't... that's what I was looking to replicate
13:40Chousukehmm
13:41Chousukelists aren't functions of indices because they're not associative :)
13:41powr-tocChousuke: I know :-)
13:42powr-toce.g. assuming this was possible you could do the following ((into [] (iterate inc 0) 10))
13:42powr-tocto return the 10th item
13:42powr-tocnot 100% sure if it's desirable
13:43Chousukeyou already can do that... if you fix paren placement
13:43Chousukebut it's not lazy.
13:43Chousukeoh wait
13:43Chousukeno you can't :)
13:43powr-tocyeah it leads to non termination because 'into' is eager
13:44Chousukebut I guess it might be possible to have a lazy vector that uses delays internally.
13:44Chousukebut I don't think it'd be very smart :/
13:46Chousukekotarak's lazy-map however is quite neat.
13:46stuhoodclojurebot: map?
13:46clojurebotmap is *LAZY*
13:46Chousukenot that map
13:46Chousukethe {} map
13:47stuhoodheh, gotcha
13:47Chousukewhy is it not in contrib though.
13:47powr-tocahhh I guess that could achieve the same result
13:48powr-tocwhere can it be found?
13:48Chousukehttp://kotka.de/projects/clojure/lazy-map.html
13:48ChousukeI have no idea if it even works with the new fully lazy clojure though.
13:51powr-toclooks interesting...
13:52gnuvinceRaynes: link?
13:53cemerickwell, I don't like LISP either
13:53Raynesgnuvince: I had the benefit of it being in an IRC conversation and directed at me.
13:55gnuvinceRaynes: k
13:55Chousuke:p
13:56RaynesI'll paste the conversation.
13:56RaynesGive me a second to edit.
14:00Rayneshttp://paste.pocoo.org/show/112835/ A bit of talk about dynamic typing is thrown in there as well. He's given me other lectures about how Haskell is moar awesome than Lisp, but I'd rather not look those up.
14:03gnuvinceI was expecting something more in detail.
14:04gnuvinceAnd as for making your brain explode, Haskell does outshine Lisp in that department.
14:05stuhoodhmm: "In a way LISP is already strongly typed... In that everything has exactly one type... That is, everything is a list."
14:05Raynesgnuvince: I was referring to the entire collection of articles as "How Haskell is better in every single way possible."
14:05stuhoodwas that true in common lisp?
14:05Chousukeno? :/
14:06Chousukeyou have vectors and hash-maps and whatnot
14:06stuhoodkinda sounds like he hasn't tried a lisp then.
14:06Chousukeand atoms :P
14:06gnuvinceChousuke: he was misinformed there, but in a sense, all data types in dynamic languages are the same type
14:07gnuvince(see PyObject for Python for example)
14:07Chousukegnuvince: that's an implementation detail :)
14:07ChousukeI think it's better to say that all types share some common properties.
14:08gnuvinceIn which case he may not be wrong depending from which point of view you choose to debate.
14:08RaynesI don't care how awesome Haskell is Clojure rocks hard. :|
14:08ChousukeI think it's useful to look at dynamic languages from a property point of view.
14:09Chousuketwo items sharing exactly the same properties can be said to have the same type
14:09gnuvinceRaynes: it's not useful to stick your head in the sand either because you like Clojure.
14:09Chousukethe dynamicism comes from the fact that the properties can change during runtime.
14:09gnuvinceHaskell has a lot of nice stuff going for it.
14:10Raynesgnuvince: What do you mean?
14:10RaynesI never said Haskell wasn't awesome.
14:10Chousukegnuvince: I wish monads weren't such a pain though :(
14:11gnuvinceChousuke: a pain how?
14:11Chousukegnuvince: a pain to understand, create and use :P
14:12stuhoodguido's quote about haskell pretty much summed up my feelings: "Haskell's purity reminds me of lemon juice: you need to add lots of water, sugar and ice to make refreshing lemonade."
14:12gnuvincethe first two are rather easy, the last one I think is a result of the operations on different datatypes being visually the same while having wildly different results.
14:13Chousukeif the first two were easy I wouldn't have problems with the third :P
14:14ChousukeIt's not like monads are the only solution, either. I think Clean's "uniqueness type" solution is much more intuitive than monads
14:15RaynesI think not being pure is an ever better solution.
14:15ChousukeI haven't looked at it in detail though, but at least it makes sense even after a cursory inspection :P
14:15Chousukethat's something Monads just fail at.
14:15gnuvinceChousuke: so you read that article last week on Reddit?
14:15Chousukewhat article?
14:15gnuvinceAbout Clean
14:16Chousukehmm, not sure if I did.
14:16gnuvinceRaynes: and while we're at it, why not go with mutations?
14:16Raynesgnuvince: It was a joke.
14:16gnuvinceAh
14:16RaynesAre you another Haskell advocate or something? :\
14:16gnuvinceDidn't catch it.
14:17gnuvinceRaynes: not an advocate, but I dislike when people diss it because they lack an understanding.
14:17Chousuketoo bad Clean seems quite unprofessional ;(
14:17Raynesgnuvince: I /never/ said I didn't like the language. Ever. Not once, and I never have and I never will. I've used the language before, I like the language, which is why I didn't argue with him when he was downing Clojure.
14:18Chousukeit also reeks of a "closed" language, even if it is LGPL
14:20hiredmanthe road to 1.0, eh?
14:20hiredmanye gods, "Source Control"
14:20Chousukehiredman: hm?
14:20gnuvincehiredman: yeah, and the first reply is a plea to switch to Git
14:21hiredmanthe google group
14:21Chousukeah, hah
14:21Chousukebut google code doesn't support it :(
14:21RaynesGit sucks on windows.
14:21gnuvinceI'd rather we use something Rich doesn't mind using.
14:21hiredmanso does most things
14:22ChousukeRaynes: does it really?
14:22ChousukeRaynes: I thought that was mostly pre 1.6.x
14:23RaynesChousuke: I still haven't managed to Git it to function correctly.
14:23RaynesBut I can pull stuff and that's all I really need.
14:24stuhoodi don't know if clojure's current 'contributor' structure really requires git
14:24stuhoodsince you have to get a CA to contribute anything, which I assume gets you svn access
14:25ChouserI think there are lots of people who have a CA on file but write access to contrib.
14:25Chouser"but no write access"
14:26hiredmanwe should start callit the RHCA instead of CA :P
14:26rhickeycontrib members are library progenitors
14:26stuhoodCLJCA?
14:27hiredmanstuhood: the form says "Rich Hickey Contributor Agreement"
14:27hiredmanRHCA
14:27stuhoodhah, gotcha.
14:27Chousukemakes me think of redhat
14:28hiredmanRHCE
14:28hiredmanyeah
14:29hiredmanrhickey: that google books link to lisp in small pieces was very helpful, thanks
14:30hiredman(I got closures working in my toy lisp)
14:30rhickeyhiredman: you're welcome - sorry it's out of print
14:31hiredman*shrug* thems the breaks
14:31cemerickit's completely impossible to keep up with the group entirely anymore
14:32cemerickwhoo, you'd think I had started drinking at work.
14:37gnuvincehiredman: link?
14:38stuhoodhttp://books.google.com/books?id=iCrrcMA6TYwC&amp;dq=lisp+in+small+pieces&amp;printsec=frontcover&amp;source=bl&amp;ots=-aM6FK3qN6&amp;sig=Pn16Sog-4BTnjBHKc8Hj4pyWzKk&amp;hl=en&amp;ei=G3vnSdCACY3FtgerocXRBQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=3
14:39hiredmanclojurebot: delicious?
14:39clojurebotdelicious is http://delicious.com/clojurebot
14:39stuhoodhah... that's cool
14:39hiredmanhttp://delicious.com/clojurebot/rhickey
14:53kotarakChousuke, powr-toc: lazy-map is compatible with current Clojure
14:54kotarakChousuke: it's not in contrib, because no one proposed it so far. I got only little feedback so fat, but only positive at that. :)
14:55Chousukeyou should put it in contrib.
14:56Chousukeit doesn't get the attention it should because it's hidden on your webpage and you'll never find it unless you explicitly searched from lazy maps :P
14:57kotarakWell, I announce the releases on the google group
15:00Chousukeand they get drowned by everything else
15:00Chousuke:)
15:00kotarakMaybe. Lots of things got lost in the Group...
15:06Drakeson(?? [0 2 3] 6) -> (nil true nil true true nil)
15:07Drakeson6 is the length, and [0 2 3] is a sorted list of indexes of elements I want to be present
15:07Drakesonit could also be a set
15:07gnuvinceAny of you guys read "Let Over Lambda"?
15:39ChouserDrakeson: I don't understand. elemnts you want to be present in what?
15:42cemerickfeh, a destructuring form allowing for [ but-last > last ] or somesuch would be *great*
15:43cemerickor [ prefix > before-before-last before-last last ] would be more general, I suppose
15:44Chouserhm, we don't even have a 'last' that takes a count
15:45Chouserdo we?
15:45cemerickdrop-last?
15:45cemerickor did you mean an nth-last?
15:46Chousersomething that your destructing form could call internally
15:47Chouser(drop (- (count coll) n) coll)
15:47cemerickyeah, that's drop-last
15:47Chouserno
15:47cemerick(essentially)
15:48cemerickoh, crap, right, no
15:48Chouser(defn last* [n coll] (drop (- (count coll) n) coll))
15:48Chouseroh
15:49Chousersplit-at
15:49Chouserhm, nope still not quite.
15:50Chouser(let [[xs [y z]] (split-at (- (count coll) 2) coll)] ...)
15:50cemerickwell, that'd be a fine intermediary -- then prefix is bound to the first from split-at, and the enumerated bindings just get streamed out of the second of split last using nth
15:50cemerickright, that :-)
15:51Chouser:-)
15:52ChouserI haven't needed it, but the convolutions necessary to do it manually does suggest destructuring support might be nice
15:52cemerickusually, I just work around it by flipping around the order of arguments in my apis
15:52Chouser(let [[z y & xs] (reverse coll)] ...)
15:53cemerickeh -- I'd often end up having to do something more like (reverse (cons foo (concat bar first-bunch-of-stuff)))
15:54cemerickthat's why I just flip the arg order around :-)
15:54Chouserwell, you could write a let-last macro
15:55Chouser(let-last [[xs & y z] coll] ...) or something
15:56Chousukehuh
15:57cemerickChouser: I aspire to a patch.
15:57cemerickaspirations are cheap, though
15:58bstephensonI need a func to remove a member of a vector given its index. I looked around clojure.contrib and elswhere, but could not find specifically what I needed. I've written a single line remove-from-vector function but it is slow. Does anyone know of a lib I could have missed that would give me this type of function?
15:59Chousukedissoc? :/
15:59Chouservectors aren't good at sparse
16:00Chouserrather, they're not good at removing things from the middle and updating the indexes of all the following items
16:01Chousukeapparently it doesn't work anyway
16:01cemerickbstephenson: your fn uses subvec I assume?
16:01bstephensonthis is my func. Is it written foolishly?
16:02bstephenson(defn remove-from-vector "Takes a vector and an index, returns a vector with the member at that index removed." [vc indx] (vec (concat (subvec vc (inc indx)) (subvec vc 0 indx))))
16:02ChousukeAs Chouser said, I think removing stuff from the middle of a vector is misuse of vectors :)
16:03bstephensonyeah, our clojure expert agrees, just ran into a situation that would be useful to do it. Coding is being done with different structs now because of your point.'
16:04Chousukethough since clojure vectors are immutable and are "partitioned", maybe they could support a reasonably quick removal from the middle :/
16:05Chousukeor hm
16:06ChousukeI guess the algorithms in the current implementation wouldn't like holes in the partitions either :(
16:06ChousukeI oversimplified the situation in my head .)
16:06bstephensonyeah, we are moving quickly away from vecs, to many hidden headaches
16:06bstephensonfrom trying to remove members
16:07bstephensontoo many hidden headaches
16:08Chouserif you don't need the full range of indeces to be valid, a hash-map with int keys might be an option
16:08slashus2,(remove #(= % 15) (range 20))
16:08clojurebot(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 18 19)
16:09slashus2Oh, by index.
16:14bstephenson,(vec (concat (subvec [0 1 2 3 4 5 6 7 8 9 10] 0 3) (subvec [0 1 2 3 4 5 6 7 8 9 10] (inc 3))))
16:14clojurebot[0 1 2 4 5 6 7 8 9 10]
16:15cooldude127isn't middle removal exactly what lists are good at?
16:17bstephensonso my best bet is to convert the vec to a list, remove the member, and re-vec it? Despite this one step, having a vector is most useful to this code.
16:18Chousuketry with a map instead.
16:18djkthxis it correct that suffixing a variable in a macro with # essentially generates a new symbol for it?
16:18djkthxand makes the macro hygenic?
16:19Chousukeit's an auto-gensym
16:19cooldude127djkthx: i don't think that's all there is to hygienic macros
16:19Chouserbstephenson: how badly do you need fast lookup by index?
16:19cooldude127but it will give you a convenient gensym
16:19bstephensonChousuke: thx, I see, I will try that way.....thx
16:20lenstIt's not macros it's backquote that does the auto-gensym.
16:20cooldude127lenst is right
16:20lenst,`(foo foo# foo# bar)
16:20clojurebot(sandbox/foo foo__1791__auto__ foo__1791__auto__ sandbox/bar)
16:20lazy1Can anyone explain http://pastebin.com/m39cd19ed to me?
16:20bstephensonspeed of lookup is the most essential part of using a vector in this component
16:20lazy1I get Wrong number of args passed to: LazilyPersistentVector
16:20Chousukeit's quite difficult to accidentally shadow variables with the clojure system anyway.
16:20Chouserbstephenson: if you can find a way to working (what amounts to) uuid, or passing around the object itself, or perhaps some other options, you're likely to get more convenient code and improved performance
16:21cooldude127lazy1: that trips up EVERYONE
16:21bstephensonwhich is why we are trying to stay with them, but other considerations are taking over
16:21lazy1Gald I can join the crowd
16:21Chousukeclojurebot: tell lazy1 about function literals
16:21clojurebotFunction literals are cute, but overused
16:21kotaraklazy1: #(vector ..) instead of #([...])
16:21Chousukenot that one ;(
16:21kotaraklazy1: #(foo) <=> (fn [] (foo)) note () around foo
16:21lazy1Is it in a FAQ somewhere? Couldn't find it
16:21cooldude127lazy1: #([blah]) is like (fn [] ([blah]))
16:22bstephensonChouser: hmmm, understand your point, like the UUID idea
16:22kotarakclojurebot: #()
16:22clojurebot#() is not a replacement for fn
16:22Chousukelazy1: you should use (fn [] [whatever]) in this case
16:22kotarakor #(vector whatever)
16:22lazy1This is what I did, just wondered why it didn't work
16:22lazy1Thanks
16:22Chousukekotarak: I wonder if that's equally fast though.
16:23kotarak*shrug* speed is overrated
16:40pjstadigclojurebot: speed
16:40clojurebotExcuse me?
16:41pjstadigclojurebot: speed is <reply>kotarak: speed is overrated
16:41clojurebotAck. Ack.
16:41pjstadigclojurebot: speed
16:41clojurebotkotarak: speed is overrated
16:41kotarakclojurebot: speed is also dangerous
16:41clojurebotAck. Ack.
16:42cemerickclojurebot: speed is also <reply>I live for speed.
16:42clojurebot'Sea, mhuise.
16:43cemerickI wonder if hiredman flushes clojurebot out every now and then.
16:43kotarakcemerick: he was pissed, because someone deleted his emacs factoids...
16:44kotarakclojurebot: speed is also <reply>Programmers should be more concerned about program correctness than speed...
16:44clojurebotIk begrijp
16:44cemerickheh, this could go on for days
16:44kotarakhehe
16:47lpetitHello
16:48lpetitkotarak: do you already have source formatting in VimClojure?
16:48clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
16:49kotaraklpetit: yes. VC has formatting since almost a year.
16:50kotarakI use some Vim built-in, which helps a lot.
16:50lpetitkotarak: if so, do you use Vim facilities, or a plain old clojure function that I could shamelessly use for clojuredev ? :-)
16:50lpetitOur posts collided :)
16:50kotaraklpetit: indenting is 100% Vim.
16:52lpetitkotarak: How dynamic and/or specific is it ? I'm currently thinking about how to implement it in clojuredev (or reuse it from somewhere, but it seems that everybody has leveraged the facilities of one's favorite platform, so nothing can be decently be shared).
16:54lpetitkotarak : but first, I'm thinking about the "question" : what exactly would be the behavior ? Is there somewhere something that looks like a "spec" for how to correctly format clojure code, or is this just a painful (for somebody willing to be very detailed) journey of synthetizing the way people indent their code, inferring the general case, and all the specific cases as well (e.g. for...
16:54lpetit...clojure "core" constructs) ...
16:54kotarakIt is relatively static, meaning you can modify it via ftplugins for Vim. You can add the macros for you libraries. But this is not automatic. I'm planning to support a heuristic of macros which have an arglist ending in "& body".
16:55kotaraklpetit: look at some VC code. ;P It uses some built-in Vim functions which is modelled after the "usual" Lisp style.
16:57arohnerMost of clojure.core and clojure.contrib also follows "usual lisp style"
16:59lpetitkotarak: Do you make even more specific cases for some clojure core macros/special forms, or does it all come down (for call forms) to a 2 space indentation from the column of the opening paren for the first argument being part of the & body ?
17:01lpetitarohner: yes, but alas "usual lisp style" does not speak formally about clojure general specificities, and maybe some clojure 'call symbols' even more specific cases :-(
17:01kotaraklpetit: it roughly comes down to this:
17:01kotarak(some-function a b
17:01kotarak c d)
17:01kotarakc should align with a
17:02kotarak(some-macro a
17:02kotarak (body-part starts here))
17:02kotarakFor a macro with a body part.
17:02kotarakSome exceptions I made include defmulti, -> and doto.
17:05lpetitkotarak: for your (some-function) example, isn't it too strict to align c with a ? Does it "scale well" if you have deep imbrication of code (does it not go too deep on the right of the screen too quickly ?)
17:06kotaraklpetit: not in my experience, and there is also the form:
17:06kotarak(some-function
17:06kotarak a b c d)
17:06kotaraktwo spaces (like in the macro with body case) if a newline directly after the function/macro,
17:07lpetitI was wondering whether this could be a workable solution :
17:07lpetit(some-function a b
17:07lpetit c d) ; it's the second line, we propose 2 characters indentation by default. If the user presses tab, we indent towards a automatically
17:07lpetit(some-function a b
17:07lpetit c d
17:07lpetit e f) ; e aligns with c, whatever c's column is
17:10kotaraklpetit: also possible
17:12lpetitkotarak: the advantage I see is its simplicity, and maybe also even more consistent with the (some-function\n a b c d) case (indeed, why not going one space after the end of the function name ?)
17:13kotaraklpetit: I'm not arguing for consistency... I just use the vim lispindent function and that's the way it works.
17:14lpetitkotarak: ok. Eclipse is too open in this area: it offers nothing prebuilt ! So all possibilities (and the time consuming task to elaborate on them :) ) are offered to me ! :)
17:45hiredmanI totally just solved euler project problem #1 in the lisp I wrote
17:45hiredmanmakes you appreciate lazy-seq
17:46aperottehello all
17:48stuhoodhowdy
17:49aperotteI'm in the process of writing a matrix/n-dimensional array data type
17:49aperottewas wondering if anyone had any suggestions or comments
17:58stuhoodi heard mention that there was a contrib module that wanted to depend on Colt (http://acs.lbl.gov/~hoschek/colt/) for its matrix functionality
17:59aperotteI've looked at colt, and liked the library but it has support for data structures of only up to 3 dimensions
18:14aperotteI also thought it would be nice to have a data structure that didn't depend on an external library
18:37djkthxis there a way to make macroexpand's output a little prettier?
18:37Chousukeuse pretty-print from contrib
18:37djkthxwith indentation and maybe syntax highlighting? (in slime)
18:39djkthxawesome, thanks
18:45lispblissIs there a more concise way of updating :b in this example: (let [m {:a {:b 1 :c 2}}] (assoc a :a (merge (:a a) {:b 2})))
18:46Chousukeassoc-in
18:47lispblisssweet
18:47Chousuke,(assoc-in {:a {:b 1 :c 2}} [:a :b] 3)
18:47clojurebot{:a {:b 3, :c 2}}
18:48Chousukealso works with nested vectors or vector-map combinations :)
18:48lispblissby using an index number for the vectors?
18:48Chousukeyeah
18:49Chousuke,(assoc-in [[1 2]] [0 1] 3)
18:49clojurebot[[1 3]]
18:50Chousukecan't add to vectors that way though. only "replace" an existing item
18:51Chousuke,(assoc-in {} [:a :b :c :d :e] 4); this works with maps though
18:51clojurebot{:a {:b {:c {:d {:e 4}}}}}
18:51gnuvince_,(update-in [[1 2]] [0] join 3)
18:51clojurebotjava.lang.Exception: Unable to resolve symbol: join in this context
18:51gnuvince_,(update-in [[1 2]] [0] conj 3)
18:51clojurebot[[1 2 3]]
18:51Chousukeah, right, that
20:26gnuvince_Chousuke: http://ertes.de/articles/monads.html
20:33scottjIs there a function (foo {:a 1 :b 2} {:a 1 :b 3}) => {:b 2} ?
20:37Chousera sort of diff?
20:38scottjyeah
20:38Chousernot that I know of: http://groups.google.com/group/clojure/browse_thread/thread/cc316de16fcba6c8/a74e652eb98693ce
20:41Chousukegnuvince_: cool, some more monad stuff for me to read.
20:41gnuvince_Chousuke: reading it between commercial breaks
20:42gnuvince_the guy seems thorough
20:42ChousukeI've read a lot on monads.
20:42ChousukeAnd still they just don't make sense.
20:43gnuvince_Read the ones for monads in Clojure :)
20:43ChousukeI mean, I already have an idea of the why and how, but there's still something missing.
20:43Chousukeyeah, I did.
20:46cp2ugh, anyone recommend a monospaced font with good unicode coverage?
20:49gnuvince_cp2: http://dejavu.sf.net
20:50cp2ahhh
20:50cp2thank you gnuvince_
20:50cp2this is much more pleasing to look at
20:51gnuvince_cp2: I use it everywhere in 16pt
20:51gnuvince_Nice big mono characters
20:51cp2heh
22:28chessguyis it possible to write my own data structures in clojure that "implement" seq? so that i can use first/rest on them?
22:29rhickeychessguy: sure - what kind of data structure?
22:29chessguyrhickey i don't have one in mind, it's more of a generic question
22:30rhickeychessguy: you just have to implement clojure.lang.Seqable
22:31chessguyin java?
22:34chessguysorry, brand new to clojure here, and don't have a ton of lisp experience either, so i'm trying to grok what that would look like
22:34hiredmanyou could do it with proxy
22:34clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
22:35chessguyit sounds like i'm asking the wrong question though :)
22:35hiredmanSeqable is just a java interface that specifies one method
22:36chessguysure, i get that. i'm sure i could implement the interface in java. just not sure what that would look like in a functional language
22:37hiredmanmost likely you would have the seq method return some kind of lazy-seq over a function that iterates your datastructure
22:38rhickeyhiredman: right, and as you said, you can implement the interface with proxy
22:38chessguywould it be...unusual to do that?
22:39hiredmannormally I would just use lazy-seq
22:40rhickey(let [rep (create-representation)]
22:40rhickey (proxy [clojure.lang.Seqable] []
22:40rhickey (seq [this] (lazy-seq (cons (get-first rep)) (get-rest rep)))))
22:41rhickeysomething like that
22:42rhickeyoops:
22:42rhickey(let [rep (create-representation)]
22:42rhickey (proxy [clojure.lang.Seqable] []
22:42rhickey (seq [this] (lazy-seq (cons (get-first rep) (get-rest rep))))))
22:42rhickeydarn those pesky parens!
22:43chessguyok, i'm way over my head now
22:43chessguyi guess i need to just find more code to read
22:44rhickeychessguy: might be unusual, in that I wonder what data structure you need that isn't an aggregate of the ones in Clojure, and thus supporting seq out of the box
22:44chessguyfair question
22:44rhickeybut nothing wrong with the idea
22:45chessguyso the more clojure-ish way would be to use some aggregate of core data structures
22:45chessguyby writing my own constructors/selectors/etc.?
22:46Carkthere are many data structure with different tradeoffs, it is possible that you want to build your own
22:46Carki have a trie which i use for telephone prefixes
22:46Carki think it makes sense to build your own data structures at times =P
22:47chessguywell, right this minute i'm more interested in typical usage of the language than what the language CAN do
22:48rhickeyCark: no doubt, I'm just interested in which ones people are needing beyond what's in core. Someone's working on a persistent heap, I'd like to see maybe treaps or finget trees
22:48rhickeyfnger
22:48rhickeyfinger
22:48Carkchessguy : usually you'll just use what's available, you have lists lazy or not, vector, maps (sorted or not, ordered or not)
22:49rhickeychessguy: it's strongly advised to use the data structures rather than classes, but there are other generic data structures not included
22:49Carkrhickey : i'm pretty happy with what's in there already
22:49Carki wouldn't expect every data structure under the sun to be available out of the box
22:50Carkthough it would be nice to have the persitent queue available from clojure itself
22:50rhickeyCark: well, the implementation is there
22:50rhickeyyou just want Clojure wrapper functions?
22:51Carkyes, someone pointed me to it, but i was a bit afraid it might disapear
22:51Carkyou know in a version 1.0 or something =P
22:51chessguyso if i wanted a generic tree, for example, i would write mk-tree, map-tree, etc.?
22:52Carkchessguy : it depends on why you need a tree
22:52Carkanyways that's how i built my trie implementation
22:53rhickeychessguy: map-tree returns a seq or a tree?
22:53Carkbut no map-trie .... rather a trie->seq function, which produces a lazy-seq
22:53Carkthen i can use every map function which is already in clojure
22:53chessguyrhickey map-tree takes a function and a tree and returns a new tree with the function applied at each node
22:53Carkwhich includes map =)
22:53chessguyerr, what?
22:54Carkah right, it won't help building a new tree
22:54Carkyou could add a seq->tree function though ...
22:54chessguyit's hard, because i'm coming from haskell, so i'm a bit lost without being able to write type signatures
22:55hiredmanmap-tree might be nice in clojure.zip
22:55Carkerr i meant "every sequence function which includes map"
22:58chessguyi also am not accustomed to thinking in macros, though i get the general concept
22:59joha1I'm having some problems with vimclojure 2.1. My classpath is set up correctly in the shell, but when I run vim and try to execute a file that imports an external library I get a ClassNotFoundException. It seems that VimClojure sets a private CLASSPATH which is wrong. How does it work? What can I do?
23:00hiredmanjoha1: the import classpath is the classpath you pass when you start the nailgun server
23:00hiredmanimportant
23:03joha1hiredgunman: so I have to submit the complete classpath to the NGServer, not only clojure.jar and clojure-contrib.jar?
23:03hiredmanyes
23:03chessguyin http://gnuvince.wordpress.com/2008/10/31/fetching-web-comics-with-clojure-part-1/ , the second snippet of code (look for with-open), why is with-open not taking a vector?
23:03hiredmanthe nailgun server is the java process
23:03hiredmanchessguy: old code
23:03joha1ok, makes sense. Will give it a try
23:04chessguyoh!
23:04chessguyno wonder i was confused
23:07joha1hiredman: thanks! it works now
23:16chessguydoes "programming clojure" work through any examples of a significant size?
23:18djkthxthroughout the book, you write a build system similar to ant
23:18djkthxiirc
23:18djkthxi suppose it depends what you consider significant
23:19chessguysignificant = non-trivial
23:19chessguyi think that qualifies
23:23chessguyok, enough for one night. thanks ya'all