#clojure log - Jan 30 2009

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:06 eee: hi

0:06 has anyone bought the 41 dollar book yet?

0:07 ayrnieu: I only paid for the PDF.

0:07 eee: that's all there is

0:07 did it help you?

0:07 i remember you . . did you already know lisp?

0:08 ayrnieu: thus far. IIRC, 41 dollars is the price both for the PDF (now and until it's finished and published) and the paper book.

0:08 eee: did you know lisp?

0:09 ayrnieu: I already knew lisp. The book has been pretty helpful -- the exploration of Java through clojure is well-done.

0:09 eee: i'm not buying that clojure is accessable to people that don't know lisp

0:10 hiredman: *shrug*

0:10 eee: I'm thinking of diggin into some lisp books first. good idea?

0:10 hiredman: clojure *is* a lisp, so knowing a lisp is required to know clojure...

0:10 eee: there's just too much people talk about that I don't grok

0:10 hiredman: clojurebot: sicp?

0:10 clojurebot: sicp is http://web.mit.edu/alexmv/6.001/sicp.pdf

0:11 hiredman: always good

0:11 the hokey videos are nice too

0:11 ayrnieu: The Little Schemer will help you.

0:11 ozy`: eee: http://www.gigamonkeys.com/book/ <= if you're into pain

0:11 * ozy` jests

0:11 ozy`: (PCL is actually pretty gentle as far as I know)

0:12 (scheme is better for learning though)

0:12 (so, SICP)

0:12 eee: lol people always recommend those

0:12 i guess they are standards at some schools

0:12 ozy`: eee: asked this question before, have you?

0:12 PCL isn't used in schools, to my knowledge

0:12 eee: no

0:12 not quite

0:13 but people still recommend those

0:13 hiredman: the sicp videos are very gentle

0:13 eee: this 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

0:14 Raynes: Why not recommend a book that is actually /about/ clojure. Like Programming Clojure. ;)

0:14 eee: there are videos?

0:14 hiredman: yeah

0:14 eee: well, I asked about that book

0:15 raynes, it's pretty good?

0:15 ozy`: 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

0:15 hiredman: eee: I always recomend hands on learning, the sooner you start writing code the better

0:15 ayrnieu: also, because he thinks it's 41 dollars.

0:15 eee: i do think it's 41 dollars :)

0:15 hiredman: ,(println "hello world")

0:15 clojurebot: hello world

0:15 eee: yup

0:15 Raynes: eee: 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.

0:15 And hid.

0:16 hiredman: man, talk about a low barrier to entry

0:16 eee: i can do plenty of simple stuff

0:16 ayrnieu: eee, the PDF is $21

0:16 eee: give me a simple challenge right now :) let's go

0:16 ozy`: ,(map println '[clojure is neat])

0:16 clojurebot: (nil nil nil)

0:16 ozy`: aw man

0:17 eee: it is? see I have reading comprehension problem aymieu

0:17 ayrnieu: it's probably the horrible font you're using :-)

0:17 Raynes: Get emacs working seamlessly with Clojure on windows in 2 minutes. There is a challenge :p

0:17 eee: i did that

0:17 someone has an easy setup for that

0:17 mfredrickson: ,(doseq [i '[clojure is neat]] (print i))

0:18 clojurebot: clojureisneat

0:18 Raynes: Clojure-box doesn't count.

0:18 eee: i clicked a button and it installed . . .2 minutes exactly

0:18 oh

0:18 mfredrickson: doseq vs map. i never get it right

0:18 hiredman: cb doesn't deal with line breaks well

0:18 map is lazy

0:18 mfredrickson: either

0:18 hiredman: clojurebot: map?

0:18 clojurebot: map is *LAZY*

0:18 eee: but, emacs doesn't follow windows conventions of things like cut and paste and save

0:18 who wants to relearn all that boilerplate . . . not to mention a new language

0:18 hiredman: and by the time cb forces the seq, it has alread closed *out*

0:18 Raynes: I use emacs for everything /but/ JVM languages, I can't handle it.

0:19 mfredrickson: is there a good windows vim? MacVim has been great to me

0:19 hiredman: ,(doall (map pr (range 10)))

0:19 clojurebot: (nil nil nil nil nil nil nil nil nil nil)

0:19 0123456789

0:19 eee: oh 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

0:20 i never got macvim to work

0:20 windows vim much easier

0:20 hiredman: ,(.codePointAt "abcd" 0)

0:20 clojurebot: 97

0:20 ozy`: eee: getting macvim to work is pretty easy... you just decompress it and open it

0:20 eee: i don't have a coding environment for clojure . . .BIG part of the problem

0:20 hiredman: that was a java call

0:20 ayrnieu: eee, I've loathed and avoided java for years, and Programming Clojure rehabilitated it for me.

0:21 hiredman: ,(char 97)

0:21 Raynes: eee: The netbeans plugin is okay.

0:21 clojurebot: \a

0:21 eee: what did you use before aymieu?

0:21 Raynes: I stress that when I say "okay".

0:21 ayrnieu: ,(map #(symbol (.getName %)) (.getMethods String))

0:21 clojurebot: (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

0:21 ayrnieu: eee - everything else.

0:21 ozy`: 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

0:22 eee: i can make a clojure program as long as there are no dependencies and in a single file in the netbeans plugin

0:22 * hiredman uses vim

0:22 * ozy` uses vim too

0:22 hiredman: for clojurebot developement

0:22 lisppaste8: ayrnieu pasted "Java-using MD5 " at http://paste.lisp.org/display/74629

0:22 hiredman: clojurebot: emacs?

0:22 clojurebot: "Learning Emacs and SLIME was just about the most painful computer experience I've ever been through."

0:22 Raynes: If VIM were the last editor of any type on the planet. I wouldn't code.

0:22 ozy`: hiredman: ah, so you're the one....

0:23 eee: i agree with the bot

0:23 ayrnieu: I didn't try to be clever with that; it's just the first example I saw online of someone writing an MD5 in Java.

0:23 * mfredrickson smells stinky editor war about to start

0:23 Raynes: The whole classpath bullshit really lowered my clojure-excitement.

0:24 eee: i 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

0:24 raynes I agree

0:24 hiredman: clojurebot: jar directory?

0:24 eee: I hate all that classpath crap

0:24 clojurebot: jar directory is find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

0:24 ozy`: Raynes: you know you can set up emacs keybindings in vim, right?

0:24 eee: ozy, then why use vim?

0:25 Raynes: ozy`: 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.

0:25 hiredman: ozy`: emacs goes a bit beyond keybindings

0:25 Raynes: I want emacs.

0:25 :|

0:25 ozy`: eee: oh, I was just being pedantic with his rhetorical situation :p

0:25 eee: i want type ahead and dot completion

0:25 ayrnieu: Raynes, 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.

0:25 ozy`: eee: you have no soul

0:25 Raynes: tl;dr ;)

0:26 hiredman: eee: I think there just was a message on the google group about a netbeans something or other with completion

0:26 eee: here's the FUNNIEST thing

0:26 i saw that

0:26 excited to try it

0:26 this is funny

0:26 tho

0:26 ready?

0:26 people talk about functional languages

0:26 nice

0:26 hiredman: ayrnieu: zsh, Nice.

0:26 eee: high level

0:26 right?

0:27 and then they TOIL setting up and playing with environments and writing scropts

0:27 the other thing

0:27 iss

0:27 is

0:27 ozy`: eee: and you're astonished that they're all so primitive that they lack basic stuff like for loops?

0:27 eee: eclipse writes all the boilerplate for you in java

0:27 so it's not fair to say that lisp programs are shorter

0:27 what percentage do I actually write?

0:27 not much

0:27 hiredman: clojurebot: what do you know about trolls?

0:27 clojurebot: trolls 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.

0:27 eee: eclipse writes it

0:28 ayrnieu: eee, eclipse doesn't read all the boilerplate for you.

0:28 mfredrickson: eclipse writes it, you maintain it

0:28 ozy`: eee: on the other hand, what percentage do you actually read? answer: you have to read -all- of it.

0:28 mfredrickson: ozy`: +1

0:28 eee: well

0:28 I can't read someone elses lisp thats for sure

0:28 ozy`: eee: always assume that your program will be written once, updated ten times, and read a hundred times

0:29 mfredrickson: to argue the other side of the coin, it's not eee's fault that java is verbose

0:29 eee: ever read output from a genetic program?

0:29 ozy`: eee: heh, well you don't know lisp, do you?

0:29 mfredrickson: best of a bad situation

0:29 eee: I think ou can write 10 lines of java in the time it takes to figure out your one line of lisp sometimes

0:30 and eclipse let's you collapse the little plusses :)

0:30 but I really appreciate you helping me with these arguments

0:30 ozy`: well that's definitely a plus ;)

0:30 eee: because I have to convince coworkers to try functional languages more

0:30 so I'm being them :)

0:31 here's a real question

0:31 someone wrote in the discussions

0:31 that they made set ops faster

0:31 ozy`: 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

0:31 ayrnieu: it's better to seek answers with questions than to seek resistance with opinions.

0:32 ozy`: ayrnieu: that should go on a plaque over the entrance to 4chan or something

0:32 eee: well, 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?

0:32 hiredman: hmmm, picking unicode symbols for macros then trying to edit the file again in a non-unicode console

0:32 not the best plan I have ever made

0:33 ayrnieu: eee, clojure doesn't just use lists - actually it's remarkable for how well it uses other data types.

0:33 hiredman: ,({:a 1 :b 2} :a)

0:33 clojurebot: 1

0:34 ayrnieu: eee, c.f. Chapter 4: Unifying Data with Sequences, of the $21 book :-)

0:34 eee: i see that now

0:35 does the book talk about web stuff, too?

0:35 ayrnieu: so far it doesn't.

0:36 There's a 'web development' section in Chapter 9.

0:36 eee: i got one of those slicehosts

0:36 so I could follow eric lavigne's tutprial

0:36 I just did it by wrote

0:36 and of course it worked

0:36 but I didn't grok it :)

0:37 I can do simple little algorithms

0:37 that's it

0:37 :)

0:37 anyone got a little challenge?

0:38 hiredman: eee: you could hit up project euler

0:38 they have a few challenges

0:38 briancarper: "Learning Emacs and SLIME... most painful experience..." did I just hear myself quoted by clojurebot or did someone else say that too?

0:38 eee: lol

0:39 hiredman: briancarper: could have been you

0:39 that was your blog post?

0:39 briancarper: Yeah.

0:39 hiredman: Yeah.

0:39 eee: where are these movies someone mentioned?

0:39 ayrnieu: 'screencasts' on clojure.org

0:39 hiredman: clojurebot: google sicp videos

0:39 mfredrickson: or did you mean SICP

0:39 clojurebot: First, out of 17600 results is:

0:40 Structure and Interpretation of Computer Programs, Video Lectures

0:40 http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/

0:40 briancarper: Those movies are good.

0:40 hiredman: clojurebot: ?

0:40 clojurebot: It's greek to me.

0:40 eee: i saw rich's clojure ones. cool . . .the lectures

0:40 thanks

0:41 briancarper: I like the parts where Sussman types LISP laboriously on an old green-on-black 30-character-wide display.

0:41 hiredman: I put them on my blackberry

0:41 briancarper: ha ha

