#clojure logs

2009-01-31

00:06eeehi
00:06eeehas anyone bought the 41 dollar book yet?
00:07ayrnieuI only paid for the PDF.
00:07eeethat's all there is
00:07eeedid it help you?
00:07eeei remember you . . did you already know lisp?
00:08ayrnieuthus far. IIRC, 41 dollars is the price both for the PDF (now and until it's finished and published) and the paper book.
00:08eeedid you know lisp?
00:09ayrnieuI already knew lisp. The book has been pretty helpful -- the exploration of Java through clojure is well-done.
00:09eeei'm not buying that clojure is accessable to people that don't know lisp
00:10hiredman*shrug*
00:10eeeI'm thinking of diggin into some lisp books first. good idea?
00:10hiredmanclojure *is* a lisp, so knowing a lisp is required to know clojure...
00:10eeethere's just too much people talk about that I don't grok
00:10hiredmanclojurebot: sicp?
00:10clojurebotsicp is http://web.mit.edu/alexmv/6.001/sicp.pdf
00:11hiredmanalways good
00:11hiredmanthe hokey videos are nice too
00:11ayrnieuThe Little Schemer will help you.
00:11ozy`eee: http://www.gigamonkeys.com/book/ <= if you're into pain
00:11ozy`(PCL is actually pretty gentle as far as I know)
00:12ozy`(scheme is better for learning though)
00:12ozy`(so, SICP)
00:12eeelol people always recommend those
00:12eeei guess they are standards at some schools
00:12ozy`eee: asked this question before, have you?
00:12ozy`PCL isn't used in schools, to my knowledge
00:12eeeno
00:12eeenot quite
00:13eeebut people still recommend those
00:13hiredmanthe sicp videos are very gentle
00:13eeethis question is whether you need to hit books like that before bothering with clojure . . . Rich has videos saying it's ok if clojure is your first sojourn into lisp . . . but I'm not finding that so far
00:14RaynesWhy not recommend a book that is actually /about/ clojure. Like Programming Clojure. ;)
00:14eeethere are videos?
00:14hiredmanyeah
00:14eeewell, I asked about that book
00:15eeeraynes, it's pretty good?
00:15ozy`Raynes: he doesn't want to buy the book yet because he's afraid he'll have trouble learning clojure if he doesn't already know lisp
00:15hiredmaneee: I always recomend hands on learning, the sooner you start writing code the better
00:15ayrnieualso, because he thinks it's 41 dollars.
00:15eeei do think it's 41 dollars :)
00:15hiredman,(println "hello world")
00:15clojurebothello world
00:15eeeyup
00:15Rayneseee: I wouldn't really know, I only read 20 pages of it because once I had to actually write a function I went back into my haskell-shell.
00:15RaynesAnd hid.
00:16hiredmanman, talk about a low barrier to entry
00:16eeei can do plenty of simple stuff
00:16ayrnieueee, the PDF is $21
00:16eeegive me a simple challenge right now :) let's go
00:16ozy`,(map println '[clojure is neat])
00:16clojurebot(nil nil nil)
00:16ozy`aw man
00:17eeeit is? see I have reading comprehension problem aymieu
00:17ayrnieuit's probably the horrible font you're using :-)
00:17RaynesGet emacs working seamlessly with Clojure on windows in 2 minutes. There is a challenge :p
00:17eeei did that
00:17eeesomeone has an easy setup for that
00:17mfredrickson,(doseq [i '[clojure is neat]] (print i))
00:18clojurebotclojureisneat
00:18RaynesClojure-box doesn't count.
00:18eeei clicked a button and it installed . . .2 minutes exactly
00:18eeeoh
00:18mfredricksondoseq vs map. i never get it right
00:18hiredmancb doesn't deal with line breaks well
00:18hiredmanmap is lazy
00:18mfredricksoneither
00:18hiredmanclojurebot: map?
00:18clojurebotmap is *LAZY*
00:18eeebut, emacs doesn't follow windows conventions of things like cut and paste and save
00:18eeewho wants to relearn all that boilerplate . . . not to mention a new language
00:18hiredmanand by the time cb forces the seq, it has alread closed *out*
00:18RaynesI use emacs for everything /but/ JVM languages, I can't handle it.
00:19mfredricksonis there a good windows vim? MacVim has been great to me
00:19hiredman,(doall (map pr (range 10)))
00:19clojurebot(nil nil nil nil nil nil nil nil nil nil)
00:19clojurebot0123456789
00:19eeeoh and another thing . . . .this "advantage" of being able to use java stuff? well, I have programmed in java a bunch but never learned it. my IDE knows java, not me
00:20eeei never got macvim to work
00:20eeewindows vim much easier
00:20hiredman,(.codePointAt "abcd" 0)
00:20clojurebot97
00:20ozy`eee: getting macvim to work is pretty easy... you just decompress it and open it
00:20eeei don't have a coding environment for clojure . . .BIG part of the problem
00:20hiredmanthat was a java call
00:20ayrnieueee, I've loathed and avoided java for years, and Programming Clojure rehabilitated it for me.
00:21hiredman,(char 97)
00:21Rayneseee: The netbeans plugin is okay.
00:21clojurebot\a
00:21eeewhat did you use before aymieu?
00:21RaynesI stress that when I say "okay".
00:21ayrnieu,(map #(symbol (.getName %)) (.getMethods String))
00:21clojurebot(hashCode compareTo compareTo indexOf indexOf indexOf indexOf equals toString length isEmpty charAt codePointAt codePointBefore codePointCount offsetByCodePoints getChars getBytes getBytes getBytes getBytes contentEquals contentEquals equalsIgnoreCase compareToIgnoreCase regionMatches regionMatches startsWith startsWith endsWith lastIndexOf lastIndexOf lastIndexOf lastIndexOf substring substring subSequence concat replace
00:21ayrnieueee - everything else.
00:21ozy`ayrnieu: I've thought for a long while that java would suck a lot less if only there was a better language to serve as the interface to its mediocre libraries
00:22eeei can make a clojure program as long as there are no dependencies and in a single file in the netbeans plugin
00:22hiredmanfor clojurebot developement
00:22lisppaste8ayrnieu pasted "Java-using MD5 " at http://paste.lisp.org/display/74629
00:22hiredmanclojurebot: emacs?
00:22clojurebot"Learning Emacs and SLIME was just about the most painful computer experience I've ever been through."
00:22RaynesIf VIM were the last editor of any type on the planet. I wouldn't code.
00:22ozy`hiredman: ah, so you're the one....
00:23eeei agree with the bot
00:23ayrnieuI didn't try to be clever with that; it's just the first example I saw online of someone writing an MD5 in Java.
00:23RaynesThe whole classpath bullshit really lowered my clojure-excitement.
00:24eeei dropped an AI class I really wanted to take because I wasted 48 hours straight trying to get emacs and a repl going for lisp
00:24eeeraynes I agree
00:24hiredmanclojurebot: jar directory?
00:24eeeI hate all that classpath crap
00:24clojurebotjar directory is find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"
00:24ozy`Raynes: you know you can set up emacs keybindings in vim, right?
00:24eeeozy, then why use vim?
00:25Raynesozy`: I don't like vim, I don't want to make it more like emacs, I don't want to make it /act/ like emacs.
00:25hiredmanozy`: emacs goes a bit beyond keybindings
00:25RaynesI want emacs.
00:25Raynes:|
00:25ozy`eee: oh, I was just being pedantic with his rhetorical situation :p
00:25eeei want type ahead and dot completion
00:25ayrnieuRaynes, the whole classpath bullshit is familiar to me from dealing with C libraries, ldconfig, etc. You just build a little bit of architecture to handle it, and continue. I 'exec zsh -l' to refresh my CLASSPATH -- I could be cleverer.
00:25ozy`eee: you have no soul
00:25Raynestl;dr ;)
00:26hiredmaneee: I think there just was a message on the google group about a netbeans something or other with completion
00:26eeehere's the FUNNIEST thing
00:26eeei saw that
00:26eeeexcited to try it
00:26eeethis is funny
00:26eeetho
00:26eeeready?
00:26eeepeople talk about functional languages
00:26eeenice
00:26hiredmanayrnieu: zsh, Nice.
00:26eeehigh level
00:26eeeright?
00:27eeeand then they TOIL setting up and playing with environments and writing scropts
00:27eeethe other thing
00:27eeeiss
00:27eeeis
00:27ozy`eee: and you're astonished that they're all so primitive that they lack basic stuff like for loops?
00:27eeeeclipse writes all the boilerplate for you in java
00:27eeeso it's not fair to say that lisp programs are shorter
00:27eeewhat percentage do I actually write?
00:27eeenot much
00:27hiredmanclojurebot: what do you know about trolls?
00:27clojurebottrolls are like harmless particles that people have terrible allergies to. If you don't start shouting and blowing your nose at them, they're just misguided young men.
00:27eeeeclipse writes it
00:28ayrnieueee, eclipse doesn't read all the boilerplate for you.
00:28mfredricksoneclipse writes it, you maintain it
00:28ozy`eee: on the other hand, what percentage do you actually read? answer: you have to read -all- of it.
00:28mfredricksonozy`: +1
00:28eeewell
00:28eeeI can't read someone elses lisp thats for sure
00:28ozy`eee: always assume that your program will be written once, updated ten times, and read a hundred times
00:29mfredricksonto argue the other side of the coin, it's not eee's fault that java is verbose
00:29eeeever read output from a genetic program?
00:29ozy`eee: heh, well you don't know lisp, do you?
00:29mfredricksonbest of a bad situation
00:29eeeI think ou can write 10 lines of java in the time it takes to figure out your one line of lisp sometimes
00:30eeeand eclipse let's you collapse the little plusses :)
00:30eeebut I really appreciate you helping me with these arguments
00:30ozy`well that's definitely a plus ;)
00:30eeebecause I have to convince coworkers to try functional languages more
00:30eeeso I'm being them :)
00:31eeehere's a real question
00:31eeesomeone wrote in the discussions
00:31eeethat they made set ops faster
00:31ozy`learning a functional language will help you understand java's whacked-out design patterns better... a lot of them are just emulating stuff you get for free in functional langs
00:31ayrnieuit's better to seek answers with questions than to seek resistance with opinions.
00:32ozy`ayrnieu: that should go on a plaque over the entrance to 4chan or something
00:32eeewell, would it be faster to drop into empiricle mode? copy everything to a java set, then call java's intersect stuff, then copy back into a list?
00:32hiredmanhmmm, picking unicode symbols for macros then trying to edit the file again in a non-unicode console
00:32hiredmannot the best plan I have ever made
00:33ayrnieueee, clojure doesn't just use lists - actually it's remarkable for how well it uses other data types.
00:33hiredman,({:a 1 :b 2} :a)
00:33clojurebot1
00:34ayrnieueee, c.f. Chapter 4: Unifying Data with Sequences, of the $21 book :-)
00:34eeei see that now
00:35eeedoes the book talk about web stuff, too?
00:35ayrnieuso far it doesn't.
00:36ayrnieuThere's a 'web development' section in Chapter 9.
00:36eeei got one of those slicehosts
00:36eeeso I could follow eric lavigne's tutprial
00:36eeeI just did it by wrote
00:36eeeand of course it worked
00:36eeebut I didn't grok it :)
00:37eeeI can do simple little algorithms
00:37eeethat's it
00:37eee:)
00:37eeeanyone got a little challenge?
00:38hiredmaneee: you could hit up project euler
00:38hiredmanthey have a few challenges
00:38briancarper"Learning Emacs and SLIME... most painful experience..." did I just hear myself quoted by clojurebot or did someone else say that too?
00:38eeelol
00:39hiredmanbriancarper: could have been you
00:39hiredmanthat was your blog post?
00:39briancarperYeah.
00:39hiredmanYeah.
00:39eeewhere are these movies someone mentioned?
00:39ayrnieu'screencasts' on clojure.org
00:39hiredmanclojurebot: google sicp videos
00:39mfredricksonor did you mean SICP
00:39clojurebotFirst, out of 17600 results is:
00:40clojurebotStructure and Interpretation of Computer Programs, Video Lectures
00:40clojurebothttp://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
00:40briancarperThose movies are good.
00:40hiredmanclojurebot: ?
00:40clojurebotIt's greek to me.
00:40eeei saw rich's clojure ones. cool . . .the lectures
00:40eeethanks
00:41briancarperI like the parts where Sussman types LISP laboriously on an old green-on-black 30-character-wide display.
00:41hiredmanI put them on my blackberry
00:41hiredmanbriancarper: ha ha
00:41hiredmanthe magic parens balancing
00:41hiredmanthe hats
00:41briancarperHis huge sidewalk chalk.
00:42eeedid y'all go to MIT or wherever that was?
00:42hiredmaneee: no, I watched the videos
00:43hiredmanberkely had a podcast of the audio from the first three of their CS courses
00:43eeethat's cool
00:43hiredmanthe first is scheme, the second is java, the third is C and asm
00:44hiredmanthose are just he languages the classes use, the classes are not about those languages
00:44hiredmanthe C/asm class was awesome
00:45eeeC/asm was your third course?
00:46eeeoh I see
00:46hiredmanclojurebot: google berkely 61c mp3s
00:46clojurebotFirst, out of 1770 results is:
00:46clojurebotCS 61C Machine Structures Introduction
00:46clojurebothttp://www.jimmyr.com/blog/CS_61C_Machine_Structures_Lecture_1_John_Wawrzynek_159_2006.php
00:46eeethat was an aside
00:46hiredmaneee: I did not personally attend berkely
00:47eeei see
00:47hiredmanI have taken CS classes at the local community college, but they are a joke
00:48eeeyou taught yourself?
00:48hiredmanit just made me really bitter
00:48hiredmaneee: I never think of that way
00:49hiredmanI just know how to read instructions
00:49hiredmanand watch videos
00:49eeei'm the opposite
00:49eeei need to start out from someone else
00:49hiredmanmany people often seem to be the opposite
00:49eeei like to use people like compilers
00:49dreishWhat are the primitives, and what are the means of combinaaation?
00:50hiredmaneee: project euler has all kinds of problems to take a crack at
00:50eeei liked this book: http://www.amazon.com/Structures-Algorithms-CBMS-NSF-Conference-Mathematics/dp/0898711878
00:50hiredmanit was fun while I was doing it, maybe I should start again
00:50hiredmandreish: word
00:50eeei'll check out project euler
00:52hiredmaneee: the first problem is, find the sum of all the multiples of 3 or 5 under 1000
00:52eeehmmmmmm
00:52eeeok
00:53eeesee, interestingly . . . my mind starts thinking, "while"
00:54eeewhich isn't really used in clojure
00:55eeeso I guess a silly way to solve it might be to just loop from 1 to 1000
00:55eeeand
00:55eeeif a number evenly divides by 3 or 5
00:55eeeadd it to some list
00:55eeethen reduce the list
00:55hiredmana lot of the time things that would be some kind of loop in another language are seqs in clojure
00:56dreishAlso, there is no list.
00:56eeeso evenly divides is checked by having mod 3 equal to zero
00:56dreishWhen you create a seq, there's usually just one or two things in memory at a time.
00:56ozy`eee: think less about what steps to take to get the answer, and more about how to describe the answer in terms of its inputs
00:57dreish,(apply + (range 1000000))
00:57clojurebot499999500000
00:57eeeahhhhhh!
00:57eeei got beat
00:57eeeok
00:57eeehow do that as reduce?
00:57dreish,(reduce + (range 1000000))
00:57hiredmandon't use reduce
00:57clojurebot499999500000
00:58eeewhy not? i've never used it
00:58hiredmanok, go ahead
00:58eee:)
00:58cp2lol
00:58ayrnieu,(interpose + (range 10))
00:58clojurebot(0 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 1 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 2 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 3 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 4 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 5 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 6 #<core$_PLUS___3183 clojure.core$_PLUS___3183@1b0d990> 7 #<core$_PLUS___3183 clo
00:58cp2hiredman, i am curious though
00:58cp2why not?
00:58hiredmaneee: make an account on the euler website
00:58ayrnieu,(interpose '+ (range 10)) ;; readable mode
00:58clojurebot(0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)
00:58eeehow do you use reduce now?
00:58ozy`cp2: because '+ is already a fold, I assume....
00:59cp2oh well, i wasnt paying attention to the topic
00:59eeehow do you check docs on something?
00:59dreishTopic is Euler puzzle 1.
00:59cp2my bad, just say hiredman saying not to use something, and it sparked interest. didnt care to read further ;)
00:59ayrnieu,(doc interleave)
00:59clojurebot"([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."
00:59eeeoh, reduce was the same as apply
01:00eeethat's no fun
01:00hiredmanno
01:00ayrnieuthe same use and the same effect, but they differ.
01:00hiredmanreduce and apply are different
01:00ozy`eee: apply only has the same effect if you use it on something that already implies 'reduce
01:00eeeand then there's "map"
01:00dreish,(apply map #(+ 2) '((1 2)))
01:00clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1372$fn
01:01dreishur
01:01ozy`eee: 'map is easier to grok. you'll get back a sequence exactly as long as the one you passed into it
01:01dreish,(apply map #(+ % 2) '((1 2)))
01:01clojurebot(3 4)
01:01dreish,(reduce map #(+ % 2) '((1 2)))
01:01clojurebot(3 4)
01:01eee,(reduce (map '+ (range 5)))
01:01clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$reduce
01:01hiredmaneee: sign up for an account on the euler website, they have a list of problems
01:01hiredmansome of them are rather difficult
01:02hiredmanspend sometime with clojure.org/api
01:02ayrnieu,(let [calls (ref 0) my+ (fn [a b] (dosync (alter calls inc)) (+ a b))] [(apply my+ (range 10000)) @calls])
01:02clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1395$my-PLUS-
01:02eeedude clojure api is so terse. it's written for people who use very few . .. but big words
01:02eeelike "intern"
01:03ayrnieuoh, duh.
01:03eeeand "destructure"
01:03eeei'm like, "thanks. that helps"
01:03cp2eee its better than garbled abrreviations/acronyms
01:03ozy`,(apply + (map #(apply + (filter (fn [k] (= (mod % k) 0)) (range 10000))) '(3 5)))
01:03clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArithmeticException: Divide by zero
01:03ayrnieueasy to fix, but nevermind.
01:03ozy`whoops
01:03ayrnieueee, ask questions in the channel.
01:03hiredmaneee: the sequence functions are very useful
01:04cp2ozy`: im glad you dont work on the lhc
01:04ozy`,(apply + (map #(apply + (filter (fn [k] (= (mod k %) 0)) (range 10000))) '(3 5)))
01:04clojurebot26663333
01:04hiredmaneee: anyway, you asked for a challenge, so have at euler
01:04eeethat's pretty cool, no if statements were used
01:04eeeyes, thankyou hiredman
01:05ozy`eee: 'filter contains an if statement, IIRC
01:05LordOfTheNoobsclojurebot: Peter Griffin?
01:05clojurebotYou and your big words and your small difficult words
01:05eeei bet filter could be avoided by looking up the list comprehension syntax
01:05ayrnieueee, find me a hundred pairs of numbers whose base-seven product contains the number of the beast
01:05ozy`eee: anyway I think my implementation is wrong given the problem specification
01:06eeei know filter does . . .you guys helped me make "separate" faster than what's in contrib last time
01:06hiredmanozy`: that certainly is not the right answer
01:06ozy`cp2: anyway I didn't think it would even parse... wasn't too careful about balancing parentheses
01:06dreish(+ (apply + (range 0 1000 3)) (apply + (range 0 1000 5)) (apply - (range 0 1000 15)))
01:06dreishThat's almost like cheating.
01:06ozy`hiredman: not too worried :p just playing around
01:06hiredmanclojurebot: clojure?
01:06clojurebotclojure is a very attractive hammer with a nice heft to it
01:07hiredmanclojurebot: clojure?
01:07clojurebotclojure is a very attractive hammer with a nice heft to it
01:07hiredmangrr
01:07ozy`dreish: ahhh didn't think of that one
01:07hiredmanclojurebot: clojure?
01:07clojurebotclojure is cheating
01:07hiredmanthat's the one
01:07ayrnieuclojurebot, use non-repeating RNG
01:08briancarperIs there any way to break an infinite loop at the REPL without killing the whole Clojure process?
01:08hiredmanayrnieu: sometimes you get a bunch of heads in a row when you flip a coin
01:08eeewow. that's smart dreish
01:08ozy`> foldl' (+)
01:08ozy`aaagghhh
01:08hiredmanno lambdabot here
01:09ozy`<_<
01:09ozy`>_>
01:10eeei'll have to think about yours for a long time aymieu
01:10briancarperI'll take lack of response to my question as a no.
01:11eeei have had the same problem in enclojure
01:11eeeand had to kill netbeans
01:11eeelet alone the repl
01:12dreishbriancarper: I haven't found one, but I think it should be possible to do.
01:12briancarperYou'd think.
01:14hiredmantry kill -QUIT the java process
01:14eee(for seq-exprs expr) Macro List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000
01:14eeesee
01:14ayrnieubriancarper, how much do you want to preserve from the repl?
01:14eeeit doesn't say what when does
01:14hiredmanthat might just make the threads dump there stack
01:14eeeverses while
01:14eeejust says you can use one or the other
01:14hiredmaneee: while is while exp is true
01:14hiredmanwhen is when expr is true
01:15eeeum . .. in a list comprehension that makes no sense
01:15hiredmanit totally does
01:15eeehaskel list comprehension makes perfect sense
01:15eeepython list comprehension makes totl sense
01:15eeeyou state the predicate
01:15eeethis when thing is meaningless
01:15ayrnieu,(for [x (range 100) :when (zero? (mod x 3))] x)
01:15clojurebot(0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99)
01:16briancarperayrnieu: I want to kill the loop and go back to the repl without losing everything in the environment.
01:16ayrnieuif you want a different syntax, write it.
01:16eee,(for [x (range 100) :while (zero? (mod x 3))] x)
01:16clojurebot(0)
01:16eeeok
01:16eeetotally arbitrary
01:16eeebut ok
01:16hiredman,(for [x (range 1000) :when (and (zero? (mod x 3)) (zero? (mode x 5)))] x)
01:16clojurebotjava.lang.Exception: Unable to resolve symbol: mode in this context
01:17ayrnieuwhat's totally arbitrary?
01:17LordOfTheNoobseee: while stops at the first failure when moving over a list, when samples through the list. I think ( checking )
01:17hiredman,(for [x (range 1000) :when (or (zero? (mod x 3)) (zero? (mod x 5)))] x)
01:17clojurebot(0 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 110 111 114 115 117 120 123 125 126 129 130 132 135 138 140 141 144 145 147 150 153 155 156 159 160 162 165 168 170 171 174 175 177 180 183 185 186 189 190 192 195 198 200 201 204 205 207 210 213 215 216 219 220 222 225 228 230 231 234 235 237 240 243 245 246 249 250 252
01:17ayrnieu,(for [x (range 30) :when (zero? (mod x 3)) y (range 30) :while (< (* 2 x) 30)] [x y])
01:17clojurebot([0 0] [0 1] [0 2] [0 3] [0 4] [0 5] [0 6] [0 7] [0 8] [0 9] [0 10] [0 11] [0 12] [0 13] [0 14] [0 15] [0 16] [0 17] [0 18] [0 19] [0 20] [0 21] [0 22] [0 23] [0 24] [0 25] [0 26] [0 27] [0 28] [0 29] [3 0] [3 1] [3 2] [3 3] [3 4] [3 5] [3 6] [3 7] [3 8] [3 9] [3 10] [3 11] [3 12] [3 13] [3 14] [3 15] [3 16] [3 17] [3 18] [3 19] [3 20] [3 21] [3 22] [3 23] [3 24] [3 25] [3 26] [3 27] [3 28] [3 29] [6 0] [6 1] [6 2] [6 3]
01:17eee,(for [x (range 100) :while (not (zero? (mod x 3)))] x)
01:17clojurebotnil
01:18dreishYou really don't want to type :when, do you?
01:18LordOfTheNoobs,(mod 0 3)
01:18clojurebot0
01:18eeei always want to type when
01:18ayrnieu,(for [x (range 30) :when (zero? (mod x 3)) y (range 30) :while (< (* 2 y) 30)] [x y])
01:18clojurebot([0 0] [0 1] [0 2] [0 3] [0 4] [0 5] [0 6] [0 7] [0 8] [0 9] [0 10] [0 11] [0 12] [0 13] [0 14] [3 0] [3 1] [3 2] [3 3] [3 4] [3 5] [3 6] [3 7] [3 8] [3 9] [3 10] [3 11] [3 12] [3 13] [3 14] [6 0] [6 1] [6 2] [6 3] [6 4] [6 5] [6 6] [6 7] [6 8] [6 9] [6 10] [6 11] [6 12] [6 13] [6 14] [9 0] [9 1] [9 2] [9 3] [9 4] [9 5] [9 6] [9 7] [9 8] [9 9] [9 10] [9 11] [9 12] [9 13] [9 14] [12 0] [12 1] [12 2] [12 3] [12 4] [12 5] [1
01:20ayrnieueee - here, implement max with list comprehensions.
01:21eeeok
01:21eeethen I'd use while
01:21eee?
01:21LordOfTheNoobs, {:while (for [aa (range 1 10) :while (not (= aa 5))] aa) :when (for [aa (range 1 10) :when (not (= aa 5))] aa)}
01:21clojurebot{:while (1 2 3 4), :when (1 2 3 4 6 7 8 9)}
01:22eeewhat is that?
01:22ayrnieuwhat is what?
01:23eeewhat LON wrote
01:23ayrnieu,*1
01:23clojurebotjava.lang.IllegalStateException: Var clojure.core/*1 is unbound.
01:23eeei'm looking up haskell right now
01:23eeeseeing how they do it
01:24ayrnieu,[(class {:a 1 :b 2}), (class :a), (class (for [x (range 4)] x))]
01:24clojurebot[clojure.lang.PersistentArrayMap clojure.lang.Keyword clojure.lang.LazyCons]
01:24LordOfTheNoobsA hash-table literal with two similar for-expression calls to demonstrate their difference.
01:25eeedoesn't seem like list comprehension would be efficient for max
01:25eeesince you have to look at all the numbers
01:25eeei can only think of empricle implementatin
01:25ayrnieuno, it would not be efficient.
01:26eeei'm drawing a blank on that one
01:27hiredmanayrnieu: huh?
01:27ayrnieuhere's the answer in set notation: { x | x E l ( no y E l > x ) }
01:27eeesure
01:27hiredmanoh, right
01:28eeeneed random
01:28eee,(rand-int 30)
01:28clojurebot5
01:28ayrnieuwhat needs random?
01:28eeecool
01:28eeei want to test on randome sequence
01:28eee,(take 30 (rand-int 30))
01:28clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
01:29eee,(take 30 (repeatedly (rand-int 30)))
01:29clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:29eee,(take 30 (repeatedly '(rand-int 30)))
01:29clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
01:29ayrnieu,(apply str (take 100 (repeatedly #(char (+ (int \a) (rand-int 26))))))
01:29clojurebot"zblkucvjrxtwgxeuxfzvxpnaokiimmvpugdxulqeketawsnzjdndeszrzwojpvfqjgjgdsgjvsuibjqnubbortiamajdcvehksta"
01:30eee,(take 30 (repeatedly #(rand-int 30)))
01:30clojurebot(15 20 10 26 0 14 7 9 25 12 9 1 3 28 23 9 6 8 5 18 0 9 5 17 26 25 4 14 25 28)
01:30eeeok
01:31ayrnieu,(.contains (apply str (take 1000000 (repeatedly #(char (+ (int \a) (rand-int 26)))))) "ayrnieu")
01:31clojurebotfalse
01:32eee,(for [x (take 30 (repeatedly #(rand-int 30))) :while
01:32clojurebotEval-in-box threw an exception:EOF while reading
01:32eeei dunno
01:32eeeneed need two variable
01:33eeeyou have them in your math
01:33eeey and x
01:35eee,(for [x (take 30 (repeatedly #(rand-int 30))) y x] :while (< y x))
01:35clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$for
01:35eee,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x) [x])
01:35clojurebotEval-in-box threw an exception:Unmatched delimiter: )
01:36eee,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x)] [x])
01:36clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
01:36ayrnieuwhy are you using while?
01:36eee,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x)] x)
01:36clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
01:37eeetrying to stop on the max
01:37eeei dunno . . .shouldn't be a while or a when
01:37eeeit's set theory
01:37eeeshold just be what's in the set or what's not
01:38ayrnieuwell, here's how I put it: { x | x E l ( no y E l > x ) }
01:38hiredmanyour syntax for for is incorrect
01:38eeei see another problem
01:38eeecan't do it in this environment with a random sequence
01:38eeeoh
01:38ayrnieu( no y E l > x ) stipulates that no element of l is greater than x.
01:38eeeunless I use let
01:38eeei need to do a let to hold the randome sequence so I can use it with x and y
01:39eeethat way I can have what will amount to a nested loop
01:39eeeor maybe nested loop happens too
01:39eeeoh yeah
01:39eeeall combinations of x and y can be tried
01:40eeesomehow
01:40hiredman,(doc for)
01:40clojurebot"([seq-exprs expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000000
01:40hiredman^- "collections are iterated in a nested fashion"
01:41hiredmanhah
01:42eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] myseq)
01:42clojurebot(4 17 16 8 16 23 25 16 28 23 4 7 2 17 16 10 13 21 25 2 7 24 15 7 3 22 3 1 20 1)
01:43eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq] x)
01:43clojurebotEval-in-box threw an exception:EOF while reading
01:43eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq] x))
01:43clojurebot(11 17 4 19 9 24 8 6 1 16 6 0 11 10 9 5 25 27 7 0 5 1 7 6 25 2 14 18 0 29)
01:43eeeok
01:43eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] (x y)))
01:43clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:43eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] [x y]))
01:43clojurebot([29 29] [29 2] [29 28] [29 11] [29 3] [29 11] [29 7] [29 8] [29 27] [29 18] [29 26] [29 15] [29 5] [29 13] [29 20] [29 18] [29 11] [29 9] [29 6] [29 29] [29 11] [29 18] [29 16] [29 8] [29 16] [29 18] [29 3] [29 21] [29 27] [29 25] [2 29] [2 2] [2 28] [2 11] [2 3] [2 11] [2 7] [2 8] [2 27] [2 18] [2 26] [2 15] [2 5] [2 13] [2 20] [2 18] [2 11] [2 9] [2 6] [2 29] [2 11] [2 18] [2 16] [2 8] [2 16] [2 18] [2 3] [2 21] [2 27]
01:44eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] x))
01:44clojurebot(5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 29 29 29 29 29 29 29 29 29 29 29 2
01:44eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] :while (> x y)))
01:44clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$for
01:44eeelost
01:44eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] :when (> x y)))
01:44clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$for
01:45eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :when (> x y)] x))
01:45clojurebot(13 13 13 13 13 13 13 13 13 13 13 12 12 12 12 12 12 12 12 12 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 8 8 8 8 8 8 12 12 12 12 12 12 12 12 12 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2
01:45eee,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :while (> x y)] x))
01:45clojurebot(29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27)
01:45durka42what would be the fastest reference type for an integer that has to be modified thousands of times very frequently, but no synchronization is needed
01:45eeethis must be painful to watch :)
01:46hiredmandurka42: you can use commute instead of alter?
01:46eeeyou can use with-local-vars, maybe?
01:46durka42i'm not sure it's commutative
01:47hiredmanoh
01:47hiredmanI misread
01:47durka42my function gets mapped over a giant array and i need the max value
01:47hiredman,(doc atom)
01:47clojurebot"([x] [x & options]); Creates and returns an Atom with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn If metadata-map is supplied, it will be come the metadata on the atom. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state is unacceptable, the validate-fn should
01:47durka42that's what i'm using now
01:47durka42alternatively, a divide-and-conquer approach might be faster
01:47durka42if i can wrest control of the giant array away from quicktime
01:48hiredmanhmmm
01:48ayrnieu,(time (let [x (ref 0)] (dorun (take 1000 (repeatedly #(dosync (alter x inc))))) @x))
01:48clojurebot1000
01:48clojurebot"Elapsed time: 49.594 msecs"
01:48durka42most approaches would be faster than calling a function (* 320 240) times, 16 times a second
01:48eeei don't trust the timer in clojure at all
01:48durka42,(time (let [x (atom 0)] (dorun (take 1000 (repeatedly (swap! x inc)))) @x))
01:48clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException
01:48durka42why not?
01:49ayrnieueee - dorun
01:49eeethe function we wrote the other day was way faster
01:49eeebut someone else had to fiigure out how to prove that
01:49eeenope
01:49ayrnieu,(time (let [x (ref 0)] (dorun (take 10000000 (repeatedly #(dosync (alter x inc))))) @x))
01:49durka42,(time (let [x (atom 0)] (dorun (take 1000 (repeatedly #(swap! x inc)))) @x))
01:49eeewe actually had to break up the algorithms
01:49clojurebotExecution Timed Out
01:49clojurebot1000
01:49clojurebot"Elapsed time: 158.512 msecs"
01:49eeeand dorun parts of it individually
01:49durka42ok, refs are faster
01:49durka42apparently
01:49durka42,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) @x))
01:49clojurebot0
01:49clojurebot"Elapsed time: 8.984 msecs"
01:49eeetry with-local-vars
01:50durka42(doc with-local-vars)
01:50clojurebotvarbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set; arglists ([name-vals-vec & body])
01:50eeeyou can just use @
01:50ayrnieudurka, @x isn't necessarily inc'd by the end
01:51durka42whoops
01:51eeeso aymieu, do you know the answer to the challenge you gave me? was I close?
01:51durka42refs are not at all faster
01:52ayrnieueee - use a second list comprehension to perform the 'no y greater than x' test.
01:52ayrnieunested comprehensions. Horrid complexity.
01:52eeei was thinking that . . . .but was trying to avoid it
01:52eeeforget it
01:52eeegoing to bed
01:53eeethanks for the schooling tho
01:53durka42,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) (await) @x))
01:53clojurebot0
01:53clojurebot"Elapsed time: 9.308 msecs"
01:53durka42,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) (await x) @x))
01:53clojurebot1000
01:53clojurebot"Elapsed time: 264.598 msecs"
01:53durka42aah
01:53durka42this is hopeless and un-clojure-like
01:54durka42i shall have to parallelize it
01:54eeewhat if you use java
01:55eeei mean for that part
01:55durka42i might have to do that
01:55durka42eh?
01:55durka42Gorilla=> (use 'clojure.parallel)
01:55durka42java.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray (parallel.clj:32)
01:55hiredmandurka42: you should just loop/recur
01:55durka42that's the problem! it's not my loop
01:55durka42quicktime gives me an interface to extend
01:55durka42and calls it for every pixel
01:56durka42which is a bad design IMO
01:56hiredmanhaha
01:56ayrnieuyes, that's horrid.
01:56durka42i mean, i don't know if i'd want to call even a C function (* 320 240) times for each frame that comes in from theh camera
01:56eeenow I see why you want to do it in parallel
01:57ayrnieuJesus, it's like they never heard of APL.
01:57durka42i think i can get the pixel array
01:57eeegnight'
01:57durka42night
01:59durka42does anyone know what's up with clojure.parallel, though?
01:59durka42where might i find jsr166y.forkjoin.ParallelArray
01:59hiredmanclojurebot: google jsr166y
01:59clojurebotFirst, out of 725 results is:
01:59clojurebotjsr166y overview
01:59clojurebothttp://artisans-serverintellect-com.si-eioswww6.com/default.asp?W9
01:59ayrnieu./src/clj/clojure/parallel.clj:You'll need jsr166y.jar in your classpath in order to use this
02:00ayrnieuhttp://gee.cs.oswego.edu/dl/concurrency-interest/index.html , there's a big comment about it in that source.
02:00durka42thanks
02:00durka42i had just searched for the classname and nothing useful came up
02:01ayrnieuI do a lot of `find . |xargs egrep`
02:01hiredmanerm
02:01hiredman-R
02:02ayrnieufind .|egrep clj|xargs egrep
02:02hiredmanugh
02:02hiredmanfind . -name \*.clj
02:02ayrnieufind .|ergep -v git|xargs egrep
02:03hiredmanfind . -name \*.clj -not -name \*git\*
02:03ayrnieuYeah, I'll remember that for another few minutes.
02:03hiredmanfind . -name \*.clj -not -name \*git\* -exec egrep Foo {} \;
02:04hiredmanfind is one of my favorite tools
02:05ayrnieuso you're a Java man at the shell and a haskell man at the editor :-)
02:05hiredmaneh?
02:10durka42oh no!
02:10durka42QTJava requires java 5
02:10durka42clojure.parallel require java 6
02:10hiredmanouch
02:11durka42maybe i will have to try that 32-bit java 6 build
02:11durka42but QTJava is obsolete anyway
02:11durka42unfortunately there doesn't seem to be a working java interface to the new way
02:11durka42hmm, that wasn't the problem
02:12durka42jsr166 doesn't quite compile
02:12durka42oh there is a binary
02:17durka42i think ParallelArray moved...
02:18durka42jsr166y.forkjoin.ParallelArray --> extra166y.ParallelArray
02:18durka42commit message from 1/6: Repackaged parallel collection classes
02:19hiredmanhmmm
02:20durka42things work if i go into parallel.clj and swap out jsr166y.forkjoin for extra166y at the top
02:21durka42user=> (reduce + 0 [1 2 3 4 5])
02:21durka4215
02:21durka42user=> (preduce + 0 [1 2 3 4 5])
02:21durka4215
02:21cp2postduce?
02:22ozy`,(doc preduce)
02:22clojurebotjava.lang.Exception: Unable to resolve var: preduce in this context
02:22durka42,(use 'clojure.parallel)
02:22clojurebotjava.io.FileNotFoundException: Could not locate clojure/parallel__init.class or clojure/parallel.clj on classpath:
02:22ozy`wait, parallel reduce, right?
02:22durka42yes
02:24durka42range is optimized for reduce, yes? but if i call seq on it, does that remove the optimizations?
02:27durka42should i open an issue for the moved imports thing?
02:28LordOfTheNoobsDo you actually have multiple cores? :) Also, is this for large or small data sets? I think that thread spawn would get you for smaller data sets.
02:29durka42yes, sort of, can you elaborate?
02:29durka42this was my test: (time (dotimes [_ 1000] (doall (pmap inc (seq (range 1000))))))
02:29durka42with that example pmap is 24 times slower than map
02:33ayrnieu,(first (lazy-cons (print 1) (print 2) (print 3)))
02:33clojurebot1
02:33LordOfTheNoobsDo not take me as an authority, for I am on the other end of the knowledge pool here. For only a thousand items with a fast computation on each the amount of time it take the JVM to setup and dispatch to the subthreads may outweight the entire runtime of a single buteforce thread. Doing things in parallel tends to win when you have many cores, a hard computation, and many items to apply it to.
02:33ayrnieu,(first (seq (lazy-cons (print 1) (print 2) (print 3))))
02:34clojurebot1
02:34ayrnieu,(rest (seq (lazy-cons (print 1) (print 2) (print 3))))
02:34clojurebot123
02:34durka42i believe that
02:34durka42i upped it to 100,000 items, which should take a while
02:34durka42well, not "should"
02:34durka42but is
02:35durka42i think i only have two cores, so it won't speed up much
02:37LordOfTheNoobsGood luck with your benchmark durka. I'd re-ask tommorow for a set of likely more precise and accurate answers.
03:12Lau_of_DKBonjour cgrand ! :)
03:14RaynesHai.
03:15cgrandHej Lau!
03:20hiredmanpurely functional then?
03:23RaynesNo, it's an overcomplicated hello-world program :p
03:23RaynesStill useless.
04:11Lau_of_DKRaynes :)
04:11RaynesLau_of_DK: Yeah I know, I've been in here for a month and never actually used Clojure. ._.
04:12RaynesUntil now.
04:12Raynes:D
04:20Lau_of_DKRaynes, sorry I left out "hi" I wasnt making a comment :)
04:20RaynesI realized.
04:21Lau_of_DKGood :) Just being friendly
05:24BigTomkotarak: Hi
05:24kotarakSalut.
05:25BigTommy GUI is not fixed but I have made progress
05:26kotarakGood to hear. :)
05:26BigTomThe outstanding issue is that my watcher seems to disappear after its first call
05:27BigTom(The RejectedExecutionException was a red-herring, I had shut down agents in the repl)
05:27kotarak:P
05:28BigTomDoh!
05:28kotarakSh** happens. ;)
05:28BigTomIf I update the GUI from the watcher it gets called once then vanishes
05:29BigTomIf I replace the gui update with a prn it keeps getting updates
05:29BigTomIts odd (but I, suspect, fundamentally dumb on my part)
05:34kotarak"Blame yourself first" helps you to fix 98% of all the bugs.
05:34kotarakIn particular: it's almost never a compiler bug....
05:38Chousukehmm :/
06:12zakwilsonI'm trying to make a gui update a counter showing completion of an operation being applied to a bunch of files with pmap. Getting the counter to work is easy using either an agent or a ref, but the UI updes rarely and gets very out of sync.
06:13zakwilsonI've tried putting a JTextField in a ref or an agent and did not get better results.
06:13BigTomIs there any way you can see the watchers attached to an agent?
06:14BigTomzakwilson: have you looked at cells?
06:15turbo24prgmorning
06:15zakwilsonNo.
06:16BigTomzakwilson: http://github.com/timothypratley/strive/blob/8285ef1419601411797205de0d60a2b2c0b71be0/src/clj/cells.clj
06:19turbo24prgi'd like to build a datastructure based on nested sorted-maps. i'm familiar with common lisp, but new to clojure. what is the best method to modify it? refs/transactions, agents or atoms?
06:20kotarakturbo24prg: assoc-in and update-in
06:21BigTomturbo24prg: It really depends on the level of coordination required between the threads
06:22turbo24prgbut that wouldn't be save if i'd have to update several nested maps in there as one transaction, and would like to read from it
06:23turbo24prgfor one action i'd have to perform several inserts/updates on different maps in the structure, several levels deep
06:23kotaraksounds like a ref in combination with assoc-in/update-in.
06:24turbo24prgduring update i'd like to have read-access on a stable version of it. isn't that ref/transactions?
06:25BigTomyou cannot update a ref outside a transaction
06:25BigTomso if you use a ref you are going to use transactions :-)
06:25turbo24prgthe example for refs on the website isn't the easiest for a newbie
06:26turbo24prgespecially if you're not into java's concurrency
06:27kotarakturbo24prg: refs are easy. (def *a-ref* (ref {:a {:x 5} :b {:y 6}})) (dosync (alter *a-ref* assoc-in [:a :x] 7)) => {:a {:x 7} :b {:y 6}}
06:28kotarakThe code outside the dosync always sees a stable version.
06:28turbo24prguh, that's a nice example.
06:28turbo24prgthanks!
06:29BigTomalso, have a look on http://en.wikibooks.org/wiki/Clojure_Programming/By_Example
06:29kotarakor with update: (dosync (alter *a-ref* update-in [:b :y] inc)) => {:a {:x 7} :b {:y 7}}
06:30kotarakA lot of things in Clojure work similar. So when you grok the idea once, it's easy to transfer to atoms, agents, etc...
06:32turbo24prgconcurrency is sth. i really missed in common lisp
06:32turbo24prgvery cool
06:33eleftherioswhat's is the most mature web framework for clijure so far? Compojure?
06:33turbo24prgdid you came from another lisp? or are you "java guys"?
06:34kotarakturbo24prg: I'm more a Scheme guy. Having more experience in C and a bit OCaml.
06:35RaynesI come from Haskell. With a little experience in C# and several other irrelevant languages.
06:35BigTomturbo24prg: while I'm a Java guy (which why I keep asking the guys here for help!)
06:35turbo24prgwow.
06:36kotarakGood mixture. :)
06:36turbo24prgyeah :)
06:36BigTomturbo24prg: clojure is definitely a Lisp, so you should feel very at home
06:37zakwilsonBigTom: waching-label looks cool, but it did not work for me. The agent updates in real-time, but the GUI does not.
06:37turbo24prgnice, assoc supports "paths"
06:37kotarakClojure has everything, which I missed about other Lisps: Immediate access to libraries (Java, but hey, it gets the work done) and the "smallness" of Scheme (in terms of core functions)
06:38kotarakturbo24prg: there is also a "normal" assoc
06:38BigTomzakwilson: Hm, I 'm having problems with the pattern too
06:38BigTomzakwilson: does cells itself work for you?
06:38zakwilsonUsing watchers has the same results I was having trying to do it manually.
06:39zakwilsonI haven't tried cells itself - just watching-label.
06:39BigTomzakwilson: try running cells to confirm your environment is ok
06:41zakwilsonI just did. It works.
06:43zakwilsonI just tried using an atom instead of an agent since that's what cells does. No change.
06:43BigTomzakwilson: could you post your code?
06:44BigTomlisppaste8: url
06:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
06:46zakwilsonI'm not sure how much I can separate the problem code from the whole app and still reproduce the problem.
06:46zakwilsonAnd the whole app is a bit big for a paste...
06:46zakwilsonSo... http://github.com/zakwilson/imagesieve/tree/master
06:47zakwilsonThis is before any attempt to use a watcher, and the UI code is a bit more messy than I'd like.
06:48zakwilsonWait... does this thing depend on my utilities file? I need to check.
06:49zakwilsonIt does. I'll put that up on github too.
06:51zakwilsonDependency: http://github.com/zakwilson/zutil-clj/tree/master
06:51cadswhat's the -> macro called?
06:52zakwilsonI think I would call it "arrow".
06:53cadsit's pretty funky :D
06:55cadstakes a list of forms headed by a value, evaluates each form with the result from the previous form inserted into the second position of the form
06:55cadsI think.
06:55cadsDo we use it often?
06:58cadsif we have a few simple one parameter functions we can use it to compose function application like (-> x (f1) (f2) (f3)) => (f3 (f2 (f1 x)))
07:10BigTomzakwilson: just running it up now...
07:11Chousukecads: it has many uses :)
07:11Chousukecads: you can omit the parens though I think
07:11zakwilsonBigTom: (update-counter) works fine when it's not actively processing.
07:11Chousuke,(macroexpand-1 '(-> f1 f2 f3))
07:11clojurebot(clojure.core/-> (clojure.core/-> f1 f2) f3)
07:12Chousukeyeah, seems to work :/
07:13Chousuke,(macroexpand '(-> f1 f2 f3))
07:13clojurebot(f3 (clojure.core/-> f1 f2))
07:15BigTomzakwilson: well, I have some gray jpegs now :-)
07:16zakwilsonBut no up-to-date GUI saying how many.
07:19BigTomzakwilson: indeed
07:22BigTomzackwilson: it updates when you mouse-over the GUI
07:22zakwilsonBigTom: I may have improved things a bit. I moved the processing itself in to an agent.
07:23zakwilsonThe update isn't quite in sync that way, but it's pretty close.
07:36BigTomactually, it does update
07:37turbo24prgis there any way to differentiate between different types of struct?
07:37cadscan we write a macro that takes a form with arithmetic written with infix syntax, such as ((b * b) - 4 * a * c), and turns it the well formatted lispy equivalent, (- (* b b) (* 4 a c))? would this be considered a perversion?
07:37turbo24prgsay (defstruct a ..) (defstruct b ...). in CL i'd use typecase
07:38BigTomzakwilson: For me it updates the GUI pretty much at the same time the file appears
07:41zakwilsonBigTom: What sort of hardware are you running it on?
07:43BigToma single core ancient ubuntu box
07:44zakwilsonInteresting. There is a small logical difference in how it does things on single-core machines (map instead of pmap).
07:44zakwilsonI'm about to try it on an older single-core Windows box.
07:49Chousukecads: sure it's possible; just not trivial :)
07:51Chousukepersonally I don't think the infix syntax offers anything over prefix syntax :/
07:53Chousukeunless you're going to allow writing things like (b^2 - 4ac), but that's even more complicated.
07:53cadsunless you're doing algebra in ascii, I guess
07:54cadsthat's not so bad, your stuff is already in tokens, you just got to do a little parsing :D
07:54Chousukebut in essence, you "only" need a function that takes a list of operators and operands in infix form and transforms it into a similar list in prefix form :)
07:55cadsI cant really think of examples of algebra where prefix notation is absolutely horrific
07:56Chousukeit's maybe not the easiest to read if you put it all on one line.
07:57cadsI can think of places where infix operators would be more mnemonic and easier to parse for a human reader
07:57Chousukesomething like (/ (* 5 (- 4 z)) 2)
07:57zakwilsonBigTom: The latest version works as intended everywhere, without mousing over the UI. I think the problem was the async update to the GUI by a callback from the GUI's own thread.
07:57Chousukebut that's really much better if it's properly indented.
07:58Chousukelisppaste8: url
07:58lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
07:59lisppaste8Chousuke pasted "like this" at http://paste.lisp.org/display/74634
07:59cadseh, that's not too bad, I bet one gets used to it
07:59cadslooking at your second example now
08:00Chousukethat even looks a lot like how you'd write it if you were writing using real notation instead of ascii formulas
08:00cadsyeah, with / you can separate the numerator from the denominators and it looks nice :)
08:27turbo24prgassoc supports paths, but find doesn't? :/
08:31turbo24prgassoc-in supports them, find/get doesn't.
08:39Chousukeget-in? :)
08:39Chousuke,(doc get-in)
08:39clojurebot"([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys"
08:41Chousukeeven works with vectors if you supply integer keys :)
08:41BigTomzakwilson: cool
08:54turbo24prguh, cool
08:59kotarakHmmm.. Should get-in support a default value?
09:02BigTom,(includes? :k {:k :v :k1 :v})
09:02clojurebotjava.lang.Exception: Unable to resolve symbol: includes? in this context
09:02BigTomoops
09:02kotarak(doc contains?)
09:02clojurebotReturns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'.; arglists ([coll key])
09:03BigTomkotarac: cheers
09:05kotarakBigTom: another useful repl function
09:05kotarak(doc find-doc)
09:05clojurebotPrints documentation for any var whose documentation or name contains a match for re-string-or-pattern; arglists ([re-string-or-pattern])
09:06BigTomkotarak: I can never remember that one
09:07BigTomIts very weird, I had an app that worked 3 weeks back and its busted all over now
09:07BigTomI think I must have every one of the bad idioms Rich is tidying up :-(
09:08Hunkotarak: though i liked the old name apropos more :)
09:08hoeckwere there any breaking changes in the last 3 weeks??
09:09BigTomI don't know, watchers changed in early Jan
09:09BigTomI used clojure-contrib includes? when I should have used contains - see above
09:10BigTomSo, its all down to me really :-/
09:11hoeckah, okay
09:11BigTomkotarak: I fixed the watcher thing, I had too many braces
09:11kotarakHun: (def apropos find-doc) ;)
09:11Hun:)
09:12Hunof course. but for some reason, i found find-doc unintuitive
09:12Hunthough that might be just musclememory to hit (apropos " before thinking
09:12kotarakI find it mnemonic.
09:13kotarakapropos is used here a bit differently.
09:19BigTomagent question
09:19BigTomif I send actions to an agent from one thread then is the execution order guaranteed to be the same as the send order?
09:19ChouserBigTom: yes
09:20ayrnieuone of the first things I wrote in clojure: http://paste.lisp.org/display/74207 - apropos. It needs some work.
09:20BigTomthought so
09:20BigTomthanks
09:21ChouserAh, here it is, tucked into the middle of a paragraph: "Actions dispatched to an agent from another single agent or thread will occur in the order they were sent, potentially interleaved with actions dispatched to the same agent from other sources."
09:21Chouserfrom http://clojure.org/agents
09:22ayrnieu...which explains how an agent 'looping' over sends to itself can be stopped.
09:23BigTomChouser: Thank you for explaining before RTFMing :-)
10:58turbo24prghmm, (doseq [a ... b ...] ... does loop a1 b1, a1 b2, ...
10:58turbo24prgthought about (doseq [[a b] (interleave as bs)] ... but it doesn't work because interleave creates no sublists
10:59turbo24prgany handy way to iterate over multiple lists element for element?
10:59kotarak(doc partition)
10:59clojurebotReturns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap.; arglists ([n coll] [n step coll])
10:59kotarak(partition 2 (interleave a b))
10:59turbo24prgneat
10:59turbo24prgthanks!
11:02kotarakFor two things, one could maybe exploit zipmap. But that would be an ugly hack.
11:09Chouserwhat about just (map ... a b) ?
11:10kotarakdoseq suggest side effects. So (dorun (map ... a b)), beh. :/
11:13Chousermm, good point.
11:19BigTomhow would I get a lazy sequence of random numbers?
11:20ayrnieu,(take 30 (repeatedly #(rand-int 30)))
11:20clojurebot(15 12 3 12 2 10 7 23 4 2 22 13 17 9 19 14 10 8 6 4 1 4 27 17 6 9 11 22 2 5)
11:20ayrnieu,(.contains (apply str (take 1000000 (repeatedly #(char (+ (int \a) (rand-int 26)))))) "ayrnieu")
11:20thickeyrhickey or Chouser: where can i find the script that currently generates the api page?
11:20clojurebotfalse
11:22BigTomayrnieu: thanks
11:29Chouserthickey: I've never seen that script, only heard rumors of its existance.
11:30thickeyChouser: =) okay, thanks
11:37BigTomok so I have this:
11:37BigTom,(into #{} (partition 2 (interleave [1 2 5 4] [5 6 1 8])))
11:37clojurebot#{(2 6) (4 8) (1 5) (5 1)}
11:38BigTombut I really want a set of vectors
11:38ayrnieu,(class #{(2 6})
11:38clojurebotEval-in-box threw an exception:Unmatched delimiter: }
11:38ayrnieuOK. (map vector ...) ?
11:39ayrnieuwell, I'd think that'd work, but it doesn't.
11:39ayrnieu,(into #{} (map #(apply vector %) (partition 2 (interleave [1 2 3 4] [5 6 1 8]))))
11:39clojurebot#{[2 6] [4 8] [1 5] [3 1]}
11:39kotarak(doc vec)
11:39clojurebotCreates a new vector containing the contents of coll.; arglists ([coll])
11:40kotarak,(map vec (partition 2 (interleave [1 2 3] [4 5 6])))
11:40clojurebot([1 4] [2 5] [3 6])
11:40BigTomah, sweet
11:40ayrnieujust found that with (find-doc "vector") :-)
11:46BigTomanother includes? bites th edust
11:46thickeyChouser: this looks like it: http://paste.lisp.org/display/71857
11:49Chouserthickey: ah, thanks.
11:51thickeyi get a java.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray when running it. i know i've had that issue before but forget how to sort it out
11:52ayrnieuhttp://gee.cs.oswego.edu/dl/concurrency-interest/index.html , but other changes are needed.
11:52ayrnieudurka42 went through it earlier: http://clojure-log.n01se.net/
11:54Chouser,(map vector [1 2 3] [4 5 6])
11:54clojurebot([1 4] [2 5] [3 6])
12:19thickeyrhickey: does the jsr166y.jar that parallel.clj was developed with no longer match the one located here? http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
12:20rhickeythickey: there's a jsr166y.jar in the files section of the google group - try that
12:20thickeyrhickey: it seems like there was some refactoring and the parallel classes are now in extra166y.jar
12:20thickeyrhickey: ok
12:24turbo24prgto add an element to a sorted-set i need to (apply sorted-set (cons 3 (sorted-set 5 1 3 2 4 1)) to get back a sorted-set again, right?
12:24kotarak(conj the-set the-thing)
12:25turbo24prgneat. thanks. finding all the methods is hard. and it's cool if they exist :)
12:26kotarakconj works also for maps, vectors, lists, ...
12:28Vargr2I can't seem to get sensible error messages and tab-completion to work with the current versions of clojure (trunk, HEAD), clojure-mode (HEAD) and swank-clojure (HEAD) - is that a known problem or am I missing something?
12:28turbo24prgCL felt a lot more practical then scheme, but clojure seems even more practical
12:30turbo24prgVargr2: updated this morning, seems to work here
12:31Vargr2turbo24prg: I get "Synchronous Lisp Evaluation aborted" when trying to expand. No problem with CLISP and SBCL, so SLIME should be alright, no?
12:31kotarakturbo24prg: http://clojure.org/api gives a nice summary
12:31kotarakfor functions I mean
12:34turbo24prgkotarak: i'm browsing /api, /sequences all the time :)
12:37turbo24prgVargr2: i'm using 23.0.60.1, no probs. duno
12:39turbo24prgit shouldn't be possible that the hash-codes of strings would < but the strings themself >, right?
12:39Chousukewhy not? :/
12:39ChousukeI don't think hash codes support ordering
12:41turbo24prghttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#hashCode()
12:42turbo24prg,(hash "6")
12:42clojurebot54
12:42turbo24prg,(hash "7")
12:42clojurebot55
12:42turbo24prg,(hash "71")
12:42clojurebot1754
12:42durka42,(hash "7")
12:42clojurebot55
12:43turbo24prgimho they're ordered, no?
12:44ayrnieu,(hash "merry had a little lamb whose fleece was white as snow, and every where that mary went the lamb was sure to go")
12:44clojurebot-1376680459
12:44ayrnieuit's positive if you spell her name correctly, but still a counterexample.
12:45clojurebotsvn rev 1241; fixed pmap so parallel in first n steps
12:46turbo24prgarbscht: thanks
12:46turbo24prgerm, ayrnieu.
12:48durka42,(Integer/toHexString -1376680459)
12:48clojurebot"adf185f5"
12:50turbo24prgso, to compare strings i'd have to call java then?
12:51turbo24prgno string<, string= ...
12:55Chouser,(compare "abc" "abc")
12:56Chouser(doc compare)
12:56Chouserclojurebot's dead
12:58durka42you can't just use = ?
12:58durka42= uses .equals internally
13:00turbo24prgbut < works only on numbers
13:01durka42oh, true
13:02durka42(doc compare)
13:02clojurebotComparator. Returns 0 if x equals y, -1 if x is logically 'less than' y, else 1. Same as Java x.compareTo(y) except it also works for nil, and compares numbers and collections in a type-independent manner. x must implement Comparable; arglists ([x y])
13:02durka42(compare "bar" "bar")
13:02durka42,(compare "bar" "bar")
13:02clojurebot0
13:02durka42,(compare "bar" "quux")
13:02clojurebot-15
13:02durka42,(compare "quux" "bar")
13:03clojurebot15
13:05ayrnieu,(let [m "merry had a little lamb whose fleece was white as snow, and every where that mary went the lamb was sure to go"] [(hash m) (sort [(hash m) (hash "a")]) (sort [m "a"])])
13:05clojurebot[-1376680459 (-1376680459 97) ("a" "merry had a little lamb whose fleece was white as snow, and every where that mary went the lamb was sure to go")]
13:07ayrnieubut if you're paranoid, (sort #(.compareTo %1 %2) ...)
13:07turbo24prguh, i still thing a way to cl. cool that there are so many generic functions
13:07turbo24prgthanks.
13:51clojurebotsvn rev 1242; [lazy] switched concat to lazy-seq, added Sequence, printing of sequences, more returns non-nil
13:54adakkakcan someone tell me what is wrong with this basic program? I am just learning clojure http://paste.lisp.org/display/74642
13:55leafwadakkak: ([] ([])) makes little sense. You meant ([] []) ... yet it still makes little sense: for no args, return empty vector?
13:56adakkakleafw: what should I be returning?
13:56Chousukeadakkak: that looks like you're trying to do haskell-style pattern matching
13:57Chousukeclojure doesn't support it :/
13:57adakkakdoes clojure have any pattern matching for function's arguments?
13:58Chousukeno.
13:58Chousukewell, there's destructuring
13:58Chousukewhich is kind of similar, but not pattern matching.
13:59Chousuke,(apply str (map #(str % "s") '("this" "is" "a" "test")))
13:59clojurebot"thississastests"
13:59Chousukehmm
13:59Chousukenot quite
13:59adakkakdo you know if scheme has pattern matching?
13:59ChousukeI'm not sure, but I don't think it does.
14:00Chousukeadakkak: what you're doing in that piece of clojure code is defining two overloads of the same function, just of different arity.
14:01Chousukeyou're never even calling the nullary version :)
14:01eyerisCould someone point me to the explaination of the & symbol in defmacros?
14:01adakkakChousuke: so why doesn't the piece of code work?
14:01Chousukeadakkak: you don't have a termination clause. it keeps recursing infinitely.
14:03Chousukeat some point it'll call "(plural-sentence nil)" but that's still calling the one-argument version, which will again call (plural-sentence nil)
14:03Chousukesince (rest nil) is nil
14:03adakkakChousuke:Ahh, so (rest ()) is nil?
14:03Chousukeyeah; though you'll never see a () there :/
14:03Chousukenil is not equal to ()
14:04Chousuke,(rest nil)
14:04clojurebotnil
14:04Chousuke,(rest '())
14:04clojurebotnil
14:04Chousuke(= '() nil)
14:04Chousuke,(= '() nil)
14:04clojurebotfalse
14:05Chousuke,(rest '(1))
14:05clojurebotnil
14:10adakkakChousuke:I fixed my little program and am now wondering why I get ("test")s in the output for http://paste.lisp.org/display/74642#2
14:13ayrnieuadakkak: (if (= (count sentence) 1) (plural_word sentence)
14:14adakkakayrnieu: what is wrong with it?
14:15Chousukeadakkak: http://paste.lisp.org/display/74642#3
14:15Chousukeadakkak: the sentence is still a list
14:16Chousukeadakkak: you want the word from it
14:16Chousuke,(str (first '("test")))
14:16clojurebot"test"
14:17Chousukeif you forget the first, you get the parens too
14:17Chousukeadakkak: as an aside, use dashes instead of underscores in naming
14:17Chousukeplural-word instead of plural_word
14:17adakkakChousuke: is that the convention in clojure?
14:18ayrnieuthat's the convention in every language that permits dashes in symbols.
14:18dreishadakkak: It is in all Lisps, but beyond convention, I think underscores in Clojure are informally reserved for gensyms.
14:19adakkakI am wondering if having (plural-word (first sentence)) twice in the code is considered bad practice in clojure?
14:20Chousukeit's not a deadly sin
14:21adakkakalso, how do you know that there is a keyword called remaining? I am checking the api and there is no mention of it!
14:25Chousukeadakkak: it's not a keyword
14:25Chousukeadakkak: I bind it, in the if-let
14:25aartist_why clojure?
14:26Chousukeadakkak: http://paste.lisp.org/display/74642#5
14:26adakkakso that is the difference between a regular if and if-let
14:26Chousukeadakkak: if-let makes a binding at the same time
14:26adakkakmakes sense
14:27Chousukeit's a shortcut for (let [foo bar] (if foo dostuff do-otherstuff))
14:27Chousukeie. that would be: (if-let [foo bar] dostuff do-otherstuff)
14:28Chousukewhere the do-otherstuff is executed when "foo" is non-true
14:29keithbIs it true that, in a given dosync transaction, all mutations will occur in sequential order, even if they are commute's and not alter's?
14:30Chousuke"sequential order"?
14:30keithbI mean in the order in which they were specified in the code.
14:30ChousukeI think with commutes the order is not guaranteed
14:30adakkakChousuke: how does foo become false, I though even nil does not evaluate to false
14:31Chousukeadakkak: hm? :/
14:31Chousukeboth "nil" and "false" are non-true values in clojure
14:31ayrnieuhttp://paste.lisp.org/display/74642#6 defmulti version.
14:32Chousuke,(if nil "nil is true" "nil is false")
14:32clojurebot"nil is false"
14:32Chousuke(if-let [foo nil] :true :false)
14:32Chousukegah
14:33Chousuke,(if-let [foo nil] [:true foo] [:false foo])
14:33clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
14:33Chousuke... okay, I fail.
14:33Chousukefoo is of course not bound if it'd be false :P
14:33ayrnieu,(if-let [foo true] [:true foo] [:false foo])
14:33clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
14:34Chousuke,(if-let [foo 1] foo :nothing)
14:34clojurebot1
14:34Chousuke,(if-let [foo nil] foo :nothing)
14:34clojurebot:nothing
14:34ayrnieusensible.
14:37adakkakChousuke: got it
14:53lisppaste8ayrnieu pasted "defmulti examples" at http://paste.lisp.org/display/74647
14:53ayrnieutranslated from mercury translated from haskell.
14:55ayrnieuI backquoted json-ex with the idea of showing that you can use symbols naturally and still execute code, but defmulti doesn't take kindly to symbols. Oh well.
15:23hiredmanayrnieu: I imagine you wanted ' not `
15:23ayrnieuhiredman - no, I want ` there.
15:24hiredmanok
15:24Chousukeayrnieu: maybe defmulti didn't like the namespace-qualified symbols.
15:24Chousuke,(= 'foo `foo)
15:24clojurebotfalse
15:25hiredman,`foo
15:25clojurebotclojure.core/foo
15:25hiredman,'foo
15:25clojurebotfoo
15:26hiredmanhuh
15:26Chousukehiredman: did you notice my (doc fix? (I hope I didn't break anything)
15:26hiredmanChousuke: no I did not notice anything
15:27ayrnieuaha. OK, defmulti does work with symbols, but his `foo 'foo difference only reemphasises that symbols will not work for data-structures like this.
15:32hiredman(doc namespace)
15:32clojurebotReturns the namespace String of a symbol or keyword or nil if not present ; arglists ([x])
15:32hiredman(doc for)
15:32clojurebotList comprehension Takes a vector of one or more binding form collection expr pairs each followed by an optional filtering when while expression when test or while test and yields a lazy sequence of evaluations of expr Collections are iterated in a nested fashion rightmost fastest and nested coll exprs can refer to bindings created in prior binding forms take 100 for x range 100000000 y range 1000000 while y x x y ; argli
15:32hiredmanexcellent
15:34Chousukethe docstrings aren't properly punctuated, which is a slight problem
15:37cooldude127Chousuke: what's changed?
15:37Chousukeit removes whitespace and handles nil arglists
15:38Chousuke(doc *print-dup*)
15:38clojurebotWhen set to logical true objects will be printed in a way that preserves their type when read in later Defaults to false
15:38Chousukeno arglist :)
15:39cooldude127oh
15:39cooldude127but why does it remove punctuation?
15:39Chousukeit doesn't.
15:40Chousukethere's no punctuation to remove :P
15:40cooldude127oh. i'm confused
15:40hiredmanChousuke: maybe [^ ] instead of \\W or whatever
15:40Chousukesee the docstring for *print-dup* in your repl.
15:41cooldude127Chousuke: i see nil
15:41cooldude127maybe i'm behind
15:41Chousukeheh, yeah
15:41cooldude127Chousuke: but my (doc for) has periods
15:41hiredman(doc for)
15:41clojurebot ; arglists ([seq-exprs expr])
15:41ChousukeI guess I forgot proper punctiation from teh docstrings
15:41hiredmanwhoops
15:42Chousuke:D
15:42cooldude127lol
15:42hiredman(doc for)
15:42clojurebotList comprehension Takes a vector of one or more binding form collection expr pairs each followed by an optional filtering when while expression when test or while test and yields a lazy sequence of evaluations of expr Collections are iterated in a nested fashion rightmost fastest and nested coll exprs can refer to bindings created in prior binding forms take 100 for x range 100000000 y range 1000000 while y x x y ; argli
15:43cooldude127see even the parens and stuff for the example are gone, that can't be good
15:45hiredman(doc for)
15:45clojurebotList comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000000) y (range 1000000) :
15:45cooldude127yay
15:46hiredmanswitched from \\W+ to \\s+
15:47MarkVolkmannThe REPL doesn't recognize the union function.
15:48MarkVolkmann(doc union) comes back with "Unable to resolve var: union in this context".
15:48MarkVolkmannI'm trying to use it to combine two sets into one.
15:48hoeck,(doc clojure.set/union)
15:48clojurebot"([xset yset]); Returns a set that is the union of the two sets."
15:48ChousukeMarkVolkmann: it's not in the clojure.core namespace :)
15:49MarkVolkmannThanks! Looking at http://clojure.org/api, I'm not sure how I could have known that.
15:49Chousukehmm
15:50hiredmanhttp://clojure.org/api#toc588 <-- it is in the clojure.set section of the api
15:50Chousukeit does have the section titled
15:50Chousukebut it doesn't really stand out.
15:50MarkVolkmannAh, I see. It's kind of hidden, just after the documentation for pvec.
15:50MarkVolkmannIt's in the same font as all the function names, so it's easy to miss.
15:50Chousukedefinitely needs improvement :/
15:51Chousukeeven better would be to have everything explicitly show their namespace.
15:54ayrnieu,(name 'user/x)
15:54clojurebot"x"
15:54ayrnieuhow do I get "user" out of that?
15:54ayrnieu,(namespace 'user/x) ;; oh.
15:54clojurebot"user"
15:56ozy`,(map + (range 20) (range 0 40 2))
15:56clojurebot(0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57)
15:56ozy`,(map #'list (range 20) (range 0 40 2))
15:56clojurebot((0 0) (1 2) (2 4) (3 6) (4 8) (5 10) (6 12) (7 14) (8 16) (9 18) (10 20) (11 22) (12 24) (13 26) (14 28) (15 30) (16 32) (17 34) (18 36) (19 38))
15:57hiredman,(map list (range 20) (range 0 40 2))
15:57clojurebot((0 0) (1 2) (2 4) (3 6) (4 8) (5 10) (6 12) (7 14) (8 16) (9 18) (10 20) (11 22) (12 24) (13 26) (14 28) (15 30) (16 32) (17 34) (18 36) (19 38))
15:58ozy`,;
15:58clojurebotEval-in-box threw an exception:EOF while reading
15:58ozy`,(display 'woot)
15:58clojurebotjava.lang.Exception: Unable to resolve symbol: display in this context
15:58ozy`,(println '(pizza))
15:58clojurebot(pizza)
16:01ozy`,(println '(SYMBOLS IN ALL CAPS))
16:01clojurebot(SYMBOLS IN ALL CAPS)
16:15ayrnieuhttp://gist.github.com/55662 <-- similar, but checks at compile-time that you've handled every case.
16:19hiredmanclojurebot: parens is <reply>????? ????
16:19clojurebotRoger.
16:20Chousuke?)
16:21hiredmanoooh
16:22hiredmangoogle translate has a "ajax" (json) api
16:22danlarkinI smell a new feature
16:56blbrowndoes anyone remember where the clojure api examples are on the wiki
16:57blbrownnevermind, http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
16:57LordOfTheNoobsclojurebot: api examples?
16:57clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
16:58blbrownI was looking at stuart hollaway's blog and thinking, dang these are good examples...he should write a book on this stuff. Lo and behold he is
17:04blbrownhttp://paste.lisp.org/display/74655 is this not valid code
17:07durka42you might have missed some parens around the println
17:07durka42which line is 177?
17:07gnuvince_blbrown: use e#
17:07ayrnieu(let [e (gensym)] `(try ... (catch Exception ~e (. ~e ...))))
17:07blbrowndurka42 error at when I called it (when-try (clojure.xml/parse db-path))
17:08ayrnieuif you really want 'e, you can ~'e
17:09durka42i mean there's no real need for a gensym there
17:09ayrnieu,[`(list ~'e) `(list e)]
17:09clojurebot[(clojure.core/list e) (clojure.core/list clojure.core/e)]
17:20blbrownthis is what I ended up with, works. (defmacro when-try [body] `(try (~@body) (catch Exception ~'e nil)))
17:22Chousersorry I'm jumping in late here, but why ~'e instead of e# ?
17:22blbrownand I guess I only need ~@body not (~@body)
17:23ayrnieu~body not (~@body)
17:23clojurebotIt's greek to me.
17:25blbrown~your mom
17:25clojurebotHuh?
17:25blbrown~mom
17:25clojurebotIt's greek to me.
17:26durka42Chouser: there's no user code being run with e bound, so why bother gensymming?
17:27blbrownI just pjb3 I just twittered you, small world isn't it
17:28pjb3blbrown: indeed
17:33Chouserdurka42: hm, I guess I tend to think it the other way around. There's no need to give 'e' a particular name, so why bother fancy-quoting it?
17:33gnuvince_,(= Short java.lang.Short)
17:33clojurebottrue
17:34gnuvince_hmmm
17:34durka42,(time (dotimes [_ 1000] (gensym)))
17:34clojurebot"Elapsed time: 12.013 msecs"
17:35durka42,(time (dotimes [_ 1000] `(~'e)))
17:35clojurebot"Elapsed time: 1.997 msecs"
17:36ayrnieu10ms difference at compile-time per thousand. I'll get right on optimizing for that.
17:36gnuvince_hahah :)
17:37durka42kind of a silly reason though
17:37durka42i guess if you refactored the macro later and bound e before user code, then forgetting to change it to e# could cause problems
17:37durka42:)
17:53durka42i must find a way to work "absquatulate" into normal conversation
17:57Chouserwouldn't it immediately cease to be a normal conversation?
17:57durka42quite possibly
17:57Chouserall the better, I suppose.
17:59gnuvince_durka42: what does that mean?
17:59durka42it means to leave abruptly
18:00gnuvince_Easy
18:00gnuvince_Go to a friend's
18:00gnuvince_Pretend you have an urgent phone call on your cell
18:00gnuvince_"I'm sorry, I must absquatulate!"
18:01hiredman"I cannot help but notice you are absquatulating with all the food"
18:08hiredmanI forget, is there a pretty printer yet?
18:08ayrnieuthere's cl-format
18:09hiredmandoes that do indenting and what not?
18:09ayrnieuI haven't explored it.
18:09hiredmanwhere is there?
18:09ayrnieugithub.
18:10durka42i believe "think about a pretty printer" is on the cl-format todo list
18:10hiredmandamn
18:17cooldude127Woo, colloquy for iPhone :)
18:21dreishclojurebot: clojure-mode?
18:21clojurebotclojure-mode is an Emacs mode for Clojure, found at git://github.com/jochu/clojure-mode.git
18:21dreishThanks.
18:22durka42to thank clojurebot,
18:22durka42clojurebot: botsnack
18:22clojurebotthanks; that was delicious. (nom nom nom)
18:36eeehi
18:37eeehere's my latest gripe: I api is gibberish to me
18:37eeelet's take a simple example that I understand
18:38eeehi
18:38eeeabout to complain :)
18:38Chousukegibberish? you mean you can't understand it?
18:38eeeyup
18:38ChousukeI guess it could be a bit better
18:38eeehere's an example
18:38ChousukeYou should read the wiki to get started; the api is more of a reference.
18:38eeelook at "doall" . . .with doall, I know what it does
18:38eeeand I understand the english description
18:38eeevery nice
18:38eeeso I'm lucky
18:39eeecause I can't make heads or tails of the gibberish part
18:39Chousukewhich part is that?
18:39eee([coll] [n coll]) or something?
18:39eeewhat the heck?
18:39Chousukeah, that's the possible parameter lists
18:39ayrnieu(defn foo ([a] (mangle a)) ([a b] (frob a b)))
18:40Chousukeeee: that means it can take either two parameters, or one
18:40eeeoh
18:40eeeshould never use the brckets there
18:41eeeshold be, like (<coll> <n coll>)
18:41Chousukeum, no
18:41eeebrackets are actually used in the language
18:41ayrnieueee, the 'foo' I just defined is valid clojure.
18:41eeeyes I get it
18:41Chousukeeee: that's why the parameter lists are like that too
18:41eeeit takes an a or an a and a b
18:41Chousukethey are like they are in the language itself.
18:42eeei've made functions like that
18:42eeeI assume that's a multimethod, but I don't know
18:42Chousukeit's not a multimethod
18:42eeeoh drat
18:42Chousukeit's simply an overloaded function
18:42Chousukeanyway, for complex parameters, using the language's own notation is better.
18:42eeeyeah . . .I was hoping that was a multimethod
18:42eeeoh well
18:42dreisheee: Have you read Programming Clojure?
18:43eeenot yet
18:43dreishIf you're interested enough to ask this many questions, why not buy the book?
18:43eeedoesn't make sense to use something that's used in the language cause you might take it literally but I guess I understand now
18:43dreishIt's an excellent way to learn the language.
18:43Chousukefor example, if you say your parameter list is a [[a b c] & rest] someone familiar with clojure and destructuring can easily tell how to call it.
18:44eeei didn't know that was destructureing. that's cool . . that fills in another blank. I use that form
18:44eeeok, so how would the docs look for something that destructures like that?
18:45Chousukeit would say its possible parameters are ([[a b c] % rest])
18:45ayrnieubut: destructuring doesn't work on lists, and it isn't coll-agnostic.
18:45Chousukeer
18:45Chousuke&*
18:46Chousukeeee: so you see, the parameter list in the doc exactly matches the function definition :)
18:46eeei've used [a b c & rest]
18:46Chousukeeee: that's a different function
18:46eeeyeah
18:46Chousukeer, a different kind of parameter list that is.
18:46Chousukemy function, you'd call like (fun [1 2 3] 4 5 6)
18:47eeewell, it doesn't exactly match the function definition because it's missing the context of the defn and the name of the function
18:47Chousukeso a, b and c would be 1, 2 and 3 respectively, and rest would be (4 5 6)
18:47eeebetter docs would be
18:47Chousukeeee: the name of the function is printed above isn't it.
18:47eee(defn foo [a] ... [a b] ...)
18:48eeenow THAT would rock
18:48eeewhat I just wrote leaves no ambiguity
18:48Chousukewhere would you put the documentation? :/
18:48Chousukealso I don't understand why this is at all better.
18:49Chousukeit's basically hte same.
18:49Chousukejust with a defn and a few parentheses.
18:49eeewhere it says "arguments" . . . .that's not quite accutate
18:49durka42it is ambiguous... is [a b] another param list, or is the vector part of the function
18:49eeethere's a needless list around it . . .a set of parens confusing things
18:49eeenight as well throw the defn in there
18:49Chousukeeee: it's not a needless list
18:49Chousukeit's a list of the possible argument vectors you can pass in
18:50eeewell, I guess I get it now . . .but I would never have needed to my way. would have had only one interpretation
18:50ChousukeI don't see how :/
18:50eeewhat durka42 said is why
18:51eeeit's awash with symbols . . . .
18:51eeeanti-tufte
18:51ChousukeI don't follow :/
18:52eeethat () around the whole thing
18:52eeeI'd even go for
18:52Chousukeeee: well, that's because it's a list.
18:52Chousukeit's a list of the ways to call the function
18:52eeearguments: a | a b
18:52Chousukethe list is more clojurey :/
18:52eeethe vector isn't even needed
18:52Chousukeyes it is.
18:53eeejust use a pipe to separate the two choices
18:53eeeotherwise I'm thinking . . ."takes a vector with a collection, what?"
18:53eeenoise
18:53eeea | a b ...
18:53eeeor
18:53eeein the case of doall
18:53eeecoll | coll1 coll2 ...
18:54eeecoll | coll1 coll2 ... colln
18:54ayrnieuso it takes a, a pipe, and ab . Or does it pipe a into a b? Is this like the unix shell? I'M CONFUSED.
18:54Chousukeeee: it's not like that though
18:54eeenowlol
18:54Chousukeit's coll | n coll
18:54eeedoall?
18:54Chousukeyeah
18:54eeei upset rhickey
18:54Chousukethe thing is, anyone familiar with how to define clojure function definitions can read the docs :/
18:54eeehe's not gonna let me play
18:54Chousuke...
18:54Chousukehow to define clojure functions*
18:55eeeok, awesome . . .one more thing people have to learn
18:55eeeI'm trying to help this stuff be how we all program
18:55eeecause I like it
18:55eeetoo bad rich missed that part
18:55eee:(
18:55eeein unix
18:55Chousukewell... clojure is not going to be very useful to you if you don't learn how to define clojure functions.
18:56eeeangle brackets are reserved for <variable>
18:56eeeso maybe
18:56hiredmanit being functional and all
18:56ayrnieueee, it's useful to distinguish between newbie problems (oh, now that I know X, I'll never worry about this ever again) and real, persistent problems. And, correspondingly, newbie-problem improvements and real improvements.
18:56Chousukein C docs, the functions are just as often given as "void foo(bar, baz)" in docs, so I don't see your point.
18:56Chousukeclojure is not the unix shell.
18:56eee<coll> | <coll1> <coll2> ... <colln>
18:57eeeyou should see my point
18:57eeein C
18:57eeeyou just see the prototype
18:57eeewithout the body
18:57eeebut in clojure it's all split up
18:57eeethe name
18:57eeethen a different section with a list of params
18:57Chousukethey're not that far apart...
18:57eeewhy put the parens like it is a c function
18:57ayrnieuit's not just split up in the doc, it's split up in the function.
18:58eeewhen you write it, you use clojure syntax
18:58Chousukeeee: eh, the parens aren't ther for that purpose. it's a *list*, you see.
18:58Chousukeso you use parens.
18:58eeewhen you see it in the api, you see C syntax
18:58eeethe parens wrap the params for some reason
18:58eeeok
18:58eeea list of optional cases
18:58durka42"some reason" being so that the compiler can parse it correctly
18:58durka42yes
18:59gnuvince_Did I miss something interesting/inflamatory?
18:59eeeI dunno. just seems like if a prototype makes sense in c of java, clojure should do it like I wrote it
18:59Chousukeeee: that list of argument vectors actually exists as a data structure in the fuction metadata.
18:59eee(defn foo [a] ... [a b] ...)
18:59Chousukethe documentation just prints it as is.
18:59eeelike that right there
19:00eee,(doc doall)
19:00clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive rests of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
19:00Chousukeeee: but the problem is that that's not a prototype; that's a definition
19:00hiredman,(:arglists (meta #'println))
19:00clojurebot([& more])
19:01eeeok, if I ask for arglist, that's one thing
19:01eeeif I ask for api, that's another
19:01ChousukeI really don't see a problem.
19:01Chousukeit's a convention.
19:01Chousukeget used to it.
19:01eeelooks like all someone did for api was call arglist and comments
19:01ayrnieuso write a my-doc and show us how much better it is.
19:01eeeconvention . . . this is why I brought up tufte
19:01Chousukeeee: yeah, that's pretty much what it is.
19:02hiredman,(:arglists (meta #'my-doc))
19:02clojurebotjava.lang.Exception: Unable to resolve var: my-doc in this context
19:02hiredman,(:arglists (meta #'mydoc))
19:02clojurebotjava.lang.Exception: Unable to resolve var: mydoc in this context
19:02hiredman,(:arglists (meta #'doc))
19:02clojurebot([name])
19:02hiredmanhmmm
19:02Chousukeeee: but what the arglist looks like is the least of the documentation worries.
19:02eee,(arglist doall)
19:02clojurebotjava.lang.Exception: Unable to resolve symbol: arglist in this context
19:02eee,(arglist #doall)
19:02clojurebotEval-in-box threw an exception:No dispatch macro for: d
19:02eee,(:arglist #doall)
19:02clojurebotEval-in-box threw an exception:No dispatch macro for: d
19:02Chousuke,(:arglists ^#'doc)
19:02clojurebot([name])
19:03Chousuke,(:arglists ^#'doall) ;een
19:03clojurebot([coll] [n coll])
19:03Chousukeeven :P
19:03eee,(:arglist ^#'doall)
19:03clojurebotnil
19:03Chousukemissed an s
19:03eee,(:arglists ^#'doall)
19:03clojurebot([coll] [n coll])
19:03eeeoh
19:04eeethanks for explaining it to me
19:04Chousukeyou're free to go write your own pretty-printer for documentation.
19:04Chousukesomething searchable or cross-referenced would be great. the regular API page is a bit plain :/
19:04lisppaste8ayrnieu pasted "print-doc" at http://paste.lisp.org/display/74659
19:04eeesounds like a good thing to practice with
19:05gnuvince_Chousuke: pretty sure there was someone who did something like that in Enclojure and posted about it on the mailing list.
19:05eeei know several people added doc writers to that list in the user group about third-party stuff
19:05eeewell, I was just complaining about the enclojure stuff
19:05eeethat's what brought me in here
19:05eee:)
19:06eeeall I know . . .is that I didn't feel like I had to ask this question for java. We can call it a broken language if we like
19:06eeebut for some reason
19:06eeepeople are able to get up and going on it
19:06eeewithout much understanding of "convention"
19:07eeebut I get it now
19:07eee(I think)
19:07eee:)
19:07eee,(doc arglists)
19:07clojurebotjava.lang.Exception: Unable to resolve var: arglists in this context
19:08eeeoh
19:08eeetaht's a key
19:08eeehuh?
19:08ayrnieu,(:a {:a :b})
19:08clojurebot:b
19:08gnuvince_It's a key on the meta-data.
19:08eeeyeah
19:08Chousuke,^#'doall
19:08clojurebot{:ns #<Namespace clojure.core>, :name doall, :file "core.clj", :line 1675, :arglists ([coll] [n coll]), :doc "When lazy sequences are produced via functions that have side\n effects, any effects other than those needed to produce the first\n element in the seq do not occur until the seq is consumed. doall can\n be used to force any effects. Walks through the successive rests of\n the seq, retains the head and returns
19:09eeenow can functions be named with colon at the beginning?
19:09Chousukeno
19:09gnuvince_But what was your objection? That Clojure doesn't have a Java-like syntax?
19:09ayrnieu,(let [x :a] [(class x) (x {:a :b})])
19:09clojurebot[clojure.lang.Keyword :b]
19:09eeeno
19:09eeethat the api makes sense
19:09eeein java
19:09eeewithout any confusing
19:09Chousukesymbols starting with a colon are always keywords :)
19:09eeenow I have to do a survey of newbies
19:10gnuvince_That the API makes sense?
19:10eeeand find out if it's just that I'm the only one who finally asked out loud
19:10gnuvince_The API or the API documentation?
19:10Chousukemaybe some note could be put on top of the API documentation page about how to read it
19:10ayrnieu,[(class (symbol ":a")) (class :a)]
19:10clojurebot[clojure.lang.Symbol clojure.lang.Keyword]
19:10eeei mean the format of the documentation
19:10Chousukeit's easy to read, but you do need to know how
19:10ayrnieu,(= (symbol ":a") :a)
19:10clojurebotfalse
19:10Chousukeor hm, actually
19:10eeethat would be good chosuke . . .I actually looked for that
19:10gnuvince_eee: on the web site? Yeah, it's not terrible. Feel free to contribute something better organized/indexed.
19:10eeemaybe it is there somewhere
19:11Chousukethe API page itself doesn't have your particular problem
19:11Chousukebut (doc foo) does :/
19:11gnuvince_Chousuke: how do?
19:11gnuvince_*so
19:11Chousukegnuvince_: he doesn't like the way argument vectors are just dumped out as a list
19:11eee\:
19:12eeei wish I cold be so succinct. well put
19:12Chousukethe api page actually has (doall coll), (doall n coll)
19:12eeeheh
19:12gnuvince_ah
19:12eeei don't even remember . . .I guess it's how it is in enclojure them
19:12ayrnieueee, did you see that paste? http://paste.lisp.org/display/74659 is all the heavy lifting that doc does wrt. documentation. So if you want something better, implement it and see if it matters.
19:13eeei just reflected on how I didn't get the api page, either . . .so gave up on it along time ago
19:13gnuvince_I figure once you learn it, the (doc) format makes sense; a list of all the different arities a function takes.
19:14Chousukeyeah.
19:15eeeyou know how people have legends in the corner of their slides sometimes in presentations? this guy http://www.edwardtufte.com/tufte/ has a lot to say about making stuff self-defining.
19:15eeeno conventions
19:15eeecognitively ergonomic
19:16gnuvince_Write a patch
19:16eeewell, I'm see what people think
19:16eeeI could just be an idiot
19:16eeebut it could be fun to play with
19:16eeeI grabbed that code
19:17gnuvince_like ayrnieu said, just go and edit print-doc
19:19eeek, thanks
19:19ayrnieu,[:a ::a]
19:19clojurebot[:a :clojure.core/a]
19:20eeeis print-doc part of doc?
19:20eee,(doc print-doc)
19:20clojurebot"([v]); "
19:20Chousukenot documented :)
19:21gnuvince_http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#2766
19:21gnuvince_print-doc is called by the doc macro
19:22Chousukeused by doc; if you do (binding [print-doc my-print-doc] (doc foo)) you might be able to override it
19:22Chousukestraight up redefining it works too, but it's less clean :/
19:22gnuvince_,'#{a b c}
19:22clojurebot#{a c b}
19:23eeeit barfed when I tried to redefine it
19:23hiredmanyou can actually rebind the var the doc macro is attached to too
19:23eeeok
19:23hiredman(binding [doc nil] (doc foo))
19:23ayrnieu,(binding [print-doc #(println (:name ^%) " - " (:arglists ^%))] (doc doall))
19:23clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive rests of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
19:24ayrnieuWFM. clojurebot is doing something special.
19:24hiredmanclojurebot rebinds doc internally
19:24hiredmanto another macro
19:25eeethat bot is cool. who wrote it?
19:25ayrnieu,(binding [print-doc #(println (:name ^%) " - " (:arglists ^%))] (clojure.core/doc doall))
19:25clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive rests of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
19:25ayrnieuoh well.
19:25Chousukehiredman wrote most of it. I did some restructuring and now hiredman seems to be implementing all kinds of weird features.
19:26hiredmanayrnieu: it rebinds doc which in that namespace refers to clojure.core/doc, so in that dynamic scope any reference to clojure.core/doc or doc is something else
19:31gnuvince_When interfacing with Java methods that might raise exceptions, what's the "better" way do deal with that in Clojure? Let them be thrown and let user code deal with it or deal with it at the library level and return nil?
19:32gnuvince_More concretely, I am dealing with java.nio.ByteBuffers, and I was wondering what would be the right way to deal with BufferUnderflowExceptions.
19:32hiredman,(pipeline '(a b (h (g y))))
19:32clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol
19:33hiredman,(pipeline '(a b (h y (g y))))
19:33clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol
19:33hiredmanhmmm
19:33ayrnieu,(doc pipeline)
19:33clojurebot"([a]); "
19:35blbrownis 'doto' a macro?
19:35Chousukeyes
19:35blbrownI like it
19:35Chousukesee -> as well :)
19:36Chousukegnuvince_: I wonder; does returning nil in such a case make sense?
19:36Chousukegnuvince_: are there cases where returning will could be useful non-error behaviour?
19:37Chousuke... nil
19:37ayrnieu,(symbol (.getName (first (.getMethods String))))
19:37clojurebothashCode
19:37ayrnieu,(-> String .getMethods first .getName symbol)
19:37clojurebothashCode
19:39gnuvince_Chousuke: not really. Actually, now that I think about it, I think that an exception indicates that there's something very wrong
19:41Chousukeyeah.
19:41ayrnieuextraordinary control flow
19:42Chousukeexceptions should indicate that not everything goes as planned. returning nil instead is a "I have nothing for you" kind of thing
19:42gnuvince_Yeah
19:43gnuvince_I guess that if you're expecting to read 10 bytes of data from a buffer and there are only 8, it should be an exception.
19:44Chousukeonly if the missing two bytes went missing because of a malfunction :/
19:48gnuvince_Chousuke: it's from a defined file format. If there's an error anywhere, the entire thing is corrupt.
19:48Chousukeyeah, that sounds exceptional enough :)
19:53gnuvince_Chousuke: I don't know if you read my latest blog post about reading binary data, but it's the continuation of that.
19:53gnuvince_Changed a few things
19:53Chousukegnuvince_: maybe it'd still make sense to return nil in the case the file is corrupt
19:54gnuvince_Chousuke: I will probably return nil for the whole operation
19:54gnuvince_(decoding the file)
19:55gnuvince_But not for the smallest tasks like reading one field.
19:55gnuvince_But at that point, I'll be in consumer code.
19:55gnuvince_Where making that decision is easier.
20:05hiredmanclojurebot: translate to it: my hovercraft is full of eels!
20:05clojurebotil mio hovercraft è pieno di anguille!
20:07hiredmanclojurebot: translate to zh: my hovercraft is full of eels!
20:07clojurebot我国气垫船充满鳗鱼!
20:14blbrownhas anyone built a web application with clojure and spring? I wonder if it is just better to avoid all of those java web frameworks all together? hmm
20:32danlarkinclojurebot: translate to hu: my hovercraft is full of eels!
20:32clojurebotSaját légpárnás tele van eles!
20:32danlarkinnot handling the encoding very well I guess
20:36ivandouble-utf8ed
21:14hiredman~translate to ru: in soviet russia the state mutates you!
21:14clojurebot? ????????? ?????? ??????????????? ???????? ???!
21:14hiredmanI guess puns don't translate well then...
21:14ayrnieu~translate to zh: ? ????????? ?????? ??????????????? ???????? ???!
21:14clojurebot? ????????? ?????? ??????????????? ???????? ??? !
21:14hiredmanayrnieu: to/from english only
21:15ayrnieu~translate from ru: ? ????????? ?????? ??????????????? ???????? ???!
21:15clojurebotIn Soviet Russia the state mutates you!
21:15danlarkinclojurebot: translate to hu: my hovercraft is full of eels!
21:15clojurebotSaj�t sikl�haj� tele van eles!
21:15danlarkinheyy there were are
21:16ayrnieu~translate from zh: ??????
21:16clojurebotWhat you are
21:16durka42a friend who speaks russian tells me that google is spouting nonsense
21:16ayrnieu(not quite)
21:22Wizardofwestmarca translation program spewing gibberish? Inconceivable!
21:23blbrownclojure is awesome. Are the developers working with any companies to integrate the technology. I think that is where a lot of open source languages/software lose out. They don't consider businesses.
21:23blbrownI will probably say something about clojure in a developer meeting, but that wont be for months
21:25durka42there was a post about clojure being used in a hospital
21:26Wizardofwestmarcwell, not probably quite what you mean but Rich did present at a recent JVM workshop hosted by Sun themselves
21:26blbrowndurka42, I remember that
21:26WizardofwestmarcThat sorta thing helps get the business side rolling
21:26blbrownI saw part of the google tech talk
21:26blbrown...or was that another language, I am getting them all confused these days
21:27Wizardofwestmarchm, don't recall a GTT
21:28blbrownmaybe not
21:30Wizardofwestmarcalthough Google taking an interest in clojure would certainly be interesting if it has happened/were to happen
21:30Wizardofwestmarcsince they already have Java in their standard dev stack
21:31blbrownthey seem to have low standards on who they invite though (IMHO)
21:31Wizardofwestmarcoh? I've only watched a few of the talks of theirs
21:31blbrownOK, president Obama doesn't count
21:31Wizardofwestmarc(GTTs)
21:31Wizardofwestmarcthe one for the xkcd cartoonist was interesting because a ton of big name guys in comp sci/programming showed up
21:32blbrownI mean they have a high quantity over quality ratio
21:32Wizardofwestmarcright
21:32WizardofwestmarcI usually just watch ones by people I figure are worth watching based on their reputation
21:32blbrownI think the JVM workshop is probably a bigger deal
21:33ayrnieu"In this chapter you have seen four concurrency APIs: refs, atoms, agents,
21:33ayrnieublech.
21:33ayrnieu" and vars. [...] So we are left with good old-fashioned locking."
21:33Wizardofwestmarcfor getting noticed by a wide audience of companies who use the java stack it probably is
21:33Wizardofwestmarcayrnieu: Halloway's book?
21:33ayrnieuYes.
21:34Wizardofwestmarcheh
21:34WizardofwestmarcI still need to read the newest beta
21:34Wizardofwestmarcskimmed the chapter on Functional, but haven't looked at the other changes
21:34Wizardofwestmarcalso, was rather sad to see the Monte Carlo chapter got cut
21:35blbrownWizardofwestmarc, there are lot of missing chapters
21:35Wizardofwestmarcbeta 6 I think is content complete
21:35blbrownhell, I could have been happy with just that chapter
21:35blbrownoooo, nice
21:36Wizardofwestmarcthe impression I get is it's gone >(
21:36blbrownthat sucks
21:36Wizardofwestmarcbut yes, 5 and before had a bunch of stuff missing still
21:36blbrownthey never put anything production quality in a tech book
21:36Wizardofwestmarctrue
21:38Wizardofwestmarcbut boy, do I keep buying them <_<
21:38Wizardofwestmarcwas debating grabbing o'reily's new book, Algorithms in a nutshell
21:39blbrownWizardofwestmarc, me too, I finally got code complete 2
21:39WizardofwestmarcGREAT book
21:40blbrownWizardofwestmarc, that book looks interesting
21:40WizardofwestmarcI reread it every couple years
21:40WizardofwestmarcCC2 and Pragmatic Programmers are both books I dig out of my bookshelf every so often as refreshers
21:40blbrownI think I may have an audit file with the list of checklists at the end of each chapter "DId you refactor this code? yes/no" And I am guessing it could apply to clojure as well
23:01dreishRandom fireworks outside.
23:44blbrownWizardofwestmarc, I got the algorithm book.
23:45blbrownactually I am thinking of writing a book (JVM languages for Enterprise Development, will cover a small bit in clojure)
23:50gnuvince_Is it possible that elements in a Seq and in a vector are in opposite orders? If I don't call (into [] data) for one of my functions, my other functions yield erroneous results.
23:53durka42what are the other functions?
23:53durka42some functions treat lists and vectors as having opposite order
23:53durka42,(pop [1 2 3])
23:53clojurebot[1 2]
23:54durka42,(pop '(1 2 3))
23:54clojurebot(2 3)
23:54durka42,(conj [1 2 3] 4)
23:54clojurebot[1 2 3 4]
23:54durka42,(conj '(1 2 3) 4)
23:54clojurebot(4 1 2 3)
23:54gnuvince_durka42: some functions inside my program, not Clojure ones.
23:55gnuvince_I'm trying to find out if I can use Seqs, because converting into vectors takes quite a lot of time: to process 1000 files, seqs takes 1.6 second (with the wrong results though) and vectors take 16 seconds
23:55durka42well, i meant if your functions depend on clojure.core fns such as the above
23:55gnuvince_So obviously, I'd want to have my cake and eat it too.
23:55durka42want to paste something?
23:56gnuvince_durka42: It's quite a lot of code.
23:56gnuvince_I'm going to try and narrow it down
23:56gnuvince_At worse, I'll put it on github (where it was going anyway)
23:59gnuvince_HAH!
23:59gnuvince_Got it
23:59durka42got it?
23:59gnuvince_doall was needed