0:41 the magic parens balancing

0:41 the hats

0:41 briancarper: His huge sidewalk chalk.

0:42 eee: did y'all go to MIT or wherever that was?

0:42 hiredman: eee: no, I watched the videos

0:43 berkely had a podcast of the audio from the first three of their CS courses

0:43 eee: that's cool

0:43 hiredman: the first is scheme, the second is java, the third is C and asm

0:44 those are just he languages the classes use, the classes are not about those languages

0:44 the C/asm class was awesome

0:45 eee: C/asm was your third course?

0:46 oh I see

0:46 hiredman: clojurebot: google berkely 61c mp3s

0:46 clojurebot: First, out of 1770 results is:

0:46 CS 61C Machine Structures Introduction

0:46 http://www.jimmyr.com/blog/CS_61C_Machine_Structures_Lecture_1_John_Wawrzynek_159_2006.php

0:46 eee: that was an aside

0:46 hiredman: eee: I did not personally attend berkely

0:47 eee: i see

0:47 hiredman: I have taken CS classes at the local community college, but they are a joke

0:48 eee: you taught yourself?

0:48 hiredman: it just made me really bitter

0:48 eee: I never think of that way

0:49 I just know how to read instructions

0:49 and watch videos

0:49 eee: i'm the opposite

0:49 i need to start out from someone else

0:49 hiredman: many people often seem to be the opposite

0:49 eee: i like to use people like compilers

0:49 dreish: What are the primitives, and what are the means of combinaaation?

0:50 hiredman: eee: project euler has all kinds of problems to take a crack at

0:50 eee: i liked this book: http://www.amazon.com/Structures-Algorithms-CBMS-NSF-Conference-Mathematics/dp/0898711878

0:50 hiredman: it was fun while I was doing it, maybe I should start again

0:50 dreish: word

0:50 eee: i'll check out project euler

0:52 hiredman: eee: the first problem is, find the sum of all the multiples of 3 or 5 under 1000

0:52 eee: hmmmmmm

0:52 ok

0:53 see, interestingly . . . my mind starts thinking, "while"

0:54 which isn't really used in clojure

0:55 so I guess a silly way to solve it might be to just loop from 1 to 1000

0:55 and

0:55 if a number evenly divides by 3 or 5

0:55 add it to some list

0:55 then reduce the list

0:55 hiredman: a lot of the time things that would be some kind of loop in another language are seqs in clojure

0:56 dreish: Also, there is no list.

0:56 eee: so evenly divides is checked by having mod 3 equal to zero

0:56 dreish: When you create a seq, there's usually just one or two things in memory at a time.

0:56 ozy`: 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

0:57 dreish: ,(apply + (range 1000000))

0:57 clojurebot: 499999500000

0:57 eee: ahhhhhh!

0:57 i got beat

0:57 ok

0:57 how do that as reduce?

0:57 dreish: ,(reduce + (range 1000000))

0:57 hiredman: don't use reduce

0:57 clojurebot: 499999500000

0:58 eee: why not? i've never used it

0:58 hiredman: ok, go ahead

0:58 eee: :)

0:58 cp2: lol

0:58 ayrnieu: ,(interpose + (range 10))

0:58 clojurebot: (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

0:58 cp2: hiredman, i am curious though

0:58 why not?

0:58 hiredman: eee: make an account on the euler website

0:58 ayrnieu: ,(interpose '+ (range 10)) ;; readable mode

0:58 clojurebot: (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)

0:58 eee: how do you use reduce now?

0:58 ozy`: cp2: because '+ is already a fold, I assume....

0:59 cp2: oh well, i wasnt paying attention to the topic

0:59 eee: how do you check docs on something?

0:59 dreish: Topic is Euler puzzle 1.

0:59 cp2: my bad, just say hiredman saying not to use something, and it sparked interest. didnt care to read further ;)

0:59 ayrnieu: ,(doc interleave)

0:59 clojurebot: "([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."

0:59 eee: oh, reduce was the same as apply

1:00 that's no fun

1:00 hiredman: no

1:00 ayrnieu: the same use and the same effect, but they differ.

1:00 hiredman: reduce and apply are different

1:00 ozy`: eee: apply only has the same effect if you use it on something that already implies 'reduce

1:00 eee: and then there's "map"

1:00 dreish: ,(apply map #(+ 2) '((1 2)))

1:00 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1372$fn

1:01 dreish: ur

1:01 ozy`: eee: 'map is easier to grok. you'll get back a sequence exactly as long as the one you passed into it

1:01 dreish: ,(apply map #(+ % 2) '((1 2)))

1:01 clojurebot: (3 4)

1:01 dreish: ,(reduce map #(+ % 2) '((1 2)))

1:01 clojurebot: (3 4)

1:01 eee: ,(reduce (map '+ (range 5)))

1:01 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$reduce

1:01 hiredman: eee: sign up for an account on the euler website, they have a list of problems

1:01 some of them are rather difficult

1:02 spend sometime with clojure.org/api

1:02 ayrnieu: ,(let [calls (ref 0) my+ (fn [a b] (dosync (alter calls inc)) (+ a b))] [(apply my+ (range 10000)) @calls])

1:02 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1395$my-PLUS-

1:02 eee: dude clojure api is so terse. it's written for people who use very few . .. but big words

1:02 like "intern"

1:03 ayrnieu: oh, duh.

1:03 eee: and "destructure"

1:03 i'm like, "thanks. that helps"

1:03 cp2: eee its better than garbled abrreviations/acronyms

1:03 ozy`: ,(apply + (map #(apply + (filter (fn [k] (= (mod % k) 0)) (range 10000))) '(3 5)))

1:03 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArithmeticException: Divide by zero

1:03 ayrnieu: easy to fix, but nevermind.

1:03 ozy`: whoops

1:03 ayrnieu: eee, ask questions in the channel.

1:03 hiredman: eee: the sequence functions are very useful

1:04 cp2: ozy`: im glad you dont work on the lhc

1:04 ozy`: ,(apply + (map #(apply + (filter (fn [k] (= (mod k %) 0)) (range 10000))) '(3 5)))

1:04 clojurebot: 26663333

1:04 hiredman: eee: anyway, you asked for a challenge, so have at euler

1:04 eee: that's pretty cool, no if statements were used

1:04 yes, thankyou hiredman

1:05 ozy`: eee: 'filter contains an if statement, IIRC

1:05 LordOfTheNoobs: clojurebot: Peter Griffin?

1:05 clojurebot: You and your big words and your small difficult words

1:05 eee: i bet filter could be avoided by looking up the list comprehension syntax

1:05 ayrnieu: eee, find me a hundred pairs of numbers whose base-seven product contains the number of the beast

1:05 ozy`: eee: anyway I think my implementation is wrong given the problem specification

1:06 eee: i know filter does . . .you guys helped me make "separate" faster than what's in contrib last time

1:06 hiredman: ozy`: that certainly is not the right answer

1:06 ozy`: cp2: anyway I didn't think it would even parse... wasn't too careful about balancing parentheses

1:06 dreish: (+ (apply + (range 0 1000 3)) (apply + (range 0 1000 5)) (apply - (range 0 1000 15)))

1:06 That's almost like cheating.

1:06 ozy`: hiredman: not too worried :p just playing around

1:06 hiredman: clojurebot: clojure?

1:06 clojurebot: clojure is a very attractive hammer with a nice heft to it

1:07 hiredman: clojurebot: clojure?

1:07 clojurebot: clojure is a very attractive hammer with a nice heft to it

1:07 hiredman: grr

1:07 ozy`: dreish: ahhh didn't think of that one

1:07 hiredman: clojurebot: clojure?

1:07 clojurebot: clojure is cheating

1:07 hiredman: that's the one

1:07 ayrnieu: clojurebot, use non-repeating RNG

1:08 briancarper: Is there any way to break an infinite loop at the REPL without killing the whole Clojure process?

1:08 hiredman: ayrnieu: sometimes you get a bunch of heads in a row when you flip a coin

1:08 eee: wow. that's smart dreish

1:08 ozy`: > foldl' (+)

1:08 aaagghhh

1:08 hiredman: no lambdabot here

1:09 ozy`: <_<

1:09 >_>

1:10 eee: i'll have to think about yours for a long time aymieu

1:10 briancarper: I'll take lack of response to my question as a no.

1:11 eee: i have had the same problem in enclojure

1:11 and had to kill netbeans

1:11 let alone the repl

1:12 dreish: briancarper: I haven't found one, but I think it should be possible to do.

1:12 briancarper: You'd think.

1:14 hiredman: try kill -QUIT the java process

1:14 eee: (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

1:14 see

1:14 ayrnieu: briancarper, how much do you want to preserve from the repl?

1:14 eee: it doesn't say what when does

1:14 hiredman: that might just make the threads dump there stack

1:14 eee: verses while

1:14 just says you can use one or the other

1:14 hiredman: eee: while is while exp is true

1:14 when is when expr is true

1:15 eee: um . .. in a list comprehension that makes no sense

1:15 hiredman: it totally does

1:15 eee: haskel list comprehension makes perfect sense

1:15 python list comprehension makes totl sense

1:15 you state the predicate

1:15 this when thing is meaningless

1:15 ayrnieu: ,(for [x (range 100) :when (zero? (mod x 3))] x)

1:15 clojurebot: (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)

1:16 briancarper: ayrnieu: I want to kill the loop and go back to the repl without losing everything in the environment.

1:16 ayrnieu: if you want a different syntax, write it.

1:16 eee: ,(for [x (range 100) :while (zero? (mod x 3))] x)

1:16 clojurebot: (0)

1:16 eee: ok

1:16 totally arbitrary

1:16 but ok

1:16 hiredman: ,(for [x (range 1000) :when (and (zero? (mod x 3)) (zero? (mode x 5)))] x)

1:16 clojurebot: java.lang.Exception: Unable to resolve symbol: mode in this context

1:17 ayrnieu: what's totally arbitrary?

1:17 LordOfTheNoobs: eee: while stops at the first failure when moving over a list, when samples through the list. I think ( checking )

1:17 hiredman: ,(for [x (range 1000) :when (or (zero? (mod x 3)) (zero? (mod x 5)))] x)

1:17 clojurebot: (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

1:17 ayrnieu: ,(for [x (range 30) :when (zero? (mod x 3)) y (range 30) :while (< (* 2 x) 30)] [x y])

1:17 clojurebot: ([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]

1:17 eee: ,(for [x (range 100) :while (not (zero? (mod x 3)))] x)

1:17 clojurebot: nil

1:18 dreish: You really don't want to type :when, do you?

1:18 LordOfTheNoobs: ,(mod 0 3)

1:18 clojurebot: 0

1:18 eee: i always want to type when

1:18 ayrnieu: ,(for [x (range 30) :when (zero? (mod x 3)) y (range 30) :while (< (* 2 y) 30)] [x y])

1:18 clojurebot: ([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

1:20 ayrnieu: eee - here, implement max with list comprehensions.

1:21 eee: ok

1:21 then I'd use while

1:21 ?

1:21 LordOfTheNoobs: , {:while (for [aa (range 1 10) :while (not (= aa 5))] aa) :when (for [aa (range 1 10) :when (not (= aa 5))] aa)}

1:21 clojurebot: {:while (1 2 3 4), :when (1 2 3 4 6 7 8 9)}

1:22 eee: what is that?

1:22 ayrnieu: what is what?

1:23 eee: what LON wrote

1:23 ayrnieu: ,*1

1:23 clojurebot: java.lang.IllegalStateException: Var clojure.core/*1 is unbound.

1:23 eee: i'm looking up haskell right now

1:23 seeing how they do it

1:24 ayrnieu: ,[(class {:a 1 :b 2}), (class :a), (class (for [x (range 4)] x))]

1:24 clojurebot: [clojure.lang.PersistentArrayMap clojure.lang.Keyword clojure.lang.LazyCons]

1:24 LordOfTheNoobs: A hash-table literal with two similar for-expression calls to demonstrate their difference.

1:25 eee: doesn't seem like list comprehension would be efficient for max

1:25 since you have to look at all the numbers

1:25 i can only think of empricle implementatin

1:25 ayrnieu: no, it would not be efficient.

1:26 eee: i'm drawing a blank on that one

1:27 hiredman: ayrnieu: huh?

1:27 ayrnieu: here's the answer in set notation: { x | x E l ( no y E l > x ) }

1:27 eee: sure

1:27 hiredman: oh, right

1:28 eee: need random

1:28 ,(rand-int 30)

1:28 clojurebot: 5

1:28 ayrnieu: what needs random?

1:28 eee: cool

1:28 i want to test on randome sequence

1:28 ,(take 30 (rand-int 30))

1:28 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

1:29 eee: ,(take 30 (repeatedly (rand-int 30)))

1:29 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

1:29 eee: ,(take 30 (repeatedly '(rand-int 30)))

1:29 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

1:29 ayrnieu: ,(apply str (take 100 (repeatedly #(char (+ (int \a) (rand-int 26))))))

1:29 clojurebot: "zblkucvjrxtwgxeuxfzvxpnaokiimmvpugdxulqeketawsnzjdndeszrzwojpvfqjgjgdsgjvsuibjqnubbortiamajdcvehksta"

1:30 eee: ,(take 30 (repeatedly #(rand-int 30)))

1:30 clojurebot: (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)

1:30 eee: ok

1:31 ayrnieu: ,(.contains (apply str (take 1000000 (repeatedly #(char (+ (int \a) (rand-int 26)))))) "ayrnieu")

1:31 clojurebot: false

1:32 eee: ,(for [x (take 30 (repeatedly #(rand-int 30))) :while

1:32 clojurebot: Eval-in-box threw an exception:EOF while reading

1:32 eee: i dunno

1:32 need need two variable

1:33 you have them in your math

1:33 y and x

1:35 ,(for [x (take 30 (repeatedly #(rand-int 30))) y x] :while (< y x))

1:35 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for

1:35 eee: ,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x) [x])

1:35 clojurebot: Eval-in-box threw an exception:Unmatched delimiter: )

1:36 eee: ,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x)] [x])

1:36 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

1:36 ayrnieu: why are you using while?

1:36 eee: ,(for [x (take 30 (repeatedly #(rand-int 30))) y x :while (< y x)] x)

1:36 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

1:37 eee: trying to stop on the max

1:37 i dunno . . .shouldn't be a while or a when

1:37 it's set theory

1:37 shold just be what's in the set or what's not

1:38 ayrnieu: well, here's how I put it: { x | x E l ( no y E l > x ) }

1:38 hiredman: your syntax for for is incorrect

1:38 eee: i see another problem

1:38 can't do it in this environment with a random sequence

1:38 oh

1:38 ayrnieu: ( no y E l > x ) stipulates that no element of l is greater than x.

1:38 eee: unless I use let

1:38 i need to do a let to hold the randome sequence so I can use it with x and y

1:39 that way I can have what will amount to a nested loop

1:39 or maybe nested loop happens too

1:39 oh yeah

1:39 all combinations of x and y can be tried

1:40 somehow

1:40 hiredman: ,(doc for)

1:40 clojurebot: "([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

1:40 hiredman: ^- "collections are iterated in a nested fashion"

1:41 hah

1:42 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] myseq)

1:42 clojurebot: (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)

1:43 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq] x)

1:43 clojurebot: Eval-in-box threw an exception:EOF while reading

1:43 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq] x))

1:43 clojurebot: (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)

1:43 eee: ok

1:43 ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] (x y)))

1:43 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

1:43 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] [x y]))

1:43 clojurebot: ([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]

1:44 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] x))

1:44 clojurebot: (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

1:44 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] :while (> x y)))

1:44 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for

1:44 eee: lost

1:44 ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq] :when (> x y)))

1:44 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for

1:45 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :when (> x y)] x))

1:45 clojurebot: (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

1:45 eee: ,(let [myseq (take 30 (repeatedly #(rand-int 30)))] (for [x myseq y myseq :while (> x y)] x))

1:45 clojurebot: (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)

1:45 durka42: what would be the fastest reference type for an integer that has to be modified thousands of times very frequently, but no synchronization is needed

1:45 eee: this must be painful to watch :)

1:46 hiredman: durka42: you can use commute instead of alter?

1:46 eee: you can use with-local-vars, maybe?

1:46 durka42: i'm not sure it's commutative

1:47 hiredman: oh

1:47 I misread

1:47 durka42: my function gets mapped over a giant array and i need the max value

1:47 hiredman: ,(doc atom)

1:47 clojurebot: "([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

1:47 durka42: that's what i'm using now

1:47 alternatively, a divide-and-conquer approach might be faster

1:47 if i can wrest control of the giant array away from quicktime

1:48 hiredman: hmmm

1:48 ayrnieu: ,(time (let [x (ref 0)] (dorun (take 1000 (repeatedly #(dosync (alter x inc))))) @x))

1:48 clojurebot: 1000

1:48 "Elapsed time: 49.594 msecs"

1:48 durka42: most approaches would be faster than calling a function (* 320 240) times, 16 times a second

1:48 eee: i don't trust the timer in clojure at all

1:48 durka42: ,(time (let [x (atom 0)] (dorun (take 1000 (repeatedly (swap! x inc)))) @x))

1:48 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException

1:48 durka42: why not?

1:49 ayrnieu: eee - dorun

1:49 eee: the function we wrote the other day was way faster

1:49 but someone else had to fiigure out how to prove that

1:49 nope

1:49 ayrnieu: ,(time (let [x (ref 0)] (dorun (take 10000000 (repeatedly #(dosync (alter x inc))))) @x))

1:49 durka42: ,(time (let [x (atom 0)] (dorun (take 1000 (repeatedly #(swap! x inc)))) @x))

1:49 eee: we actually had to break up the algorithms

1:49 clojurebot: Execution Timed Out

1:49 1000

1:49 "Elapsed time: 158.512 msecs"

1:49 eee: and dorun parts of it individually

1:49 durka42: ok, refs are faster

1:49 apparently

1:49 ,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) @x))

1:49 clojurebot: 0

1:49 "Elapsed time: 8.984 msecs"

1:49 eee: try with-local-vars

1:50 durka42: (doc with-local-vars)

1:50 clojurebot: varbinding=> 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])

1:50 eee: you can just use @

1:50 ayrnieu: durka, @x isn't necessarily inc'd by the end

1:51 durka42: whoops

1:51 eee: so aymieu, do you know the answer to the challenge you gave me? was I close?

1:51 durka42: refs are not at all faster

1:52 ayrnieu: eee - use a second list comprehension to perform the 'no y greater than x' test.

1:52 nested comprehensions. Horrid complexity.

1:52 eee: i was thinking that . . . .but was trying to avoid it

1:52 forget it

1:52 going to bed

1:53 thanks for the schooling tho

1:53 durka42: ,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) (await) @x))

1:53 clojurebot: 0

1:53 "Elapsed time: 9.308 msecs"

1:53 durka42: ,(time (let [x (agent 0)] (dorun (take 1000 (repeatedly #(send x inc)))) (await x) @x))

1:53 clojurebot: 1000

1:53 "Elapsed time: 264.598 msecs"

1:53 durka42: aah

1:53 this is hopeless and un-clojure-like

1:54 i shall have to parallelize it

1:54 eee: what if you use java

1:55 i mean for that part

1:55 durka42: i might have to do that

1:55 eh?

1:55 Gorilla=> (use 'clojure.parallel)

1:55 java.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray (parallel.clj:32)

1:55 hiredman: durka42: you should just loop/recur

1:55 durka42: that's the problem! it's not my loop

1:55 quicktime gives me an interface to extend

1:55 and calls it for every pixel

1:56 which is a bad design IMO

1:56 hiredman: haha

1:56 ayrnieu: yes, that's horrid.

1:56 durka42: i 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

1:56 eee: now I see why you want to do it in parallel

1:57 ayrnieu: Jesus, it's like they never heard of APL.

1:57 durka42: i think i can get the pixel array

1:57 eee: gnight'

1:57 durka42: night

1:57 * durka42 should go to bed

1:59 durka42: does anyone know what's up with clojure.parallel, though?

1:59 where might i find jsr166y.forkjoin.ParallelArray

1:59 hiredman: clojurebot: google jsr166y

1:59 clojurebot: First, out of 725 results is:

1:59 jsr166y overview

1:59 http://artisans-serverintellect-com.si-eioswww6.com/default.asp?W9

1:59 ayrnieu: ./src/clj/clojure/parallel.clj:You'll need jsr166y.jar in your classpath in order to use this

2:00 http://gee.cs.oswego.edu/dl/concurrency-interest/index.html , there's a big comment about it in that source.

2:00 durka42: thanks

2:00 i had just searched for the classname and nothing useful came up

2:01 ayrnieu: I do a lot of `find . |xargs egrep`

2:01 hiredman: erm

2:01 -R

2:02 ayrnieu: find .|egrep clj|xargs egrep

2:02 hiredman: ugh

2:02 find . -name \*.clj

2:02 ayrnieu: find .|ergep -v git|xargs egrep

2:03 hiredman: find . -name \*.clj -not -name \*git\*

2:03 ayrnieu: Yeah, I'll remember that for another few minutes.

2:03 hiredman: find . -name \*.clj -not -name \*git\* -exec egrep Foo {} \;

2:04 find is one of my favorite tools

2:05 ayrnieu: so you're a Java man at the shell and a haskell man at the editor :-)

2:05 hiredman: eh?

2:10 durka42: oh no!

2:10 QTJava requires java 5

2:10 clojure.parallel require java 6

2:10 hiredman: ouch

2:11 durka42: maybe i will have to try that 32-bit java 6 build

2:11 but QTJava is obsolete anyway

2:11 unfortunately there doesn't seem to be a working java interface to the new way

2:11 hmm, that wasn't the problem

2:12 jsr166 doesn't quite compile

2:12 oh there is a binary

2:17 i think ParallelArray moved...

2:18 jsr166y.forkjoin.ParallelArray --> extra166y.ParallelArray

2:18 commit message from 1/6: Repackaged parallel collection classes

2:19 hiredman: hmmm

2:20 durka42: things work if i go into parallel.clj and swap out jsr166y.forkjoin for extra166y at the top

2:21 user=> (reduce + 0 [1 2 3 4 5])

2:21 15

2:21 user=> (preduce + 0 [1 2 3 4 5])

2:21 15

2:21 cp2: postduce?

2:22 ozy`: ,(doc preduce)

2:22 clojurebot: java.lang.Exception: Unable to resolve var: preduce in this context

2:22 durka42: ,(use 'clojure.parallel)

2:22 clojurebot: java.io.FileNotFoundException: Could not locate clojure/parallel__init.class or clojure/parallel.clj on classpath:

2:22 ozy`: wait, parallel reduce, right?

2:22 durka42: yes

2:24 range is optimized for reduce, yes? but if i call seq on it, does that remove the optimizations?

2:25 * durka42 wonders why preduce is six times slower than reduce

2:27 durka42: should i open an issue for the moved imports thing?

2:28 LordOfTheNoobs: Do 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.

2:29 durka42: yes, sort of, can you elaborate?

2:29 this was my test: (time (dotimes [_ 1000] (doall (pmap inc (seq (range 1000))))))

2:29 with that example pmap is 24 times slower than map

2:30 * durka42 confirms that the JVM is using over 100% of the cpu

2:33 ayrnieu: ,(first (lazy-cons (print 1) (print 2) (print 3)))

2:33 clojurebot: 1

2:33 LordOfTheNoobs: Do 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.

2:33 ayrnieu: ,(first (seq (lazy-cons (print 1) (print 2) (print 3))))

2:34 clojurebot: 1

2:34 ayrnieu: ,(rest (seq (lazy-cons (print 1) (print 2) (print 3))))

2:34 clojurebot: 123

2:34 durka42: i believe that

2:34 i upped it to 100,000 items, which should take a while

2:34 well, not "should"

2:34 but is

2:35 i think i only have two cores, so it won't speed up much

2:37 LordOfTheNoobs: Good luck with your benchmark durka. I'd re-ask tommorow for a set of likely more precise and accurate answers.

3:12 Lau_of_DK: Bonjour cgrand ! :)

3:14 Raynes: Hai.

3:15 cgrand: Hej Lau!

3:19 * Raynes just wrote his first useless Clojure program :>

3:20 hiredman: purely functional then?

3:23 Raynes: No, it's an overcomplicated hello-world program :p

3:23 Still useless.

4:11 Lau_of_DK: Raynes :)

4:11 Raynes: Lau_of_DK: Yeah I know, I've been in here for a month and never actually used Clojure. ._.

4:12 Until now.

4:12 :D

4:20 Lau_of_DK: Raynes, sorry I left out "hi" I wasnt making a comment :)

4:20 Raynes: I realized.

4:21 Lau_of_DK: Good :) Just being friendly

5:24 BigTom: kotarak: Hi

5:24 kotarak: Salut.

5:25 BigTom: my GUI is not fixed but I have made progress

5:26 kotarak: Good to hear. :)

5:26 BigTom: The outstanding issue is that my watcher seems to disappear after its first call

5:27 (The RejectedExecutionException was a red-herring, I had shut down agents in the repl)

5:27 kotarak: :P

5:28 BigTom: Doh!

5:28 kotarak: Sh** happens. ;)

5:28 BigTom: If I update the GUI from the watcher it gets called once then vanishes

5:29 If I replace the gui update with a prn it keeps getting updates

5:29 Its odd (but I, suspect, fundamentally dumb on my part)

5:34 kotarak: "Blame yourself first" helps you to fix 98% of all the bugs.

5:34 In particular: it's almost never a compiler bug....

5:38 Chousuke: hmm :/

6:12 zakwilson: I'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.

6:13 I've tried putting a JTextField in a ref or an agent and did not get better results.

6:13 BigTom: Is there any way you can see the watchers attached to an agent?

6:14 zakwilson: have you looked at cells?

6:15 turbo24prg: morning

6:15 zakwilson: No.

6:16 BigTom: zakwilson: http://github.com/timothypratley/strive/blob/8285ef1419601411797205de0d60a2b2c0b71be0/src/clj/cells.clj

6:19 turbo24prg: i'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?

6:20 kotarak: turbo24prg: assoc-in and update-in

6:21 BigTom: turbo24prg: It really depends on the level of coordination required between the threads

6:22 turbo24prg: but 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

6:23 for one action i'd have to perform several inserts/updates on different maps in the structure, several levels deep

6:23 kotarak: sounds like a ref in combination with assoc-in/update-in.

6:24 turbo24prg: during update i'd like to have read-access on a stable version of it. isn't that ref/transactions?

6:25 BigTom: you cannot update a ref outside a transaction

6:25 so if you use a ref you are going to use transactions :-)

6:25 turbo24prg: the example for refs on the website isn't the easiest for a newbie

6:26 especially if you're not into java's concurrency

6:27 kotarak: turbo24prg: 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}}

6:28 The code outside the dosync always sees a stable version.

6:28 turbo24prg: uh, that's a nice example.

6:28 thanks!

6:29 BigTom: also, have a look on http://en.wikibooks.org/wiki/Clojure_Programming/By_Example

6:29 kotarak: or with update: (dosync (alter *a-ref* update-in [:b :y] inc)) => {:a {:x 7} :b {:y 7}}

6:30 A lot of things in Clojure work similar. So when you grok the idea once, it's easy to transfer to atoms, agents, etc...

6:32 turbo24prg: concurrency is sth. i really missed in common lisp

6:32 very cool

6:33 eleftherios: what's is the most mature web framework for clijure so far? Compojure?

6:33 turbo24prg: did you came from another lisp? or are you "java guys"?

6:34 kotarak: turbo24prg: I'm more a Scheme guy. Having more experience in C and a bit OCaml.

6:35 Raynes: I come from Haskell. With a little experience in C# and several other irrelevant languages.

6:35 BigTom: turbo24prg: while I'm a Java guy (which why I keep asking the guys here for help!)

6:35 turbo24prg: wow.

6:36 kotarak: Good mixture. :)

6:36 turbo24prg: yeah :)

6:36 BigTom: turbo24prg: clojure is definitely a Lisp, so you should feel very at home

6:37 zakwilson: BigTom: waching-label looks cool, but it did not work for me. The agent updates in real-time, but the GUI does not.

6:37 turbo24prg: nice, assoc supports "paths"

6:37 kotarak: Clojure 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)

6:38 turbo24prg: there is also a "normal" assoc

6:38 BigTom: zakwilson: Hm, I 'm having problems with the pattern too

6:38 zakwilson: does cells itself work for you?

6:38 zakwilson: Using watchers has the same results I was having trying to do it manually.

6:39 I haven't tried cells itself - just watching-label.

6:39 BigTom: zakwilson: try running cells to confirm your environment is ok

6:41 zakwilson: I just did. It works.

6:43 I just tried using an atom instead of an agent since that's what cells does. No change.

6:43 BigTom: zakwilson: could you post your code?

6:44 lisppaste8: url

6:44 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

6:46 zakwilson: I'm not sure how much I can separate the problem code from the whole app and still reproduce the problem.

6:46 And the whole app is a bit big for a paste...

6:46 So... http://github.com/zakwilson/imagesieve/tree/master

6:47 This is before any attempt to use a watcher, and the UI code is a bit more messy than I'd like.

6:48 Wait... does this thing depend on my utilities file? I need to check.

6:49 It does. I'll put that up on github too.

6:51 Dependency: http://github.com/zakwilson/zutil-clj/tree/master

6:51 cads: what's the -> macro called?

6:52 zakwilson: I think I would call it "arrow".

6:53 cads: it's pretty funky :D

6:55 takes 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

6:55 I think.

6:55 Do we use it often?

6:58 if 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)))

7:10 BigTom: zakwilson: just running it up now...

7:11 Chousuke: cads: it has many uses :)

7:11 cads: you can omit the parens though I think

7:11 zakwilson: BigTom: (update-counter) works fine when it's not actively processing.

7:11 Chousuke: ,(macroexpand-1 '(-> f1 f2 f3))

7:11 clojurebot: (clojure.core/-> (clojure.core/-> f1 f2) f3)

7:12 Chousuke: yeah, seems to work :/

7:13 ,(macroexpand '(-> f1 f2 f3))

7:13 clojurebot: (f3 (clojure.core/-> f1 f2))

7:15 BigTom: zakwilson: well, I have some gray jpegs now :-)

7:16 * zakwilson has a LOT of grey jpegs.

7:16 zakwilson: But no up-to-date GUI saying how many.

7:19 BigTom: zakwilson: indeed

7:22 zackwilson: it updates when you mouse-over the GUI

7:22 zakwilson: BigTom: I may have improved things a bit. I moved the processing itself in to an agent.

7:23 The update isn't quite in sync that way, but it's pretty close.

7:36 BigTom: actually, it does update

7:37 turbo24prg: is there any way to differentiate between different types of struct?

7:37 cads: can 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?

7:37 turbo24prg: say (defstruct a ..) (defstruct b ...). in CL i'd use typecase

7:38 BigTom: zakwilson: For me it updates the GUI pretty much at the same time the file appears

7:41 zakwilson: BigTom: What sort of hardware are you running it on?

7:43 BigTom: a single core ancient ubuntu box

7:44 zakwilson: Interesting. There is a small logical difference in how it does things on single-core machines (map instead of pmap).

7:44 I'm about to try it on an older single-core Windows box.

7:49 Chousuke: cads: sure it's possible; just not trivial :)

7:51 personally I don't think the infix syntax offers anything over prefix syntax :/

7:53 unless you're going to allow writing things like (b^2 - 4ac), but that's even more complicated.

7:53 cads: unless you're doing algebra in ascii, I guess

7:54 that's not so bad, your stuff is already in tokens, you just got to do a little parsing :D

7:54 Chousuke: but 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 :)

7:55 cads: I cant really think of examples of algebra where prefix notation is absolutely horrific

7:56 Chousuke: it's maybe not the easiest to read if you put it all on one line.

7:57 cads: I can think of places where infix operators would be more mnemonic and easier to parse for a human reader

7:57 Chousuke: something like (/ (* 5 (- 4 z)) 2)

7:57 zakwilson: BigTom: 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.

7:57 Chousuke: but that's really much better if it's properly indented.

7:58 lisppaste8: url

7:58 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

7:59 Chousuke pasted "like this" at http://paste.lisp.org/display/74634

7:59 cads: eh, that's not too bad, I bet one gets used to it

7:59 looking at your second example now

8:00 Chousuke: that even looks a lot like how you'd write it if you were writing using real notation instead of ascii formulas

8:00 cads: yeah, with / you can separate the numerator from the denominators and it looks nice :)

8:27 turbo24prg: assoc supports paths, but find doesn't? :/

8:31 assoc-in supports them, find/get doesn't.

8:39 Chousuke: get-in? :)

8:39 ,(doc get-in)

8:39 clojurebot: "([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys"

8:41 Chousuke: even works with vectors if you supply integer keys :)

8:41 BigTom: zakwilson: cool

8:54 turbo24prg: uh, cool

8:59 kotarak: Hmmm.. Should get-in support a default value?

9:02 BigTom: ,(includes? :k {:k :v :k1 :v})

9:02 clojurebot: java.lang.Exception: Unable to resolve symbol: includes? in this context

9:02 BigTom: oops

9:02 kotarak: (doc contains?)

9:02 clojurebot: Returns 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])

9:03 BigTom: kotarac: cheers

9:05 kotarak: BigTom: another useful repl function

9:05 (doc find-doc)

9:05 clojurebot: Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern; arglists ([re-string-or-pattern])

9:06 BigTom: kotarak: I can never remember that one

9:07 Its very weird, I had an app that worked 3 weeks back and its busted all over now

9:07 I think I must have every one of the bad idioms Rich is tidying up :-(

9:08 Hun: kotarak: though i liked the old name apropos more :)

9:08 hoeck: were there any breaking changes in the last 3 weeks??

9:09 BigTom: I don't know, watchers changed in early Jan

9:09 I used clojure-contrib includes? when I should have used contains - see above

9:10 So, its all down to me really :-/

9:11 hoeck: ah, okay

9:11 BigTom: kotarak: I fixed the watcher thing, I had too many braces

9:11 kotarak: Hun: (def apropos find-doc) ;)

9:11 Hun: :)

9:12 of course. but for some reason, i found find-doc unintuitive

9:12 though that might be just musclememory to hit (apropos " before thinking

9:12 kotarak: I find it mnemonic.

9:13 apropos is used here a bit differently.

9:19 BigTom: agent question

9:19 if I send actions to an agent from one thread then is the execution order guaranteed to be the same as the send order?

9:19 Chouser: BigTom: yes

9:20 ayrnieu: one of the first things I wrote in clojure: http://paste.lisp.org/display/74207 - apropos. It needs some work.

9:20 BigTom: thought so

9:20 thanks

9:21 Chouser: Ah, 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."

9:21 from http://clojure.org/agents

9:22 ayrnieu: ...which explains how an agent 'looping' over sends to itself can be stopped.

9:23 BigTom: Chouser: Thank you for explaining before RTFMing :-)

10:58 turbo24prg: hmm, (doseq [a ... b ...] ... does loop a1 b1, a1 b2, ...

10:58 thought about (doseq [[a b] (interleave as bs)] ... but it doesn't work because interleave creates no sublists

10:59 any handy way to iterate over multiple lists element for element?

10:59 kotarak: (doc partition)

10:59 clojurebot: Returns 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:59 kotarak: (partition 2 (interleave a b))

10:59 turbo24prg: neat

10:59 thanks!

11:02 kotarak: For two things, one could maybe exploit zipmap. But that would be an ugly hack.

11:09 Chouser: what about just (map ... a b) ?

11:10 kotarak: doseq suggest side effects. So (dorun (map ... a b)), beh. :/

11:13 Chouser: mm, good point.

11:19 BigTom: how would I get a lazy sequence of random numbers?

11:20 ayrnieu: ,(take 30 (repeatedly #(rand-int 30)))

11:20 clojurebot: (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:20 ayrnieu: ,(.contains (apply str (take 1000000 (repeatedly #(char (+ (int \a) (rand-int 26)))))) "ayrnieu")

11:20 thickey: rhickey or Chouser: where can i find the script that currently generates the api page?

11:20 clojurebot: false

11:22 BigTom: ayrnieu: thanks

11:29 Chouser: thickey: I've never seen that script, only heard rumors of its existance.

11:30 thickey: Chouser: =) okay, thanks

11:37 BigTom: ok so I have this:

11:37 ,(into #{} (partition 2 (interleave [1 2 5 4] [5 6 1 8])))

11:37 clojurebot: #{(2 6) (4 8) (1 5) (5 1)}

11:38 BigTom: but I really want a set of vectors

11:38 ayrnieu: ,(class #{(2 6})

11:38 clojurebot: Eval-in-box threw an exception:Unmatched delimiter: }

11:38 ayrnieu: OK. (map vector ...) ?

11:39 well, I'd think that'd work, but it doesn't.

11:39 ,(into #{} (map #(apply vector %) (partition 2 (interleave [1 2 3 4] [5 6 1 8]))))

11:39 clojurebot: #{[2 6] [4 8] [1 5] [3 1]}

11:39 kotarak: (doc vec)

11:39 clojurebot: Creates a new vector containing the contents of coll.; arglists ([coll])

11:40 kotarak: ,(map vec (partition 2 (interleave [1 2 3] [4 5 6])))

11:40 clojurebot: ([1 4] [2 5] [3 6])

11:40 BigTom: ah, sweet

11:40 ayrnieu: just found that with (find-doc "vector") :-)

11:46 BigTom: another includes? bites th edust

11:46 thickey: Chouser: this looks like it: http://paste.lisp.org/display/71857

11:49 Chouser: thickey: ah, thanks.

11:51 thickey: i 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:52 ayrnieu: http://gee.cs.oswego.edu/dl/concurrency-interest/index.html , but other changes are needed.

11:52 durka42 went through it earlier: http://clojure-log.n01se.net/

11:54 Chouser: ,(map vector [1 2 3] [4 5 6])

11:54 clojurebot: ([1 4] [2 5] [3 6])

12:19 thickey: rhickey: 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:20 rhickey: thickey: there's a jsr166y.jar in the files section of the google group - try that

12:20 thickey: rhickey: it seems like there was some refactoring and the parallel classes are now in extra166y.jar

12:20 rhickey: ok

12:24 turbo24prg: to 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:24 kotarak: (conj the-set the-thing)

12:25 turbo24prg: neat. thanks. finding all the methods is hard. and it's cool if they exist :)

12:26 kotarak: conj works also for maps, vectors, lists, ...

12:28 Vargr2: I 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:28 turbo24prg: CL felt a lot more practical then scheme, but clojure seems even more practical

12:30 Vargr2: updated this morning, seems to work here

12:31 Vargr2: turbo24prg: I get "Synchronous Lisp Evaluation aborted" when trying to expand. No problem with CLISP and SBCL, so SLIME should be alright, no?

12:31 kotarak: turbo24prg: http://clojure.org/api gives a nice summary

12:31 for functions I mean

12:34 turbo24prg: kotarak: i'm browsing /api, /sequences all the time :)

12:37 Vargr2: i'm using 23.0.60.1, no probs. duno

12:39 it shouldn't be possible that the hash-codes of strings would < but the strings themself >, right?

12:39 Chousuke: why not? :/

12:39 I don't think hash codes support ordering

12:41 turbo24prg: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#hashCode()

12:42 ,(hash "6")

12:42 clojurebot: 54

12:42 turbo24prg: ,(hash "7")

12:42 clojurebot: 55

12:42 turbo24prg: ,(hash "71")

12:42 clojurebot: 1754

12:42 durka42: ,(hash "7")

12:42 clojurebot: 55

12:43 turbo24prg: imho they're ordered, no?

12:44 ayrnieu: ,(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:44 clojurebot: -1376680459

12:44 ayrnieu: it's positive if you spell her name correctly, but still a counterexample.

12:45 clojurebot: svn rev 1241; fixed pmap so parallel in first n steps

12:46 turbo24prg: arbscht: thanks

12:46 erm, ayrnieu.

12:48 durka42: ,(Integer/toHexString -1376680459)

12:48 clojurebot: "adf185f5"

12:50 turbo24prg: so, to compare strings i'd have to call java then?

12:51 no string<, string= ...

12:55 Chouser: ,(compare "abc" "abc")

12:56 (doc compare)

12:56 clojurebot's dead

12:58 durka42: you can't just use = ?

12:58 = uses .equals internally

13:00 turbo24prg: but < works only on numbers

13:01 durka42: oh, true

13:02 (doc compare)

13:02 clojurebot: Comparator. 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:02 durka42: (compare "bar" "bar")

13:02 ,(compare "bar" "bar")

13:02 clojurebot: 0

13:02 durka42: ,(compare "bar" "quux")

13:02 clojurebot: -15

13:02 durka42: ,(compare "quux" "bar")

13:03 clojurebot: 15

13:05 ayrnieu: ,(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:05 clojurebot: [-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:07 ayrnieu: but if you're paranoid, (sort #(.compareTo %1 %2) ...)

13:07 turbo24prg: uh, i still thing a way to cl. cool that there are so many generic functions

13:07 thanks.

13:51 clojurebot: svn rev 1242; [lazy] switched concat to lazy-seq, added Sequence, printing of sequences, more returns non-nil

13:54 adakkak: can someone tell me what is wrong with this basic program? I am just learning clojure http://paste.lisp.org/display/74642

13:55 leafw: adakkak: ([] ([])) makes little sense. You meant ([] []) ... yet it still makes little sense: for no args, return empty vector?

13:56 adakkak: leafw: what should I be returning?

13:56 Chousuke: adakkak: that looks like you're trying to do haskell-style pattern matching

13:57 clojure doesn't support it :/

13:57 adakkak: does clojure have any pattern matching for function's arguments?

13:58 Chousuke: no.

13:58 well, there's destructuring

13:58 which is kind of similar, but not pattern matching.

13:59 ,(apply str (map #(str % "s") '("this" "is" "a" "test")))

13:59 clojurebot: "thississastests"

13:59 Chousuke: hmm

13:59 not quite

13:59 adakkak: do you know if scheme has pattern matching?

13:59 Chousuke: I'm not sure, but I don't think it does.

14:00 adakkak: what you're doing in that piece of clojure code is defining two overloads of the same function, just of different arity.

14:01 you're never even calling the nullary version :)

14:01 eyeris: Could someone point me to the explaination of the & symbol in defmacros?

14:01 adakkak: Chousuke: so why doesn't the piece of code work?

14:01 Chousuke: adakkak: you don't have a termination clause. it keeps recursing infinitely.

14:03 at 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:03 since (rest nil) is nil

14:03 adakkak: Chousuke:Ahh, so (rest ()) is nil?

14:03 Chousuke: yeah; though you'll never see a () there :/

14:03 nil is not equal to ()

14:04 ,(rest nil)

14:04 clojurebot: nil

14:04 Chousuke: ,(rest '())

14:04 clojurebot: nil

14:04 Chousuke: (= '() nil)

14:04 ,(= '() nil)

14:04 clojurebot: false

14:05 Chousuke: ,(rest '(1))

14:05 clojurebot: nil

14:10 adakkak: Chousuke: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:13 ayrnieu: adakkak: (if (= (count sentence) 1) (plural_word sentence)

14:14 adakkak: ayrnieu: what is wrong with it?

14:15 Chousuke: adakkak: http://paste.lisp.org/display/74642#3

14:15 adakkak: the sentence is still a list

14:16 adakkak: you want the word from it

14:16 ,(str (first '("test")))

14:16 clojurebot: "test"

14:17 Chousuke: if you forget the first, you get the parens too

14:17 adakkak: as an aside, use dashes instead of underscores in naming

14:17 plural-word instead of plural_word

14:17 adakkak: Chousuke: is that the convention in clojure?

14:18 ayrnieu: that's the convention in every language that permits dashes in symbols.

14:18 dreish: adakkak: It is in all Lisps, but beyond convention, I think underscores in Clojure are informally reserved for gensyms.

14:19 adakkak: I am wondering if having (plural-word (first sentence)) twice in the code is considered bad practice in clojure?

14:20 Chousuke: it's not a deadly sin

14:21 adakkak: also, how do you know that there is a keyword called remaining? I am checking the api and there is no mention of it!

14:25 Chousuke: adakkak: it's not a keyword

14:25 adakkak: I bind it, in the if-let

14:25 aartist_: why clojure?

14:26 Chousuke: adakkak: http://paste.lisp.org/display/74642#5

14:26 adakkak: so that is the difference between a regular if and if-let

14:26 Chousuke: adakkak: if-let makes a binding at the same time

14:26 adakkak: makes sense

14:27 Chousuke: it's a shortcut for (let [foo bar] (if foo dostuff do-otherstuff))

14:27 ie. that would be: (if-let [foo bar] dostuff do-otherstuff)

14:28 where the do-otherstuff is executed when "foo" is non-true

14:29 keithb: Is 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:30 Chousuke: "sequential order"?

14:30 keithb: I mean in the order in which they were specified in the code.

14:30 Chousuke: I think with commutes the order is not guaranteed

14:30 adakkak: Chousuke: how does foo become false, I though even nil does not evaluate to false

14:31 Chousuke: adakkak: hm? :/

14:31 both "nil" and "false" are non-true values in clojure

14:31 ayrnieu: http://paste.lisp.org/display/74642#6 defmulti version.

14:32 Chousuke: ,(if nil "nil is true" "nil is false")

14:32 clojurebot: "nil is false"

14:32 Chousuke: (if-let [foo nil] :true :false)

14:32 gah

14:33 ,(if-let [foo nil] [:true foo] [:false foo])

14:33 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

14:33 Chousuke: ... okay, I fail.

14:33 foo is of course not bound if it'd be false :P

14:33 ayrnieu: ,(if-let [foo true] [:true foo] [:false foo])

14:33 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

14:34 Chousuke: ,(if-let [foo 1] foo :nothing)

14:34 clojurebot: 1

14:34 Chousuke: ,(if-let [foo nil] foo :nothing)

14:34 clojurebot: :nothing

14:34 ayrnieu: sensible.

14:37 adakkak: Chousuke: got it

14:53 lisppaste8: ayrnieu pasted "defmulti examples" at http://paste.lisp.org/display/74647

14:53 ayrnieu: translated from mercury translated from haskell.

14:55 I 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:23 hiredman: ayrnieu: I imagine you wanted ' not `

15:23 ayrnieu: hiredman - no, I want ` there.

15:24 hiredman: ok

15:24 Chousuke: ayrnieu: maybe defmulti didn't like the namespace-qualified symbols.

15:24 ,(= 'foo `foo)

15:24 clojurebot: false

15:25 hiredman: ,`foo

15:25 clojurebot: clojure.core/foo

15:25 hiredman: ,'foo

15:25 clojurebot: foo

15:26 hiredman: huh

15:26 Chousuke: hiredman: did you notice my (doc fix? (I hope I didn't break anything)

15:26 hiredman: Chousuke: no I did not notice anything

15:27 * hiredman pulls

15:27 ayrnieu: aha. OK, defmulti does work with symbols, but his `foo 'foo difference only reemphasises that symbols will not work for data-structures like this.

15:32 hiredman: (doc namespace)

15:32 clojurebot: Returns the namespace String of a symbol or keyword or nil if not present ; arglists ([x])

15:32 hiredman: (doc for)

15:32 clojurebot: 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 y range 1000000 while y x x y ; argli

15:32 hiredman: excellent

15:34 Chousuke: the docstrings aren't properly punctuated, which is a slight problem

15:37 cooldude127: Chousuke: what's changed?

15:37 Chousuke: it removes whitespace and handles nil arglists

15:38 (doc *print-dup*)

15:38 clojurebot: When set to logical true objects will be printed in a way that preserves their type when read in later Defaults to false

15:38 Chousuke: no arglist :)

15:39 cooldude127: oh

15:39 but why does it remove punctuation?

15:39 Chousuke: it doesn't.

15:40 there's no punctuation to remove :P

15:40 cooldude127: oh. i'm confused

15:40 hiredman: Chousuke: maybe [^ ] instead of \\W or whatever

15:40 Chousuke: see the docstring for *print-dup* in your repl.

15:41 cooldude127: Chousuke: i see nil

15:41 maybe i'm behind

15:41 Chousuke: heh, yeah

15:41 cooldude127: Chousuke: but my (doc for) has periods

15:41 hiredman: (doc for)

15:41 clojurebot: ; arglists ([seq-exprs expr])

15:41 Chousuke: I guess I forgot proper punctiation from teh docstrings

15:41 hiredman: whoops

15:42 Chousuke: :D

15:42 cooldude127: lol

15:42 hiredman: (doc for)

15:42 clojurebot: 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 y range 1000000 while y x x y ; argli

15:43 cooldude127: see even the parens and stuff for the example are gone, that can't be good

15:45 hiredman: (doc for)

15:45 clojurebot: 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) y (range 1000000) :

15:45 cooldude127: yay

15:46 hiredman: switched from \\W+ to \\s+

15:47 MarkVolkmann: The REPL doesn't recognize the union function.

15:48 (doc union) comes back with "Unable to resolve var: union in this context".

15:48 I'm trying to use it to combine two sets into one.

15:48 hoeck: ,(doc clojure.set/union)

15:48 clojurebot: "([xset yset]); Returns a set that is the union of the two sets."

15:48 Chousuke: MarkVolkmann: it's not in the clojure.core namespace :)

15:49 MarkVolkmann: Thanks! Looking at http://clojure.org/api, I'm not sure how I could have known that.

15:49 Chousuke: hmm

15:50 hiredman: http://clojure.org/api#toc588 <-- it is in the clojure.set section of the api

15:50 Chousuke: it does have the section titled

15:50 but it doesn't really stand out.

15:50 MarkVolkmann: Ah, I see. It's kind of hidden, just after the documentation for pvec.

15:50 It's in the same font as all the function names, so it's easy to miss.

15:50 Chousuke: definitely needs improvement :/

15:51 even better would be to have everything explicitly show their namespace.

15:54 ayrnieu: ,(name 'user/x)

15:54 clojurebot: "x"

15:54 ayrnieu: how do I get "user" out of that?

15:54 ,(namespace 'user/x) ;; oh.

15:54 clojurebot: "user"

15:56 ozy`: ,(map + (range 20) (range 0 40 2))

15:56 clojurebot: (0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57)

15:56 ozy`: ,(map #'list (range 20) (range 0 40 2))

15:56 clojurebot: ((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:57 hiredman: ,(map list (range 20) (range 0 40 2))

15:57 clojurebot: ((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:58 ozy`: ,;

15:58 clojurebot: Eval-in-box threw an exception:EOF while reading

15:58 ozy`: ,(display 'woot)

15:58 clojurebot: java.lang.Exception: Unable to resolve symbol: display in this context

15:58 ozy`: ,(println '(pizza))

15:58 clojurebot: (pizza)

16:01 ozy`: ,(println '(SYMBOLS IN ALL CAPS))

16:01 clojurebot: (SYMBOLS IN ALL CAPS)

16:15 ayrnieu: http://gist.github.com/55662 <-- similar, but checks at compile-time that you've handled every case.

16:18 * ayrnieu sets that aside.

16:19 hiredman: clojurebot: parens is <reply>????? ????

16:19 clojurebot: Roger.

16:20 Chousuke: ?)

16:21 hiredman: oooh

16:22 google translate has a "ajax" (json) api

16:22 danlarkin: I smell a new feature

16:56 blbrown: does anyone remember where the clojure api examples are on the wiki

16:57 nevermind, http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

16:57 LordOfTheNoobs: clojurebot: api examples?

16:57 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

16:58 blbrown: I 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:04 http://paste.lisp.org/display/74655 is this not valid code

17:07 durka42: you might have missed some parens around the println

17:07 which line is 177?

17:07 gnuvince_: blbrown: use e#

17:07 ayrnieu: (let [e (gensym)] `(try ... (catch Exception ~e (. ~e ...))))

17:07 blbrown: durka42 error at when I called it (when-try (clojure.xml/parse db-path))

17:08 ayrnieu: if you really want 'e, you can ~'e

17:09 durka42: i mean there's no real need for a gensym there

17:09 ayrnieu: ,[`(list ~'e) `(list e)]

17:09 clojurebot: [(clojure.core/list e) (clojure.core/list clojure.core/e)]

17:20 blbrown: this is what I ended up with, works. (defmacro when-try [body] `(try (~@body) (catch Exception ~'e nil)))

17:22 Chouser: sorry I'm jumping in late here, but why ~'e instead of e# ?

17:22 blbrown: and I guess I only need ~@body not (~@body)

17:23 ayrnieu: ~body not (~@body)

17:23 clojurebot: It's greek to me.

17:25 blbrown: ~your mom

17:25 clojurebot: Huh?

17:25 blbrown: ~mom

17:25 clojurebot: It's greek to me.

17:26 durka42: Chouser: there's no user code being run with e bound, so why bother gensymming?

17:27 blbrown: I just pjb3 I just twittered you, small world isn't it

17:28 pjb3: blbrown: indeed

17:33 Chouser: durka42: 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:33 gnuvince_: ,(= Short java.lang.Short)

17:33 clojurebot: true

17:34 gnuvince_: hmmm

17:34 durka42: ,(time (dotimes [_ 1000] (gensym)))

17:34 clojurebot: "Elapsed time: 12.013 msecs"

17:35 durka42: ,(time (dotimes [_ 1000] `(~'e)))

17:35 clojurebot: "Elapsed time: 1.997 msecs"

17:36 ayrnieu: 10ms difference at compile-time per thousand. I'll get right on optimizing for that.

17:36 gnuvince_: hahah :)

17:37 durka42: kind of a silly reason though

17:37 i guess if you refactored the macro later and bound e before user code, then forgetting to change it to e# could cause problems

17:37 :)

17:37 * gnuvince_ hugs multimethods

17:53 durka42: i must find a way to work "absquatulate" into normal conversation

17:57 Chouser: wouldn't it immediately cease to be a normal conversation?

17:57 durka42: quite possibly

17:57 Chouser: all the better, I suppose.

17:59 gnuvince_: durka42: what does that mean?

17:59 durka42: it means to leave abruptly

18:00 gnuvince_: Easy

18:00 Go to a friend's

18:00 Pretend you have an urgent phone call on your cell

18:00 "I'm sorry, I must absquatulate!"

18:01 hiredman: "I cannot help but notice you are absquatulating with all the food"

18:08 I forget, is there a pretty printer yet?

18:08 ayrnieu: there's cl-format

18:09 hiredman: does that do indenting and what not?

18:09 ayrnieu: I haven't explored it.

18:09 hiredman: where is there?

18:09 ayrnieu: github.

18:10 durka42: i believe "think about a pretty printer" is on the cl-format todo list

18:10 hiredman: damn

18:17 cooldude127: Woo, colloquy for iPhone :)

18:21 dreish: clojurebot: clojure-mode?

18:21 clojurebot: clojure-mode is an Emacs mode for Clojure, found at git://github.com/jochu/clojure-mode.git

18:21 dreish: Thanks.

18:22 durka42: to thank clojurebot,

18:22 clojurebot: botsnack

18:22 clojurebot: thanks; that was delicious. (nom nom nom)

18:36 eee: hi

18:37 here's my latest gripe: I api is gibberish to me

18:37 let's take a simple example that I understand

18:38 hi

18:38 about to complain :)

18:38 Chousuke: gibberish? you mean you can't understand it?

18:38 eee: yup

18:38 Chousuke: I guess it could be a bit better

18:38 eee: here's an example

18:38 Chousuke: You should read the wiki to get started; the api is more of a reference.

18:38 eee: look at "doall" . . .with doall, I know what it does

18:38 and I understand the english description

18:38 very nice

18:38 so I'm lucky

18:39 cause I can't make heads or tails of the gibberish part

18:39 Chousuke: which part is that?

18:39 eee: ([coll] [n coll]) or something?

18:39 what the heck?

18:39 Chousuke: ah, that's the possible parameter lists

18:39 ayrnieu: (defn foo ([a] (mangle a)) ([a b] (frob a b)))

18:40 Chousuke: eee: that means it can take either two parameters, or one

18:40 eee: oh

18:40 should never use the brckets there

18:41 shold be, like (<coll> <n coll>)

18:41 Chousuke: um, no

18:41 eee: brackets are actually used in the language

18:41 ayrnieu: eee, the 'foo' I just defined is valid clojure.

18:41 eee: yes I get it

18:41 Chousuke: eee: that's why the parameter lists are like that too

18:41 eee: it takes an a or an a and a b

18:41 Chousuke: they are like they are in the language itself.

18:42 eee: i've made functions like that

18:42 I assume that's a multimethod, but I don't know

18:42 Chousuke: it's not a multimethod

18:42 eee: oh drat

18:42 Chousuke: it's simply an overloaded function

18:42 anyway, for complex parameters, using the language's own notation is better.

18:42 eee: yeah . . .I was hoping that was a multimethod

18:42 oh well

18:42 dreish: eee: Have you read Programming Clojure?

18:43 eee: not yet

18:43 dreish: If you're interested enough to ask this many questions, why not buy the book?

18:43 eee: doesn'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:43 dreish: It's an excellent way to learn the language.

18:43 Chousuke: for 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:44 eee: i didn't know that was destructureing. that's cool . . that fills in another blank. I use that form

18:44 ok, so how would the docs look for something that destructures like that?

18:45 Chousuke: it would say its possible parameters are ([[a b c] % rest])

18:45 ayrnieu: but: destructuring doesn't work on lists, and it isn't coll-agnostic.

18:45 Chousuke: er

18:45 &*

18:46 eee: so you see, the parameter list in the doc exactly matches the function definition :)

18:46 eee: i've used [a b c & rest]

18:46 Chousuke: eee: that's a different function

18:46 eee: yeah

18:46 Chousuke: er, a different kind of parameter list that is.

18:46 my function, you'd call like (fun [1 2 3] 4 5 6)

18:47 eee: well, it doesn't exactly match the function definition because it's missing the context of the defn and the name of the function

18:47 Chousuke: so a, b and c would be 1, 2 and 3 respectively, and rest would be (4 5 6)

18:47 eee: better docs would be

18:47 Chousuke: eee: the name of the function is printed above isn't it.

18:47 eee: (defn foo [a] ... [a b] ...)

18:48 now THAT would rock

18:48 what I just wrote leaves no ambiguity

18:48 Chousuke: where would you put the documentation? :/

18:48 also I don't understand why this is at all better.

18:49 it's basically hte same.

18:49 just with a defn and a few parentheses.

18:49 eee: where it says "arguments" . . . .that's not quite accutate

18:49 durka42: it is ambiguous... is [a b] another param list, or is the vector part of the function

18:49 eee: there's a needless list around it . . .a set of parens confusing things

18:49 night as well throw the defn in there

18:49 Chousuke: eee: it's not a needless list

18:49 it's a list of the possible argument vectors you can pass in

18:50 eee: well, I guess I get it now . . .but I would never have needed to my way. would have had only one interpretation

18:50 Chousuke: I don't see how :/

18:50 eee: what durka42 said is why

18:51 it's awash with symbols . . . .

18:51 anti-tufte

18:51 Chousuke: I don't follow :/

18:52 eee: that () around the whole thing

18:52 I'd even go for

18:52 Chousuke: eee: well, that's because it's a list.

18:52 it's a list of the ways to call the function

18:52 eee: arguments: a | a b

18:52 Chousuke: the list is more clojurey :/

18:52 eee: the vector isn't even needed

18:52 Chousuke: yes it is.

18:53 eee: just use a pipe to separate the two choices

18:53 otherwise I'm thinking . . ."takes a vector with a collection, what?"

18:53 noise

18:53 a | a b ...

18:53 or

18:53 in the case of doall

18:53 coll | coll1 coll2 ...

18:54 coll | coll1 coll2 ... colln

18:54 ayrnieu: so 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:54 Chousuke: eee: it's not like that though

18:54 eee: nowlol

18:54 Chousuke: it's coll | n coll

18:54 eee: doall?

18:54 Chousuke: yeah

18:54 eee: i upset rhickey

18:54 Chousuke: the thing is, anyone familiar with how to define clojure function definitions can read the docs :/

18:54 eee: he's not gonna let me play

18:54 Chousuke: ...

18:54 how to define clojure functions*

18:55 eee: ok, awesome . . .one more thing people have to learn

18:55 I'm trying to help this stuff be how we all program

18:55 cause I like it

18:55 too bad rich missed that part

18:55 :(

18:55 in unix

18:55 Chousuke: well... clojure is not going to be very useful to you if you don't learn how to define clojure functions.

18:56 eee: angle brackets are reserved for <variable>

18:56 so maybe

18:56 hiredman: it being functional and all

18:56 ayrnieu: eee, 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:56 Chousuke: in C docs, the functions are just as often given as "void foo(bar, baz)" in docs, so I don't see your point.

18:56 clojure is not the unix shell.

18:56 eee: <coll> | <coll1> <coll2> ... <colln>

18:57 you should see my point

18:57 in C

18:57 you just see the prototype

18:57 without the body

18:57 but in clojure it's all split up

18:57 the name

18:57 then a different section with a list of params

18:57 Chousuke: they're not that far apart...

18:57 eee: why put the parens like it is a c function

18:57 ayrnieu: it's not just split up in the doc, it's split up in the function.

18:58 eee: when you write it, you use clojure syntax

18:58 Chousuke: eee: eh, the parens aren't ther for that purpose. it's a *list*, you see.

18:58 so you use parens.

18:58 eee: when you see it in the api, you see C syntax

18:58 the parens wrap the params for some reason

18:58 ok

18:58 a list of optional cases

18:58 durka42: "some reason" being so that the compiler can parse it correctly

18:58 yes

18:59 gnuvince_: Did I miss something interesting/inflamatory?

18:59 eee: I dunno. just seems like if a prototype makes sense in c of java, clojure should do it like I wrote it

18:59 Chousuke: eee: that list of argument vectors actually exists as a data structure in the fuction metadata.

18:59 eee: (defn foo [a] ... [a b] ...)

18:59 Chousuke: the documentation just prints it as is.

18:59 eee: like that right there

19:00 ,(doc doall)

19:00 clojurebot: "([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:00 Chousuke: eee: but the problem is that that's not a prototype; that's a definition

19:00 hiredman: ,(:arglists (meta #'println))

19:00 clojurebot: ([& more])

19:01 eee: ok, if I ask for arglist, that's one thing

19:01 if I ask for api, that's another

19:01 Chousuke: I really don't see a problem.

19:01 it's a convention.

19:01 get used to it.

19:01 eee: looks like all someone did for api was call arglist and comments

19:01 ayrnieu: so write a my-doc and show us how much better it is.

19:01 eee: convention . . . this is why I brought up tufte

19:01 Chousuke: eee: yeah, that's pretty much what it is.

19:02 hiredman: ,(:arglists (meta #'my-doc))

19:02 clojurebot: java.lang.Exception: Unable to resolve var: my-doc in this context

19:02 hiredman: ,(:arglists (meta #'mydoc))

19:02 clojurebot: java.lang.Exception: Unable to resolve var: mydoc in this context

19:02 hiredman: ,(:arglists (meta #'doc))

19:02 clojurebot: ([name])

19:02 hiredman: hmmm

19:02 Chousuke: eee: but what the arglist looks like is the least of the documentation worries.

19:02 eee: ,(arglist doall)

19:02 clojurebot: java.lang.Exception: Unable to resolve symbol: arglist in this context

19:02 eee: ,(arglist #doall)

19:02 clojurebot: Eval-in-box threw an exception:No dispatch macro for: d

19:02 eee: ,(:arglist #doall)

19:02 clojurebot: Eval-in-box threw an exception:No dispatch macro for: d

19:02 Chousuke: ,(:arglists ^#'doc)

19:02 clojurebot: ([name])

19:03 Chousuke: ,(:arglists ^#'doall) ;een

19:03 clojurebot: ([coll] [n coll])

19:03 Chousuke: even :P

19:03 eee: ,(:arglist ^#'doall)

19:03 clojurebot: nil

19:03 Chousuke: missed an s

19:03 eee: ,(:arglists ^#'doall)

19:03 clojurebot: ([coll] [n coll])

19:03 eee: oh

19:04 thanks for explaining it to me

19:04 Chousuke: you're free to go write your own pretty-printer for documentation.

19:04 something searchable or cross-referenced would be great. the regular API page is a bit plain :/

19:04 lisppaste8: ayrnieu pasted "print-doc" at http://paste.lisp.org/display/74659

19:04 eee: sounds like a good thing to practice with

19:05 gnuvince_: Chousuke: pretty sure there was someone who did something like that in Enclojure and posted about it on the mailing list.

19:05 eee: i know several people added doc writers to that list in the user group about third-party stuff

19:05 well, I was just complaining about the enclojure stuff

19:05 that's what brought me in here

19:05 :)

19:06 all 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:06 but for some reason

19:06 people are able to get up and going on it

19:06 without much understanding of "convention"

19:07 but I get it now

19:07 (I think)

19:07 :)

19:07 ,(doc arglists)

19:07 clojurebot: java.lang.Exception: Unable to resolve var: arglists in this context

19:08 eee: oh

19:08 taht's a key

19:08 huh?

19:08 ayrnieu: ,(:a {:a :b})

19:08 clojurebot: :b

19:08 gnuvince_: It's a key on the meta-data.

19:08 eee: yeah

19:08 Chousuke: ,^#'doall

19:08 clojurebot: {: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:09 eee: now can functions be named with colon at the beginning?

19:09 Chousuke: no

19:09 gnuvince_: But what was your objection? That Clojure doesn't have a Java-like syntax?

19:09 ayrnieu: ,(let [x :a] [(class x) (x {:a :b})])

19:09 clojurebot: [clojure.lang.Keyword :b]

19:09 eee: no

19:09 that the api makes sense

19:09 in java

19:09 without any confusing

19:09 Chousuke: symbols starting with a colon are always keywords :)

19:09 eee: now I have to do a survey of newbies

19:10 gnuvince_: That the API makes sense?

19:10 eee: and find out if it's just that I'm the only one who finally asked out loud

19:10 gnuvince_: The API or the API documentation?

19:10 Chousuke: maybe some note could be put on top of the API documentation page about how to read it

19:10 ayrnieu: ,[(class (symbol ":a")) (class :a)]

19:10 clojurebot: [clojure.lang.Symbol clojure.lang.Keyword]

19:10 eee: i mean the format of the documentation

19:10 Chousuke: it's easy to read, but you do need to know how

19:10 ayrnieu: ,(= (symbol ":a") :a)

19:10 clojurebot: false

19:10 Chousuke: or hm, actually

19:10 eee: that would be good chosuke . . .I actually looked for that

19:10 gnuvince_: eee: on the web site? Yeah, it's not terrible. Feel free to contribute something better organized/indexed.

19:10 eee: maybe it is there somewhere

19:11 Chousuke: the API page itself doesn't have your particular problem

19:11 but (doc foo) does :/

19:11 gnuvince_: Chousuke: how do?

19:11 *so

19:11 Chousuke: gnuvince_: he doesn't like the way argument vectors are just dumped out as a list

19:11 eee: \:

19:12 i wish I cold be so succinct. well put

19:12 Chousuke: the api page actually has (doall coll), (doall n coll)

19:12 eee: heh

19:12 gnuvince_: ah

19:12 eee: i don't even remember . . .I guess it's how it is in enclojure them

19:12 ayrnieu: eee, 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:13 eee: i just reflected on how I didn't get the api page, either . . .so gave up on it along time ago

19:13 gnuvince_: I figure once you learn it, the (doc) format makes sense; a list of all the different arities a function takes.

19:14 Chousuke: yeah.

19:15 eee: you 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:15 no conventions

19:15 cognitively ergonomic

19:16 gnuvince_: Write a patch

19:16 eee: well, I'm see what people think

19:16 I could just be an idiot

19:16 but it could be fun to play with

19:16 I grabbed that code

19:17 gnuvince_: like ayrnieu said, just go and edit print-doc

19:19 eee: k, thanks

19:19 ayrnieu: ,[:a ::a]

19:19 clojurebot: [:a :clojure.core/a]

19:20 eee: is print-doc part of doc?

19:20 ,(doc print-doc)

19:20 clojurebot: "([v]); "

19:20 Chousuke: not documented :)

19:21 gnuvince_: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#2766

19:21 print-doc is called by the doc macro

19:22 Chousuke: used by doc; if you do (binding [print-doc my-print-doc] (doc foo)) you might be able to override it

19:22 straight up redefining it works too, but it's less clean :/

19:22 gnuvince_: ,'#{a b c}

19:22 clojurebot: #{a c b}

19:23 eee: it barfed when I tried to redefine it

19:23 hiredman: you can actually rebind the var the doc macro is attached to too

19:23 eee: ok

19:23 hiredman: (binding [doc nil] (doc foo))

19:23 ayrnieu: ,(binding [print-doc #(println (:name ^%) " - " (:arglists ^%))] (doc doall))

19:23 clojurebot: "([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:24 ayrnieu: WFM. clojurebot is doing something special.

19:24 hiredman: clojurebot rebinds doc internally

19:24 to another macro

19:25 eee: that bot is cool. who wrote it?

19:25 ayrnieu: ,(binding [print-doc #(println (:name ^%) " - " (:arglists ^%))] (clojure.core/doc doall))

19:25 clojurebot: "([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:25 ayrnieu: oh well.

19:25 Chousuke: hiredman wrote most of it. I did some restructuring and now hiredman seems to be implementing all kinds of weird features.

19:26 hiredman: ayrnieu: 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:31 gnuvince_: 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:32 More concretely, I am dealing with java.nio.ByteBuffers, and I was wondering what would be the right way to deal with BufferUnderflowExceptions.

19:32 hiredman: ,(pipeline '(a b (h (g y))))

19:32 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol

19:33 hiredman: ,(pipeline '(a b (h y (g y))))

19:33 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol

19:33 hiredman: hmmm

19:33 ayrnieu: ,(doc pipeline)

19:33 clojurebot: "([a]); "

19:35 blbrown: is 'doto' a macro?

19:35 Chousuke: yes

19:35 blbrown: I like it

19:35 Chousuke: see -> as well :)

19:36 gnuvince_: I wonder; does returning nil in such a case make sense?

19:36 gnuvince_: are there cases where returning will could be useful non-error behaviour?

19:37 ... nil

19:37 ayrnieu: ,(symbol (.getName (first (.getMethods String))))

19:37 clojurebot: hashCode

19:37 ayrnieu: ,(-> String .getMethods first .getName symbol)

19:37 clojurebot: hashCode

19:39 gnuvince_: Chousuke: not really. Actually, now that I think about it, I think that an exception indicates that there's something very wrong

19:41 Chousuke: yeah.

19:41 ayrnieu: extraordinary control flow

19:42 Chousuke: exceptions should indicate that not everything goes as planned. returning nil instead is a "I have nothing for you" kind of thing

19:42 gnuvince_: Yeah

19:43 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:44 Chousuke: only if the missing two bytes went missing because of a malfunction :/

19:48 gnuvince_: Chousuke: it's from a defined file format. If there's an error anywhere, the entire thing is corrupt.

19:48 Chousuke: yeah, that sounds exceptional enough :)

19:53 gnuvince_: Chousuke: I don't know if you read my latest blog post about reading binary data, but it's the continuation of that.

19:53 Changed a few things

19:53 Chousuke: gnuvince_: maybe it'd still make sense to return nil in the case the file is corrupt

19:54 gnuvince_: Chousuke: I will probably return nil for the whole operation

19:54 (decoding the file)

19:55 But not for the smallest tasks like reading one field.

19:55 But at that point, I'll be in consumer code.

19:55 Where making that decision is easier.

20:05 hiredman: clojurebot: translate to it: my hovercraft is full of eels!

20:05 clojurebot: il mio hovercraft è pieno di anguille!

20:07 hiredman: clojurebot: translate to zh: my hovercraft is full of eels!

20:07 clojurebot: 我国气垫船充满鳗鱼!

20:14 blbrown: has 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:32 danlarkin: clojurebot: translate to hu: my hovercraft is full of eels!

20:32 clojurebot: Saját légpárnás tele van eles!

20:32 danlarkin: not handling the encoding very well I guess

20:36 ivan: double-utf8ed

21:14 hiredman: ~translate to ru: in soviet russia the state mutates you!

21:14 clojurebot: ? ????????? ?????? ??????????????? ???????? ???!

21:14 hiredman: I guess puns don't translate well then...

21:14 ayrnieu: ~translate to zh: ? ????????? ?????? ??????????????? ???????? ???!

21:14 clojurebot: ? ????????? ?????? ??????????????? ???????? ??? !

21:14 hiredman: ayrnieu: to/from english only

21:15 ayrnieu: ~translate from ru: ? ????????? ?????? ??????????????? ???????? ???!

21:15 clojurebot: In Soviet Russia the state mutates you!

21:15 danlarkin: clojurebot: translate to hu: my hovercraft is full of eels!

21:15 clojurebot: Saj�t sikl�haj� tele van eles!

21:15 danlarkin: heyy there were are

21:16 ayrnieu: ~translate from zh: ??????

21:16 clojurebot: What you are

21:16 durka42: a friend who speaks russian tells me that google is spouting nonsense

21:16 ayrnieu: (not quite)

21:22 Wizardofwestmarc: a translation program spewing gibberish? Inconceivable!

21:23 blbrown: clojure 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:23 I will probably say something about clojure in a developer meeting, but that wont be for months

21:25 durka42: there was a post about clojure being used in a hospital

21:26 Wizardofwestmarc: well, not probably quite what you mean but Rich did present at a recent JVM workshop hosted by Sun themselves

21:26 blbrown: durka42, I remember that

21:26 Wizardofwestmarc: That sorta thing helps get the business side rolling

21:26 blbrown: I saw part of the google tech talk

21:26 ...or was that another language, I am getting them all confused these days

21:27 Wizardofwestmarc: hm, don't recall a GTT

21:28 blbrown: maybe not

21:30 Wizardofwestmarc: although Google taking an interest in clojure would certainly be interesting if it has happened/were to happen

21:30 since they already have Java in their standard dev stack

21:31 blbrown: they seem to have low standards on who they invite though (IMHO)

21:31 Wizardofwestmarc: oh? I've only watched a few of the talks of theirs

21:31 blbrown: OK, president Obama doesn't count

21:31 Wizardofwestmarc: (GTTs)

21:31 the one for the xkcd cartoonist was interesting because a ton of big name guys in comp sci/programming showed up

21:32 blbrown: I mean they have a high quantity over quality ratio

21:32 Wizardofwestmarc: right

21:32 I usually just watch ones by people I figure are worth watching based on their reputation

21:32 blbrown: I think the JVM workshop is probably a bigger deal

21:33 ayrnieu: "In this chapter you have seen four concurrency APIs: refs, atoms, agents,

21:33 blech.

21:33 " and vars. [...] So we are left with good old-fashioned locking."

21:33 Wizardofwestmarc: for getting noticed by a wide audience of companies who use the java stack it probably is

21:33 ayrnieu: Halloway's book?

21:33 ayrnieu: Yes.

21:34 Wizardofwestmarc: heh

21:34 I still need to read the newest beta

21:34 skimmed the chapter on Functional, but haven't looked at the other changes

21:34 also, was rather sad to see the Monte Carlo chapter got cut

21:35 blbrown: Wizardofwestmarc, there are lot of missing chapters

21:35 Wizardofwestmarc: beta 6 I think is content complete

21:35 blbrown: hell, I could have been happy with just that chapter

21:35 oooo, nice

21:36 Wizardofwestmarc: the impression I get is it's gone >(

21:36 blbrown: that sucks

21:36 Wizardofwestmarc: but yes, 5 and before had a bunch of stuff missing still

21:36 blbrown: they never put anything production quality in a tech book

21:36 Wizardofwestmarc: true

21:38 but boy, do I keep buying them <_<

21:38 was debating grabbing o'reily's new book, Algorithms in a nutshell

21:39 blbrown: Wizardofwestmarc, me too, I finally got code complete 2

21:39 Wizardofwestmarc: GREAT book

21:40 blbrown: Wizardofwestmarc, that book looks interesting

21:40 Wizardofwestmarc: I reread it every couple years

21:40 CC2 and Pragmatic Programmers are both books I dig out of my bookshelf every so often as refreshers

21:40 blbrown: I 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:01 dreish: Random fireworks outside.

23:44 blbrown: Wizardofwestmarc, I got the algorithm book.

23:45 actually I am thinking of writing a book (JVM languages for Enterprise Development, will cover a small bit in clojure)

23:50 gnuvince_: 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:53 durka42: what are the other functions?

23:53 some functions treat lists and vectors as having opposite order

23:53 ,(pop [1 2 3])

23:53 clojurebot: [1 2]

23:54 durka42: ,(pop '(1 2 3))

23:54 clojurebot: (2 3)

23:54 durka42: ,(conj [1 2 3] 4)

23:54 clojurebot: [1 2 3 4]

23:54 durka42: ,(conj '(1 2 3) 4)

23:54 clojurebot: (4 1 2 3)

23:54 gnuvince_: durka42: some functions inside my program, not Clojure ones.

23:55 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:55 durka42: well, i meant if your functions depend on clojure.core fns such as the above

23:55 gnuvince_: So obviously, I'd want to have my cake and eat it too.

23:55 durka42: want to paste something?

23:56 gnuvince_: durka42: It's quite a lot of code.

23:56 I'm going to try and narrow it down

23:56 At worse, I'll put it on github (where it was going anyway)

23:58 * durka42 will be back later

23:59 gnuvince_: HAH!

23:59 Got it

23:59 durka42: got it?

23:59 gnuvince_: doall was needed

Logging service provided by n01se.net