#clojure log - Dec 22 2010

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

0:00 amalloy: brehaut: nah, i should just do it right the first time instead of flattening the wrong version :P

0:00 brehaut: amalloy: haha sure :P

0:00 amalloy: &(into [] (for [[k v] {3 1, 2 2, 0 3}] (repeat v k)))

0:00 sexpbot: ⟹ [(3) (2 2) (0 0 0)]

0:00 amalloy: haha nope, not that either

0:00 dnolen: &(reduce concat (for [[k v] {3 1, 2 2, 0 3}] (repeat v k))))

0:00 sexpbot: ⟹ (3 2 2 0 0 0)

0:00 amalloy: &(mapcat (fn [[k v]] (repeat v k)) {3 1, 2 2, 0 3})

0:00 sexpbot: ⟹ (3 2 2 0 0 0)

0:01 brehaut: amalloy: nice

0:03 amalloy: mapcat solves a lot of problems if you remember it's there

0:03 dougbradbury: ^^

0:04 dougbradbury: amalloy:, dnolen:, brehaut: et al thanks!

0:04 I'll look at mapcat

0:04 brehaut: amalloy: it does. i knew it was possible with seq-m but couldnt remember the sane name :P

0:04 dougbradbury: haven't used it yet

0:05 dnolen: &(mapcat (juxt inc dec) [1 2 3])

0:05 sexpbot: ⟹ (2 0 3 1 4 2)

0:05 brehaut: &((juxt inc dec) 1)

0:05 sexpbot: ⟹ [2 0]

0:05 brehaut: i love juxt

0:07 amalloy: brehaut: juxt is great. fnil is another HOF that's surprisingly useful

0:07 dnolen: &((juxt true? false?) true)

0:07 sexpbot: ⟹ [true false]

0:07 amalloy: &((juxt :a :b :c) {:a 1 :b 4 :c 9})

0:07 sexpbot: ⟹ [1 4 9]

0:08 brehaut: amalloy: im quite confused about what fnil does

0:11 amalloy: &(let [m {:a 1}] (update-in m [:a] (fnil inc 0)))

0:11 sexpbot: ⟹ {:a 2}

0:11 amalloy: &(let [m {:a 1}] (update-in m [:b] (fnil inc 0)))

0:11 sexpbot: ⟹ {:b 1, :a 1}

0:12 brehaut: amalloy: awesome

0:12 amalloy: brehaut: you can often use fnil to gloss over the base case of your recursion

0:14 brehaut: amalloy: yeah thats really cool. definately adding it to my toolbox

0:16 amalloy: &(map (fnil (memfn length) "") ["foo" nil "x"])

0:16 sexpbot: java.lang.IllegalStateException: Var clojail.core/tester is unbound.

0:16 amalloy: &(doall (map (fnil (memfn length) "") ["foo" nil "x"]))

0:16 sexpbot: ⟹ (3 0 1)

0:17 amalloy: that is a really annoying bug to fix in sexpbot, btw. i've been trying to wrap my head around it for a couple days

0:19 brehaut: im off. have a good rest of your day

1:44 replaca: Q: does anyone know the idiom to get clojure.walk/walk to stop recursing at some point in its walk?

1:45 I want to create a modified version of loop that modifies any returns inside, but doesn't modify nested loops

1:46 s/returns/recurs/

1:46 sexpbot: <replaca> I want to create a modified version of loop that modifies any recurs inside, but doesn't modify nested loops

1:47 amalloy: replaca: walk doesn't recur at all; it's post-walk that adds the recursive-ness

1:48 you want to call walk with an <inner> function like (fn [x] (if (some-condition x) x (some-transform x)))

1:49 replaca: amalloy: ahh, that makes the code make sense! Thanks for the insight - I knew I was missing something

1:55 brehaut: i think i have succeeded in writing my scraggliest piece of clojure so far. unimpressed with myself; there must be a cleaner way.

1:55 amalloy: brehaut: an admirable attitude, and expressed in such a way that i can't help but laugh

1:55 brehaut: amalloy: hah :)

1:56 amalloy: any ideas on 'handle-post' in https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/core.clj

1:57 the nested if-let in a try are just plain nasty

2:00 amalloy: brehaut: hrm. there's no obvious way to improve it

2:00 brehaut: amalloy: le sigh

2:01 amalloy: brehaut: it makes me think of cond-let, though. i wonder if that can help somehow

2:03 brehaut: hmm. someone was asking about maybe-m which did stuff on failures. clearly this is my penance for not working harder on his problem

2:03 cond-let looks interesting though

2:03 amalloy: brehaut: it is interesting, but i don't think we can apply it to this problem easily

2:04 brehaut: amalloy: agreed

2:05 amalloy: &(cond-let [[a b]] nil {a b} [1 2] (list a b))

2:05 sexpbot: java.lang.Exception: Unable to resolve symbol: cond-let in this context

2:05 amalloy: (use 'clojure.contrib.cond)

2:05 &(use 'clojure.contrib.cond)

2:05 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/cond__init.class or clojure/contrib/cond.clj on classpath:

2:05 amalloy: oh well

2:06 brehaut: (1 2)

2:06 according to my repl

2:07 amalloy: brehaut: yeah, i hoped it would be. cond-let is kinda inside-out from when-let and if-let

2:08 brehaut: im not quite sure i understand what is going on

2:09 i mean, i can kind of see whats happening, but im not quite sure how it deviates from cond

2:10 amalloy: brehaut: it gives you bindings from the test which you can use in the expr

2:11 ie, it evaluates first nil, and then [1 2]; the first one that evaluates to true it binds to [[a b]], and then evaluates the corresponding expression

2:11 brehaut: ah right now i see

2:11 clever

2:12 amalloy: brehaut: yes, it looks clever but i've never found a condition where it seems to fit. so maybe not

2:12 brehaut: amalloy: it doesnt seem to quite suit what i need

2:12 amalloy: no

2:13 brehaut: amalloy: i wonder if ideally id be best suited by a form that has pairs of expressions, first of each pair is the expression to try. if it fails (ie results in nil) then the second of the pair is evaluated and that isthe result of the expression. if i succeeds it moves on to the next pair and repeats. once there is no more pairs it returns the final result

2:14 except that it gets horrible fast

2:14 amalloy: brehaut: so you want "and-let"

2:14 replaca: brehaut: isn't that just cond with a lot of "not"s

2:14 brehaut: amalloy: that would be a good name for it

2:15 replaca: i missed a detail. the result of each successful pair is passed onto the next as an argument

2:15 lets see if i can do a hypothetical

2:16 replaca: brehaut: ok, that's different

2:17 sort of like a mash-up of cond and -?>

2:17 brehaut: -?> is new to me

2:18 (attempt [foo ({:foo {:bar 2}} :foo)] "no foo present"

2:18 [r (:bar foo)] "found foo but not bar"

2:18 r) ; => 2

2:18 amalloy: brehaut: clojure.contrib.core/-?>

2:19 brehaut: this is really looking monadic to me :(

2:19 clearly im on the wrong track if thats the case

2:20 amalloy, replaca: cheers for the -?> pointer. looks handy

2:25 is there a function to determine the available arity(s) of a fn?

2:27 amalloy: brehaut: none that i know of, but you can do it with a var, sorta

2:28 &(-> partition var meta :arglists)

2:28 sexpbot: ⟹ ([n coll] [n step coll] [n step pad coll])

2:28 _ato: brehaut: http://stackoverflow.com/questions/1696693/clojure-how-to-find-out-the-arity-of-function-at-runtime

2:28 amalloy: &(->> partition var meta :arglists first (map count))

2:28 sexpbot: java.lang.UnsupportedOperationException: count not supported on this type: Symbol

2:28 amalloy: &(->> partition var meta :arglists (map count))

2:28 sexpbot: ⟹ (2 3 4)

2:29 brehaut: amalloy _ato: cheers

2:30 amalloy: brehaut: but i'll echo the sentiments on stackoverflow: relying on this is unlikely to work well in practice

2:30 brehaut: amalloy: i was worried about that

2:30 esp seeing as the comments are that its not really workable on anon funs

2:30 amalloy: right, like i said: only for vars

2:31 brehaut: amalloy: yeah. oh well.

2:31 amalloy: well. i suppose someone could attach arglist metadata to the anonymous functions they return you, but...

2:31 _ato: IIRC you can do it with java reflection on anon fns

2:31 brehaut: yeah thats unlikely to happen!

2:31 _ato: not sure if that breaks with primitive args in 1.3 though

2:32 brehaut: _ato that might be something i put off for now

2:32 amalloy: _ato: i don't think primitives will break it, but anon functions with multiple arities would

2:33 _ato: http://groups.google.com/group/clojure/browse_thread/thread/d9953ada48068d78/1823e56ffba50dbb

2:33 see Achim's answer

2:34 amalloy: yeah, that's a good answer

2:34 "here is some clever code that does what you want. but don't use it, it's really a bad idea"

2:35 brehaut: im comfortable with just catching the exception and having really minimal autodocumentation for these handlers

2:35 cheers for all the pointers

3:54 Raynes: ping?

3:54 Raynes: brehaut: Furious pong.

3:55 brehaut: im not quite sure what to make of that!

3:55 Raynes: :p

3:55 brehaut: so as to not duplicate effort on another project, did you have any partcular blog api's you were planning to start work on ?

3:56 Raynes: brehaut: Wordpress mostly. I wanted to write a library for all of the major blogging engines, but I'm not sure how feasible that is given differences in APIs.

3:56 I need wordpress as a prerequisite for my blog editor.

3:56 brehaut: Raynes: so you are planning to consume their APIs rather than reimplement them?

3:57 Raynes: i was planning to implement both ends of pingback next just as a heads up

3:57 Raynes: The former.

3:57 brehaut: sweet as. that should mean we avoid duplicating effort

3:58 Raynes: I haven't started work on anything and didn't have any plans on doing so in the immediate future, so no duplicating going on here. <3

3:58 I've been busy on a super secret project lately.

3:59 brehaut: heh :)

4:04 AWizzArd: Will protocol fns always dispatch to the most specific type?

4:08 raek: AWizzArd: http://groups.google.com/group/clojure-dev/browse_thread/thread/fb3a0b03bf3ef8ca?pli=1

4:13 AWizzArd: raek: thx

4:20 ejackson: morning all

4:56 fbru02: Hey all , don't want to bring back the thread about primitive support, but just want to check that i understand correctly According to this : http://dev.clojure.org/display/doc/Enhanced+Primitive+Support it seems that the reason for the change was to gain ability to have primitives in fns, thus being able to do high-order stuff with primitives. Am i right ?

5:02 fliebel: morning

5:02 fbru02: fliebel: morning !

5:03 _ato: fbru02: as arguments and return values yes. You could already use primitives within a fn, but they would be boxed when passed to another fn

5:03 fbru02: _ato: thanks

5:05 fliebel: This morning I found a very good argument for the new pods, and why they should not do the lock managing thing. You know why? Because it'll be awesome to have Podrace conditions! :)

5:16 fbru02: _ato: the other day i was reading this http://tech.puredanger.com/2010/10/25/conj-parallel/ and if you look near the end it says that (after this changes) "we can leverage everything latent in the JVM" what is everything latent in the JVM?

5:16 fliebel: nice :D

5:30 Leonidas: what is the name of the function to divite a seq into two, depending on a predicate?

5:30 *divide

5:30 fliebel: split-with

5:31 Leonidas: fliebel: thanks, exactly what I was looking for

5:42 Raynes: Morning cemerick.

5:43 cemerick: morning :-)

5:43 Raynes: cemerick: Been doing much book writing lately?

5:44 cemerick: Raynes: my usual amount. I've been on the same cadence since ~October.

5:45 ejackson: cemerick: is the book going to built using Maven, like the Maven book ?

5:45 cemerick: ejackson: no, O'Reilly has its own tooling platform. I've no idea what drives it.

5:46 All the code in the book will likely be tested via maven, though.

5:46 ejackson: if you write in LaTeX, then the whole process is just like coding.... How fun :)

5:47 deployment to pdf, hahahaha

5:48 cemerick: They're very anti-latex. Non-semantic markup, etc.

5:49 ejackson: I guess they'd know. Still, it seems like a powerful toolchain.

5:51 cemerick: My impression of their impression is that it doesn't play well with others, in various ways.

5:51 e.g. if you're Knuth or writing a dissertation, it seems just fine because you can do things your way

5:51 If you're trying to keep a "house style" across 100's of books, it's just a PITA. *shrug*

5:52 I actually figured I'd have to learn latex for the book, but asciidoc is **way** simpler. :-D

5:52 Raynes: I'm using Lyx for my book. LaTeX without having to deal with LaTeX.

5:52 ejackson: In our lab we had a latex stylesheet that did exactly that. I grant that requires an in house wizard though.

5:53 Raynes: Lyx has been a joy to write with so far.

5:53 ejackson: Glad to hear it. LaTeX is marvellous.

5:54 mrBliss: Raynes: what's your book about?

5:54 fliebel: Raynes: You're writing a book? And, LaTeX is the math thing, right? You write books with that?

5:54 Raynes: mrBliss: Clojure

5:54 LaTeX is for *

5:54 ejackson: cemerick: actually, I'm suprised to hear that argument, given that all the techie journals ask for LaTeX and manage to publish in a house style.

5:54 mrBliss: Raynes: what's gonna be your focus?

5:55 ejackson: fliebel: latex is a document layout language. Its particularly good at doing maths, hence the association.

5:55 cemerick: ejackson: I'm not sure anyone else operates at O'Reilly's scale.

5:55 fliebel: okay

5:55 ejackson: cemerick: this is true :D

5:55 cemerick: In any case, insofar as their approach didn't force me to use latex, I'm happy for it. ;-)

5:55 Raynes: mrBliss: Freeness. It's licensed under a CC license and will be made freely available upon completion. It is not aimed at anybody in particular, but the book is an introductory book that expects some programming knowledge in any given language.

5:56 cemerick: I remember your editor from the Conj.

5:56 Julie Steele.

5:56 cemerick: Yup, that's her.

5:56 Raynes: One of the few women that attended.

5:56 My own book has been keeping me away from doing tech review on your book. :(

5:57 I'm paranoid that if I don't hurry with the tech review, I'll get way behind when more drafts are out.

5:57 bobo_: Someone should write a book about web devlopment or statistics in clojure. so i can read it =)

5:58 cemerick: Raynes: I think that's a fair bet. You've got to keep your own cadence. ;-)

5:58 * fliebel notes bobo_'s comment

5:58 ejackson: bobo_: an interesting idea indeed....

5:58 cemerick: bobo_: @marick is doing a book on Ring, FWIW

5:58 Raynes: mrBliss: Of course, it isn't being published by anybody, so if anybody wants printed copies, they'll have to print it themselves.

6:00 bobo_: cemerick: oh he is? awesome

6:01 mrBliss: Now that we're on the topic of books: which one should I read first "On Lisp" or "ANSI Common Lisp". Or does reading one make the other redundant?

6:03 bobo_: a mixed book with one chapter on web development, one on statistics, and other more practical things would also be nice

6:03 fbru02: bobo_: clojure in action kinda does that

6:03 Raynes: Well, I might self-publish printed copies while making the pdf free.

6:03 cemerick: bobo_: That almost perfectly describes our book, actually.

6:04 bobo_: fbru02: it does? and i thought i have read clojure in action =)

6:04 fbru02: bobo_: i thought i read it too :)

6:04 bobo_: cemerick: yours is practical clojure?

6:04 Raynes: My book is going to have a chapter devoted to creating a library and an application that uses that library. Using cake. Probably some stuff on web development and whatever else I feel like talking about.

6:04 cemerick: bobo_: no: http://cemerick.com/2010/09/10/clojure-programming-the-book/

6:05 bobo_: ah

6:05 ejackson: Raynes: thought of pre-publishing on a blog ? Would be nice for rapid iteration and feedback.

6:05 Raynes: I enjoyed Real World Haskell's chapters walking through the creation of real things.

6:06 fbru02: Raynes: i was thinking that too ! I even grabbed my copy of RWH

6:07 Raynes: ejackson: I've been giving drafts to a lot of people from different walks of life, including non-Clojure and non-Lispers. I'll probably give it to more and more as I write more. I'll probably throw the final drafts up on my blog and let people give me feedback before I totally finalize the book.

6:07 ejackson: groovy

6:07 clojurebot: Titim gan éirí ort.

6:08 ejackson: $botsnack

6:08 sexpbot: ejackson: Thanks! Om nom nom!!

6:08 ejackson: take that clojurebot ! ha

6:09 Raynes: $huggle ejackson

6:09 * sexpbot Hugglez ejackson. I lubs yous.

6:09 ejackson: oh lord

6:14 Raynes: It's surprising that I've written as much as I have so quickly. Especially given that I wrote more typos than coherent sentences.

6:14 Gigaroby: hello guys

6:16 can I ask a question ?

6:16 fliebel: Gigaroby: No!

6:16 Welll, yes of course

6:16 Gigaroby: thanks

6:16 I'm new to clojure

6:16 fliebel: And to IRC...

6:16 Gigaroby: and I'm trying to write somethink that make sense

6:16 yep both

6:16 never used

6:17 irc

6:17 what am I doing wrong btw ?

6:17 fliebel: Gigaroby: "Don't aks to ask"

6:17 Gigaroby: good

6:17 I was looking

6:17 for a function

6:18 to count how many elements are in a collection

6:18 like

6:18 fliebel: (and type a whole sentence before you hit enter)

6:18 Raynes: &(count [1 2 3 4])

6:18 sexpbot: ⟹ 4

6:18 Gigaroby: no

6:18 not that

6:18 I meant (count 1 '( 1 2 4 5 1 5 2))

6:18 fliebel: $(distinct [1 2 3 1 2])

6:18 Gigaroby: -> 2

6:19 Raynes: Oh. I see.

6:19 mrBliss: $(count (filter #{1} '( 1 2 4 5 1 5 2)))

6:19 Raynes: &(distinct [1 2 3 1 2])

6:19 sexpbot: ⟹ (1 2 3)

6:19 Raynes: Ampersand, silly.

6:19 mrBliss: &(count (filter #{1} '( 1 2 4 5 1 5 2)))

6:19 sexpbot: ⟹ 2

6:19 fliebel: The PHP I did yesterday got me I think :(

6:20 Gigaroby: ok that what I meant I just thought there was a function I didn't see

6:20 Raynes: &(group-by identity [1 2 3 4 5 1 5 2])

6:20 sexpbot: ⟹ {1 [1 1], 2 [2 2], 3 [3], 4 [4], 5 [5 5]}

6:21 Raynes: &((group-by identity [1 2 3 4 5 1 5 2]) 1)

6:21 sexpbot: ⟹ [1 1]

6:21 Raynes: Fun.

6:21 mrBliss's example is better, of course. Still, fun.

6:21 Gigaroby: yeah

6:21 good

6:21 mrBliss: Gigaroby: Clojure's count is CL's length, not CL's count.

6:21 fliebel: Poor Gigaroby, asks for one solutions, gets ten :)

6:22 Gigaroby: better than 0 anyway

6:22 thanks a lot

6:24 fliebel: &(get 1 (frequencies [ 1 2 3 1 2 3]))

6:24 sexpbot: ⟹ nil

6:24 fliebel: &(get (frequencies [ 1 2 3 1 2 3]) 1)

6:24 sexpbot: ⟹ 2

6:25 Gigaroby: a set used like a function just test the membership of the argument ?

6:25 fliebel: $huggle frequencies

6:25 * sexpbot Hugglez frequencies. I lubs yous.

6:26 Raynes: fliebel: Ah! I knew there was something I was forgetting.

6:26 mrBliss: Gigaroby: correct

6:26 Gigaroby: ok

6:26 it's weird not having all the usual loops and stuff

6:27 mrBliss: Gigaroby: What's your background? Common Lisp, Ruby, Python, Java, ...?

6:27 Gigaroby: Python and Java at most

6:27 some php

6:27 some C

6:27 fliebel: Gigaroby: Same as me :)

6:28 mrBliss: Gigaroby: I thought Common Lisp, since the 'count' you suggested, does exactly what you need in Common Lisp :-)

6:28 Gigaroby: mrBliss no just get a clojure manual on the kindle sounded like fun

6:29 infact it was btw

6:29 fliebel: &(reduce #(if (= %2 1) (inc %1) %1) 0 [1 2 3 2 3 1])

6:29 sexpbot: ⟹ 2

6:31 fliebel: &(keep (map #{1} [1 2 3 1 2 3]))

6:31 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep

6:31 mrBliss: Gigaroby: besides the good books that are currently available, http://clojuredocs.org/quickref/Clojure%20Core is very helpful

6:31 fliebel: &(keep identity (map irc://irc.freenode.net:6667/#%7B1} [1 2 3 1 2 3]))

6:31 sexpbot: java.lang.Exception: Unmatched delimiter: }

6:31 Gigaroby: mrBliss, thanks I'll have a look but when I begin a new language I like to have a manual to follow

6:32 fliebel: huh?

6:32 * fliebel actually wants to get 10 solutions.

6:33 mrBliss: fliebel: another one for your list: ##(count (remove (complement #{1}) '(1 2 3 1 2 3))) ; pretty similar to my previous solution though

6:34 sexpbot: ⟹ 2

6:36 Gigaroby: mrBliss, the first is my favourite I think

6:37 AWizzArd: &seen AWizzArd

6:37 sexpbot: java.lang.Exception: Unable to resolve symbol: seen in this context

6:37 mrBliss: Gigaroby: it's probably the most idiomatic

6:37 AWizzArd: Raynes: can you add a $seen fn to the sex bot?

6:38 Raynes: $seen AWizzArd

6:38 sexpbot: AWizzArd was last seen talking on #clojure 10 seconds and 787 milliseconds ago.

6:38 Raynes: Normal commands are prefixed with $, while code is prefixed with & for evaluation.

6:39 fliebel: &(count (nth (partition-by identity (sort [ 1 2 3 1 2 3])) 0))

6:39 sexpbot: ⟹ 2

6:43 fliebel: 5 distinct solutions so far.

7:01 http://pepijndevos.nl/6-ways-to-tell-how-many-xes-are-in-a-list

7:17 Gigaroby: how do you do != in clojure ?

7:18 Raynes: not=

7:18 &(not= 3 3)

7:18 sexpbot: ⟹ false

7:21 Gigaroby: thanks Raynes

7:29 _ato: &((fn f [[x & xs :as coll]] (cond (= coll '(1)) 1, (nil? xs) 0, :else (apply + (map #(f (take-nth 2 %)) [coll xs])))) [1 2 3 4 5 1 5 2])

7:29 sexpbot: ⟹ 2

7:30 Raynes: Holy God, I've just went blind.

7:38 _ato: &(let [s (sort [1 2 3 4 5 1 5 2])] (- (.lastIndexOf s 1) (.indexOf s 1) -1))

7:38 sexpbot: ⟹ 2

7:40 AWizzArd: Raynes: ah ok

7:41 $seen rhickey

7:41 sexpbot: rhickey was last seen quitting 2 weeks and 2 days ago.

7:41 Raynes: $seen stuarthalloway

7:41 sexpbot: stuarthalloway was last seen quitting 4 weeks ago.

7:42 Raynes: If not for chouser, I'd feel like a chick without a hen.

7:52 rsenior: I've got a -main function (invoking via lein run) and I am trying to get console input from (.readLine *in*) or (read-line) via that main function and for some reason (.readLine *in*) does not prompt for input and always just returns nil

7:52 is it possible that something else has grabbed System/in?

8:03 probably too early for an I/O question :-)

8:04 mids: rsenior: http://stackoverflow.com/questions/3790889/clojure-lein-read-line-stdin-woes

8:04 LauJensen: Morning all

8:06 fliebel: _ato: I'll add them. beautiful!

8:06 LauJensen: morning

8:06 ejackson: hey Lau

8:07 LauJensen: Hey Action Jackson

8:07 rsenior: mids: that certainly seems like my issue, thanks!

8:08 ejackson: Lau, no that's ajackson.

8:09 Raynes: LauJensen: Ohai

8:09 LauJensen: You missed the public announcement of my new book. ;>

8:09 LauJensen: I sure did - link? :)

8:10 Raynes: It isn't actually finished yet. Only been writing for just over a week. I've got a 47 page draft sitting in front of me right now.

8:10 LauJensen: Exiciting, how did you get the idea for a book ?

8:11 Raynes: Well, it's a Clojure book. Not fiction.

8:11 jk_: silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set

8:12 Raynes: LauJensen: I'd like to fill the 'free' niche that no Clojure book fills yet.

8:12 I'm licensing it under a CC license and making it freely available upon completion.

8:12 Might self-publish it and make printed copies available.

8:12 LauJensen: Interesting. What would happen if you put no license on it at all ?

8:13 Raynes: Well, there is the unlikely event that someone would take the book and put their name on it and sell it.

8:14 LauJensen: In which case you would be prepared to sue ? :)

8:14 fliebel: Hah, I found the link to the Ring book on the Google group . "This book seems intended to be about Ring specifically, rather than the more general topic of how to write Clojure web applications."

8:15 Raynes: With a fury. I'm almost ready to take the BAR.

8:16 fliebel: So, no general web dev books yet?

8:16 Raynes: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License is the license I'm licensing it under. Nice long one.

8:19 Speaking of all that: dear chouser, thank you for coauthoring The Joy of Clojure. If I didn't have that book to teach me this stuff, I wouldn't be able to write what I'm writing in the first place.

8:20 I keep it open for reference as I write.

8:20 cemerick: That's a good one. Lets others pass around the PDF, but doesn't allow others to sell copies.

8:20 IIRC, anyway.

8:20 Raynes: cemerick: That's about right.

8:21 And, people can make changes to it as long as it remains under the same license.

8:22 jk_: silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set

8:22 this document says (byte) should wrap around, but it doesn't seem to: http://faustus.webatu.com/clj-quick-ref.html

8:25 ejackson: jk_: that's true, now it throws an out of range exception

8:28 jk_: ejackson: and no function exists to return the byte equivalent?

8:29 ejackson: jk_: no idea.

8:29 jk_: ejackson: i'm trying to pack an integer value into 3 bytes and was confronted by this when i had working java code to do the same

8:30 not b64 encoding... some stupid proprietary protocol

8:30 TubeSteak: jk_: well, if it's a constant, why don't you put the signed value?

8:31 jk_: TubeSteak: sure, that's what i want to do. i want to pass an arbitrary value 0x00-0xFF and have it return the signed byte value

8:31 TubeSteak: i just thought a byte cast would do that, or that an existing function at least existed.(java byte cast does this exact thing)

8:34 i could write the function but i found it hard to believe that this functionality was lost in clojure

8:34 that's why i'm asking here :)

8:37 fliebel: LauJensen: You know about this? http://en.wikipedia.org/wiki/Language_Integrated_Query

8:37 LauJensen: fliebel: yep

8:37 Its like a poor mans version of ClojureQL :)

8:38 fliebel: LauJensen: Just what I thought… Somewhat related: Is there a data structure backend for CQL?

8:39 LauJensen: fliebel: Yes, the RTable record is effectively an AST comprised by its fields, altered by its methods

8:40 fliebel: LauJensen: I'm afraid you use to many unknown words in that sentence… A what record is effective a what?

8:41 LauJensen: fliebel: ClojureQL contains this like (defrecord RTable [....]). That record has fields like table-name, columns, predicates etc. Together they form an Abstract Syntax Tree, a datarepresentation of the query. This AST can be easily modified by the methods of the record, ie. (select tble (where (= :x 5))) etc.

8:41 Crowb4r: amalloy_: Hey, how do I give a plugin to you and Raynes for sexpbot?

8:42 jk_: LauJensen: but can you easily convert any seq or data collection in clojure to an RTable? that's what LINQ does for you, (i think, not a .net programmer)

8:42 Raynes: Crowb4r: If you have forked sexpbot on Github and added the plugin, you're welcome to issue a pull request and it will be looked at as soon as possible.

8:42 LauJensen: jk_: essentialy its a hashmap

8:44 jk_: LauJensen: all i'm saying is that LINQ has functionality that isn't already built into ClojureQL in that you can apply LINQ operations to any enumerable or sequence in .NET

8:45 LauJensen: jk_: Im not sure I follow, can you show an example ?

8:45 fliebel: LauJensen: So can I do (into (RTable) {:a 1 :b 2 :c 3}) and then do the CQL equivalent of SELECT * FROM :a , or something like that?

8:45 jk_: LauJensen: read the wikipedia article referenced... section on LINQ providers

8:45 LauJensen: Aha. That would be trivial to implement. Like (map rtable [{:a 5} {:b 5} {:c 5}]) etc

8:46 Im not sure that buys us anything in the composability department though

8:52 Crowb4r: Raynes: ok, will do. I have a couple of features my bot has that can be converted to run on sexpbot.

8:53 fliebel: LauJensen: What it buys you is that you can do relational stuff to your seqs, rather than (reduce (map)). Like NoSQL vs SQL.

8:57 LauJensen: fliebel: But you realiase that ClojureQL already lets you do relational operations right?

8:58 Gigaroby: how can I load a file into the repl ?

8:58 fliebel: LauJensen: On relational databases. What if I parse a nice XML file, can it do relational stuff to that as well?

8:58 LauJensen: fliebel: no, hence the QL

8:59 For normal relational algebra ops, you have clojure.set, for SQL backends, you have clojureql

8:59 fliebel: LauJensen: LINQ to XML offers this, but I'll have a closer look at clojure.set.

9:01 *amazed* I had no idea clojure.set contained things like join and select!

9:15 ejackson: fliebel: you didn't read Stuart Halloways book (seeing we're talking books today) !

9:16 fliebel: ejackson: Uh, no. Which one is it?

9:16 ejackson: "Programming Clojure" the first clojure book

9:27 Gigaroby: gotta problem : I was trying to execute a few lines I write and I dunno what's wrong but the compiler gives me an error on line 0. http://pastebin.com/EqBxpSEz

9:28 fliebel: Gigaroby: What error?

9:28 mrBliss: Gigaroby: the docstring give me an error

9:28 only the first line should start with a " and only the last line should end with a "

9:29 Gigaroby: mrBliss, wich first line are you talking about ?

9:29 mrBliss, you mean docstrings ?

9:29 mrBliss: Gigaroby: yes remove the last char from L10 and the first from L11

9:30 Gigaroby: mrBliss, fliebel thanks a lot

9:31 mrBliss, still same error

9:31 mrBliss: Gigaroby: I'll post a fixed version in a sec

9:31 Gigaroby: mrBliss, but I did correct the docstring

9:31 mrBliss, thanks

9:32 agentwrangler: Is it a bug or a feature that you can't send-off from within the error-handler of a failed agent?

9:32 chouser: agentwrangler: what version of Clojure?

9:32 agentwrangler: chouser: 1.2.0

9:34 Gigaroby: mrBliss, must be a lot of mess I'm sorry but that's the first I do with clojure

9:34 mrBliss: Gigaroby: http://pastebin.com/C7WjXM88

9:35 chouser: I believe it was intentional, but has been changed in 1.3-alpha4: http://dev.clojure.org/jira/browse/CLJ-390

9:35 mrBliss: Gigaroby: it's ok, I've seen much worse ;-)

9:35 Gigaroby: this compiles

9:36 agentwrangler: chouser: thanks!

9:36 Gigaroby: mrBliss, you think the style is lispy enaugh or I'm still too in imperative programming ?

9:37 mrBliss: Gigaroby: judging by this small amount of code, I think you're on the right path

9:38 Gigaroby: mrBliss, ok thanks I understood what was wrong

9:39 mrBliss, you gotta declare the functions in the order in wich you are going to use or at least with declare

9:39 mrBliss: Gigaroby: correct. Also notice the last expression (the or)

9:39 Gigaroby: In Clojure, you seldomly return false or true explicitly

9:40 Gigaroby: mrBliss, that was just style of indentation or there was an error ?

9:40 mrBliss: Gigaroby: in Lisps in general, everything that's not nil or false will be treated as 'true' in an 'if'

9:42 Gigaroby: mrBliss, good thanks

9:43 mids: Gigaroby: minor nitpick; for a predicate I'd drop the is- prefix if it already has a ? at the end

9:43 Gigaroby: mids, fair enaugh thanks

9:43 mids: so position-valid? instead of is-position-valid?

9:44 mrBliss: Gigaroby: small tip: you can replace L27 with (let [{:keys [board current-queen]} queens

9:45 Gigaroby: mrBliss, any suggestion for an IDE ?

9:46 mrBliss: Gigaroby: most Clojurians use Emacs + Slime, but I think Eclipse + counterclockwise is easier to start with

9:47 Gigaroby: mrBliss, yeah I do use eclipse for python and java as well

9:47 mrBliss: Gigaroby: http://www.assembla.com/wiki/show/clojure/Getting_Started

9:58 Gigaroby: mrBliss, counterclockwise is really good thanks for the tips now I go offline

9:58 see ya

9:58 mrBliss: Gigaroby: hope to see you again on this channel

9:58 Gigaroby: mrBliss, tomorrow for sure xD

10:08 drdozer: hi - are there any resources to get me started with genetic programming using clojure?

10:08 mrBliss: drdozer: An example: http://npcontemplation.blogspot.com/2009/01/clojure-genetic-mona-lisa-problem-in.html

10:12 drdozer: Now I'm remembering why I don't use lisp :)

10:13 thanks mrBliss for that example

10:13 I have a multi-player game coded up in scala, and need to write some bots to play it

10:15 so I'm hoping to breed functions that make sensible responses when it is time for the bot to make a move

10:15 companion_cube: wow, anonymous classes are not garbage collected ? this is ugly

10:17 chouser: companion_cube: where are you seeing that?

10:17 companion_cube: in the blog post mrBliss posted

10:18 Raynes: companion_cube: Where did that name come from, if you don't mind me asking? I am deadly curious.

10:19 companion_cube: you mean my nickname ?

10:19 Raynes: Yes.

10:19 joly: sound like Portal

10:19 companion_cube: it comes from portal, yeah :D

10:19 Raynes: I was thinking of a few games with cubes. None of them were minecraft.

10:19 joly: interesting 1st person puzzle game that I couldn't play due to motion sickness :P

10:24 chouser: joly: I can relate. Very high framerate helps, but still I often had to stop playing to recover my equilibrium.

10:24 Crowb4r: what makes sexpbot eval clojure code?

10:25 chouser: companion_cube: you see the note in there that the class GC problem has been corrected?

10:25 companion_cube: oh, i didn't see it, thanks

10:28 fliebel: Crowb4r: prefix it with an ampersand or with ##(println "this") mid-sentence.

10:28 sexpbot: ⟹ this nil

10:28 Raynes: Crowb4r: There is a Clojure plugin. clojure.clj. It uses clojail to evaluate code.

10:28 Oh. Is that what he was asking?

10:28 fliebel: I don't know...

10:29 * Raynes figured he was asking for the actual mechanism.

10:29 * fliebel thinks Raynes thinks to complicated.

10:29 Raynes: ;)

10:29 fliebel: Crowb4r: Enlighten us, what did you want to know?

10:30 Crowb4r: I was asking the keyword to kick it off

10:31 before opening up the src code to look at the trigger

10:31 like ',' is clojurebot

10:31 eckroth: If I defn a multiple-arity fn, I cannot :use it in another ns; why is that (or am I mistaken)?

10:31 joly: &(println "test")

10:31 sexpbot: ⟹ test nil

10:31 Crowb4r: got ya

10:32 Raynes: also where are the dynamic.clj and status.clj files I had to take them out of plugins to load because it could not find the files and I don't see them on github anyplace.

10:33 Raynes: Crowb4r: Eh, those were deleted a few weeks ago. I forgot to remove the references to them from the default configuration.

10:34 Just remove them from the plugin lists in your config. Sorry for that. I'll push a commit to remove them in a moment.

10:34 Crowb4r: Raynes: kk, umm another question anything specdial I have to do besides have mongo db just run in and be connectable (using ubuntu 10.10)?

10:35 or is ther ea config I'm missing

10:35 this is fresh from apt in this vm

10:36 Raynes: Right. You should just be able to start it up and run. If the apt installation configures it to use a non-standard default port, it might not work though.

10:37 Crowb4r: Raynes: because I get this error when I send him a message in an irc server http://pastebin.com/yVxfNSeH

10:37 Raynes: Right, that means he isn't seeing mongo. Make sure that it is being run on port 27017

10:37 I don't think I've made that configurable yet.

10:37 Crowb4r: Raynes: ok thanks

10:37 will look

10:38 thanks for all the help

10:38 cemerick: fliebel: a couchdb "external handler"?

10:38 Raynes: Crowb4r: Also, we have a channel for sexpbot and related projects: #sexpbot

10:38 Crowb4r: Raynes: alright, I will squat in that one as well, thanks

10:38 Raynes: If you don't mind, please join there for further discussion/questions.

10:38 :)

10:38 Crowb4r: done

11:02 joly: &(macroexpand-1 (binding [test 5] (println test)))

11:02 sexpbot: ⟹ 5 nil

11:02 joly: &(doc binding)

11:02 sexpbot: ⟹ "Macro ([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made i... http://gist.github.com/751681

11:02 fliebel: &(macroexpand-1 '(binding [test 5] (println test)))

11:02 sexpbot: ⟹ (let* [] (clojure.core/push-thread-bindings (clojure.core/hash-map (var test) 5)) (try (println test) (finally (clojure.core/pop-thread-bindings))))

11:02 joly: ah, thanks

11:06 I'm looking at some scheme code that uses make-parameter and parameterize. Would binding be a good way to translate that in general?

11:10 chouser: joly: After reading a couple paragraphs of related scheme docs, I think so.

11:11 though clojure's use of lazy seqs can sometimes lead to surprising results with 'binding'

11:13 because of that, how they interact with multiple threads, and how it leads to non-pure functions, many people avoid using 'binding' as much as possible in Clojure.

11:28 joly: chouser: thanks, I'll keep an eye out trouble. I shouldn't be dealing with lazy seqs or multiple threads here, but I'll be on my guard

11:28 for trouble*

11:32 kurtharriger: where does one find foldr foldl do these functions not already exist?

11:33 chouser: reduce is one of them, though I forget which

11:34 foldl I think

11:34 joly: reduce should be foldl

11:34 chouser: foldr is rarely needed and not provided by clojure core, afaik.

11:34 kurtharriger: k

11:35 reduce works thanks

11:36 chouser: I think foldr would be something like (reduce #(f %2 %1) (reverse coll))

11:36 tonyl: morning

11:36 Dranik: for what projects do you guys use clojure?

11:37 chouser: eeeeevvvvrrrryyyytttthhhiiinnnngggggg

11:37 ;-)

11:37 Dranik: chouser, for example?

11:38 fbru02_: Dranik: what's on your mind , and i will tell u if clojure is a good fit ! :)

11:38 Dranik: fbru02_, well, I'm trying to determin which projects clojure fits best comparing to java

11:39 fbru02_: comparing to java?

11:39 Dranik: yep

11:39 fbru02_: if you are thinking of doing sth in java , do it in clojure, you will be happier

11:40 Dranik: fbru02_, well, its a bit complex to do j2ee with pure clojure

11:40 chouser: the most common good reason I run into for not using Clojure is because the JVM is unavailable or a poor fit

11:41 Dranik: chouser, like in Android, for instance?

11:41 fbru02_: i agree with chouser, and i would add web-dev is somehow easier in rails for me because i have experience with that

11:41 chouser: Dranik: well, some people are doing even that. I meant like in the web browser, or for quick-startup at the command line.

11:41 fbru02_: but other than that , clojure for most of the stuff

11:42 Dranik: fbru02_, that's why I've said "comparing to java", bcs web-development with rails3 is really much easier :-)

11:42 chouser, could you give any examples?

11:43 fbru02_: we are doing a web app hallf in rails and half in clojure , with zeromq and works great

11:43 chouser: Dranik: examples of things I've used Clojure for?

11:43 Dranik: fbru02_, so why did you choose clojure with rails, not pure rails?

11:44 chouser, yep

11:45 fbru02_: i was doing provisioning but wanting to do it concurrently and used pallet for that, hugod does a great job and i much prefer it over the ruby solutions

11:45 chouser: scraping web pages, web apps, web apis, mongo abstraction layer, protobuf library, data structure experimentation

11:45 I'm sure I'm forgetting things

11:46 fractal applets, custom RPC protocol

11:46 Dranik: chouser, ok, thanks :-)

11:46 chouser: swing gui

11:47 Dranik: chouser, btw, is any of your clojure code available anywhere? or maybe you coud share some?

11:47 fbru02_: Dranik: many people are using clojure in the bigdata niche

11:47 Dranik: I just try to lear clojure

11:47 chouser: Dranik: I have a bunch in contrib and on github

11:48 Dranik: fbru02_, yep, I see. Clojure is really good at concurrent programming

11:48 replaca: chouser: didn't you write some kind of book filled with great examples? :)

11:48 chouser: oh, right, IRC log to web site converter.

11:49 replaca: yeah, it's a great language to use for examples in a Clojure book!

11:49 tonyl: brehaut: ping

11:49 Dranik: chouser, could you please share some links and the book?

11:50 I've just searched through github and there are really many links with "chouser" strings there... so I've got lost

11:50 chouser: Dranik: http://joyofclojure.com/ FETCH parties IS demo.parties

11:50 FOR party IN parties

11:50 HAVING party.name = \"Old Timers\"

11:51 doh

11:51 sorry

11:52 Dranik: http://joyofclojure.com/ http://tinyurl.com/fingertree https://github.com/Chouser/textjure https://github.com/Chouser/data-munge https://github.com/Chouser/clojure-irc-log https://github.com/Chouser/clojure-jna https://github.com/Chouser/clojure-classes

11:52 Dranik: chouser, thanks a lot!

11:53 fbru02_: into-array converts a seq into an array, is there a way to make a seq from an array ?

11:53 chouser: Dranik: contrib is full of interesting and primarily high-quality code, too

11:53 replaca: chouser: hey, do you know when we're going to see the dead-tree version of JoC?

11:53 chouser: fbru02_: seq

11:53 replaca: soon. Maybe January?

11:53 fbru02_: chouser: don't know why i didn't try that :D

11:54 chouser: :-)

11:54 replaca: chouser: excellent! Can't wait to have it on my shelf. Really nice discussion of records, types, and protocols there by the way

11:54 (among other things)

11:55 fbru02_: yeah i thought it was coll -> seq , didn't know it worked with java arrays

11:55 chouser: replaca: thanks!

11:55 Dranik: chouser, clojure-jna -- wow! that's great!

11:55 replaca: fbru02_: seq is the (almost) universal magic function

11:55 fbru02_: thanks !

11:56 chouser: fbru02_: also strings, iterators, etc.

11:56 Dranik: there is a much more industrial-strength lib out there if clojure-jna's features are too thin for you: clj-native

11:58 Dranik: chouser, yep, I'll give it a try!

12:14 Raynes: chouser: You're fairly performance savvy, aren't you?

12:15 * chouser shrugs

12:15 Raynes: I'm curious as to what would be the absolute dirtiest, rawest, fastest way to write this in Clojure: https://gist.github.com/c1b5a16b6ea582ef85ba

12:15 chouser: Raynes: s is always a string?

12:15 Raynes: The idea is to just count the number of non-space characters in a string.

12:15 I want the fastest possible thing I can get without using Java.

12:16 chouser: and this is on 1.3-alpha-something?

12:16 Raynes: 1.2.0, but I'd be interested in 1.3-alpha versions as well if they make an important difference.

12:17 chouser: it makes a difference in the code, not the potential speed, I think.

12:18 Raynes: I'm trying to see how close I can get to some Java algorithms I've seen.

12:21 I've wrote a version using loop, but it leaves much to be desired at an average of 138168.371 to run on a 460 character string 1000 times.

12:21 The fastest Java solution I saw ran at just under 3000 nanoseconds.

12:22 chouser: hm, I'm not sure how to do primitive char equality

12:23 amatos: In clojure.test what is the equivalent of JUnit's assertEquals(double, double, delta)? Basically comparing doubles but passing a small delta because doubles are never exact?

12:27 chouser: Raynes: I think the problem might be that char comparison. I can't think of a way to check the equality of chars without autoboxing them.

12:28 Raynes: :\

12:29 chouser: hmm...

12:32 (defn count-num-chars [^String s] (let [len (.length s), space (int 32)] (loop [i (int 0), c (int 0)] (if (< i len) (recur (inc i) (if (== (.codePointAt s i) space) c (inc c))) c))))

12:33 I've done no profiling of that, but it ought to produce bytecode that deals only with primitives and does no reflection

12:33 Raynes: chouser: Runs slower than my loop version.

12:33 chouser: noooo

12:33 Raynes: Marginally. :p

12:33 chouser: good thing I shrugged in the first place. :-)

12:33 what's yours?

12:34 Raynes: https://gist.github.com/51073bc37369fcda9368

12:34 Nothing special at all, actually.

12:35 I wrote an example with reduce that runs around the same time as yours does.

12:35 chouser: hm, I must have missed something in mine then.

12:35 Raynes: More eye watering code? :p

12:35 chouser: oh

12:35 #^String

12:36 you probably caught that already?

12:36 Raynes: Nope, did the same thing in my example as well.

12:36 Doesn't seem to make a difference though.

12:37 chouser: hm, I guess 1.2 already supported ^ for tagging

12:37 Raynes: I thought so. I was already googling to make sure.

12:38 chouser: I suppose .codePointAt might be slow

12:39 performance questions might do better on the google group

12:40 Raynes: I'm not sure I care enough to bother the group with it.

12:40 It's a trivial example that I was just obsessing over.

12:40 chouser: I bet there are people on the group who would enjoy it.

12:41 Raynes: You have a point. I guess I'll go ahead and post it and see what I can get.

12:41 Thanks for trying. <3

12:41 chouser: :-) sorry I didn't help

12:42 Raynes: Well, you did help. It was a demonstration that "Hey, even though I'm obviously much smarter than you, even I could come up with a speedy example."

12:42 (inc ego)

12:42 sexpbot: ⟹ 1

12:43 chouser: Raynes: are you using a profiler?

12:44 Raynes: No. Just a bit of code that checks the current nanotime, runs the code 1000 times, and then checks the nanotime again.

12:44 amalloy: Raynes: wouldn't it be faster to convert the string to a byte[] first?

12:45 Raynes: amalloy: If you think you can implement it faster, go for it. I'm interested in all sorts of fun ideas. :>

12:47 gtrak: (inc nil)

12:47 sexpbot: ⟹ 1

12:48 gtrak: (nil)

12:50 clizzin_: is there a way to take a sequence of lazy sequences and make one lazy sequence that iterates through each of the elements of those lazy sequences in turn? basically, i'd like to (apply lazy-cat foo) where foo is a sequence of lazy sequences, but unfortunately i can't apply a macro.

12:51 chouser: (apply concat foo) should do what I you want, I believe.

12:52 amalloy: clizzin_: or mapcat before you get those lazy sequences: ##(mapcat range [5 6])

12:52 sexpbot: ⟹ (0 1 2 3 4 0 1 2 3 4 5)

12:52 chouser: the only what that lazy-cat is more lazy than concat is that because concat is a function, it's arguments will normally all be evaluated first.

12:52 but apply itself is lazy, so you should be ok

12:53 clizzin_: amalloy, chouser: great info, thanks!

13:09 Raynes: chouser: Switching to using unchecked-inc in your version gives me an extreme speed increase.

13:09 rayne@ubuntu:~$ cake run ~/challenge.clj

13:09 Chars outputted: 460

13:09 Time (in nanoseconds): 5711.932

13:10 tomoj: (.start (Thread. (fn [] (loop [] (.read stream (byte-array (.available stream))) ()))))

13:10 that makes no sense, right?

13:13 the loop form can be removed, and the empty list at the end as well if the return value is ignored? (.start (Thread. (fn [] (.read stream (byte-array (.available stream)))))) ?

13:13 Raynes: chouser: I also changed .codePointAt to be (int (.charAt ..)), because .codePointAt was a huge bottleneck.

13:17 clizzin_: hmm so the behaviour i was attempting to achieve is to create a lazy sequence on top of a sequence of readers. so i have a function (defn datum-seq [filenames] (mapcat (comp line-seq clojure.java.io/reader) filenames)). and then i have a function foo that iterates through a sequence and updates a transient map as it goes. my hope was to have the iteration through lines in the files be such that it discards files (or even b

13:17 lines) from memory as soon as it's done with them, but i'm seeing linear growth in memory as foo iterates through the sequence that suggests that the file contents are being cached. anyone have any ideas on how i can achieve the behaviour i'm looking for? thanks in advance!

13:23 amalloy: clizzin_: garbage collection only runs when it's needed. if you have enough memory to keep it all cached, the gc won't bother cleaning it up even if clojure has thrown away all references to the earlier stuff

13:24 technomancy: clizzin_: you need to use with-open for readers; this doesn't play nicely with laziness.

13:25 amalloy: clizzin_: see http://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx for an interesting take on this, even if it is from a CLR perspective

13:28 clizzin: amalloy, technomancy: hmmm. ideally, i'd like to create a sequence abstraction over all the lines of these files so that foo can take any sequence of data as input. it sounds like this isn't possible without manually opening/closing each file as the iteration starts/finishes with that file's lines, but how can i have the resulting function be treated as a sequence? i come from a python background, so the best way i can expl

13:28 what i'm trying to achieve is the equivalent of a python generator.

13:28 also feel free to let me know if i'm thinking about this all wrong

13:30 my main concern is that i can't hold all of the data in these files in memory at once, so i thought making a lazy sequence on top of the readers would avoid caching the contents of multiple files at once.

13:52 leif-p: Hi, all. Is there a clojure json lib that accepts all legal json? c.c.json/read-json seems to take only a subset.

13:52 Raynes: $google clj-json

13:52 sexpbot: First out of 459 results is: mmcgrana/clj-json - GitHub

13:52 https://github.com/mmcgrana/clj-json

13:52 Raynes: That probably does.

13:53 It wraps a Java JSON lib though, so it isn't a pure Clojure implementation.

13:53 * Raynes goes to sleep.

13:55 chouser: clizzin: having a lazy seq close an underlying resource (like a file) when it is fully consumed is generally considered fragile, because of how often lazy seqs in general are abandoned before being fully consumed.

13:56 clizzin: but in your case, it may be less objectionable since you should be able to guarantee that no more than one file is open at a time.

14:03 raek: leif-p: what does it not accept?

14:07 technomancy: apparently clj-time has not released any stable versions; what's up with that? ಠ_ಠ

14:08 leif-p: raek: maps with numeric keys. Hmm... I'm just assuming that's legal json, let me check. And while it technically accepts maps with any string keys, the fact that it automatically converts them all to keywords means the result is hard to use if any of the keys contain clojure special characters.

14:10 raek: the awesome syntax diagram of http://json.org/ suggests that it isn't allowed to have numbers as keys in json

14:11 leif-p: you can turn off the keywordization of you like

14:12 or you can construct keywords from strings ##(keyword "\u2603")

14:12 sexpbot: ⟹ :☃

14:13 raek: (unicode snowman)

14:14 but yeah, keywordization is perhaps not always a good idea

14:14 ,(doc read-json)

14:14 clojurebot: Gabh mo leithscéal?

14:14 raek: &(doc read-json)

14:14 sexpbot: java.lang.Exception: Unable to resolve var: read-json in this context

14:15 raek: &(use clojure.contrib.json)

14:15 sexpbot: java.lang.ClassNotFoundException: clojure.contrib.json

14:17 leif-p: raek: You're right, I am looking at that right now. I guess I am using json wrong. Unfortunately, when almost all json libraries dump to string, they fix my mistake, and js might be doing some str->num magic. :(

14:22 dnm: technomancy: Hey there.

14:23 technomancy: Quick question. Are you still in Seattle? I happened to be perusing the careers section of the Sonian website, and it seems all the open positions are in Boston. Is there still a telecommute option available for certain roles?

14:29 technomancy: dnm: all our engineering roles are telecommute, but I'm not sure if we are actively looking for Clojure hackers right now. I'll ask.

14:34 dnm: technomancy: Ah, I see. Thanks for asking! It happened to be an interesting conincidence, as I was just mentioning elsewhere (#dylan) that I missed Boston and would consider moving there second to moving to Seattle, but didn't know what I would do in Boston. And last I knew, you, anyway, were in Seattle with Sonian. I didn't know they were Boston-based.

14:35 technomancy: we hire wherever there's talent

14:35 * dnm nods

14:36 technomancy: I'm in Seattle, but I work with people all over the place.

14:36 are you in Seattle?

14:37 dnm: No. Currently I'm in the D.C. area.

14:37 But I have plans to move to Seattle.

14:37 technomancy: it's great; I love it

14:38 see also http://seajure.technomancy.us of course

14:38 dnm: Is the picture of the bench that showed up on Fogus's interview of you from Green Lake?

14:38 Or elsewhere?

14:38 fogus`: dnm: Have you been out to any of the NOVA Clojure meetups?

14:39 dnm: fogus`: Sadly no, they're all out in Reston, and I am never out that far. I live carless in Arlington, and I work in downtown D.C. during the day.

14:39 fogus`: Would like to meet up with local Clojure hackers though.

14:40 technomancy: dnm: that's a park across the street from my house, but I love working from the shores of Green Lake in the summer =)

14:40 dnm: http://www.flickr.com/photos/technomancy/4798518932/

14:40 fogus`: dnm: People are usually willing to do drop/pick at local metro stations

14:40 dnm: technomancy: Intensely envious. ;] Looking at apartments on padmapper.com, it seems I can find a place in Seattle or surrounding areas for less than I pay here, which seems like a win/win!

14:41 technomancy: dnm: my remoteoffice flickr feed is a covert Sonian recruitment mechanism.

14:41 not as effective in the Winter though =(

14:41 dnm: fogus`: Yeah, which is very nice of them. Usually they also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending.

14:41 s/they/the meetups/

14:41 sexpbot: <dnm> fogus`: Yeah, which is very nice of them. Usually the meetups also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending.

14:42 dnm: fogus`: One of these days, maybe. Do you know of any Arlington or D.C. proper Clojure hackers? I'd love to do something even less formal than a capital-M meetup.

14:42 fogus`: dnm: Too bad. If the time is ever not a factor then ping the meetup page. I'm certain someone will volunteer as chauffeur. ;-)

14:43 dnm: Surprisingly DC/VA/MD seems to be a hotbed of Lispiness

14:43 chouser: Fort Wayne too

14:43 dnm: technomancy: Seattle's great attraction for me is to escape humid Virginia summers.

14:43 chouser: in my dreams

14:44 dnm: technomancy: Well, one of the great attractions anyway.

14:44 fogus`: The author of Land of Lisp lives in DC and he used to run the DC Fringe group. He might (hoping) restart those meetups again

14:44 chouser: in reality, Fort Wayne is a hotbed of military radio engineering.

14:44 dnm: Conrad, yeah! I know Conrad. FringeDC's been kinda dormant for a while.

14:44 Crowb4r: Fort Wayne IN?

14:45 chouser: yessir

14:45 dnm: The last FringeDC meeting I went to was a talk on ML from a then-local company making their product in it. That was a few years back.

14:45 Crowb4r: chouser: heh, I'm not that far from you then

14:46 <- Western Michigan

14:48 chouser: Crowb4r: cool

14:49 I keep meaning to go to one of the ohio clojure meetups

14:49 Crowb4r: far in perspective to some I suppose..

14:49 chouser: Crowb4r: this is the midwest. < 4 hours drive is close

14:49 Crowb4r: I should drive down for that. there is a Detroit group that just started. I need to look at Chicago as well.

14:49 chouser: in Europe that might require a passport, but here it's just "going in to town"

14:50 Crowb4r: yeah

14:50 chouser: Crowb4r: I talked at the Chicago one once -- nice folks. But it takes too long to do regularly

14:50 Crowb4r: I'm in Holland, right on Lake Michigan so pretty much I can only go east or south for 4 hours to hit anything (but Grand Rapids)

14:51 pjstadig: dnm: i'm also in the DC area, and i work for Sonian

14:51 dnm: pjstadig: Hi there!

14:52 * dnm hits send on an email to Zach Tellman.

14:57 dnm: fogus`: Are you in the area?

14:58 fogus`: dnm: Indeed

14:59 dnm: fogus`: Ah, neat!

15:01 pjstadig: fogus` has presented at the clojure group several times

15:01 * fogus` got snowed out of his last talk

15:11 brehaut: morning

15:30 AWizzArd: brehaut: good evening brehaut

15:30 brehaut: AWizzArd: clearly i forgot my timezone again

15:30 AWizzArd: 21:32 in Germany

15:31 brehaut: 09:32 in new zealand

15:31 AWizzArd: So, middle Earth is on the other side of the world :)

15:31 brehaut: yup :)

15:32 dnm: brehaut: Where are you in NZ?

15:33 brehaut: dnm hamilton

15:33 AWizzArd: How far away is that from Hobbingen?

15:33 dnm: Ah. I converse regularly with a Dylan developer in Wellington.

15:33 brehaut: AWizzArd: maybe half an hour

15:33 dnm: there are still dylan developers?!

15:34 dnm: Yes. We're a rare breed, I guess ;]

15:34 brehaut: dnm: i guess. pretty cool though

15:34 dnm: Not only that, there's another Dylan developer who uses Clojure regularly.

15:35 brehaut: i guess if you are going to use one relatively unknown language, why not use 2

15:35 dnm: Heh.

15:41 brehaut: fogus`: ping?

15:44 fogus`: pong

15:45 brehaut: fogus`: i tried to tweet a bug report at you but twitter is doing weird nonsense. anyway, xml-> is getting rendered as xml-&gt; while -> is still ->

15:47 fogus`: brehaut: Thanks will look into that

15:47 brehaut: fogus`: ive also got a curious case where marginalia is thinking that the body of a condp is code to output verbatim in the doc side of the uberdoc

15:48 fogus`: brehaut: Do you mind creating a case at https://github.com/fogus/marginalia/issues with a link to the code you're trying to operate on?

15:48 brehaut: sure thing

15:48 fogus`: Thank you!

15:48 brehaut: not a problem

15:57 fogus`: https://github.com/fogus/marginalia/issues/#issue/4

16:04 fogus`: brehaut: The dangers of regex! Thanks again. Gotta run, but it should be fixed some time today

16:04 brehaut: fogus`: not a problem. cheers

16:43 (inc tonyl)

16:43 sexpbot: ⟹ 1

17:19 raek: oh, java... http://www.youtube.com/watch?v=wDN_EYUvUq0

17:19 interesting though...

17:30 &(= (.hashCode "polygenelubricants") (Integer/MIN_VALUE))

17:30 sexpbot: ⟹ true

17:31 brehaut: raek: what the?!

17:32 raek: (see the video...)

17:32 also:

17:32 (Math/abs (Integer/MIN_VALUE))

17:32 &(Math/abs (Integer/MIN_VALUE))

17:32 sexpbot: ⟹ -2147483648

17:32 brehaut: i havent, my internet connections incredibly lame today

17:32 raek: hrm

17:34 ah, Raynes's long decorative arrow hid the minus sign...

17:34 so, yupp. the abs function can return a negative value

17:35 brehaut: so strange

17:35 raek: since there are one more negative Integer than positive

17:36 brehaut: ah true

17:36 raek: hrm, why did using that static field as a method work?

17:36 &(Math/abs Integer/MIN_VALUE)

17:36 sexpbot: ⟹ -2147483648

17:37 raek: &(Integer/MIN_VALUE)

17:37 sexpbot: ⟹ -2147483648

18:08 joshua__: amalloy, the plugin is pretty much done =) XML worked wonderfully. The only thing that needs to be fixed at the moment is this really dumb bug. Basically there is a file where you specifcy what amounts to a config page and even though I changed that file it is still compiling as if I had not changed it.. anyways that is not why I came here..

18:08 Trying to connect to mongodb is giving me a network exception error.

18:09 Any idea where the problem might be?

18:09 amalloy: joshua__: $ sudo mongod, is what usually fixes it for me

18:09 ISTR i fixed something in my etc/init.d or thereabouts to get this to stop happening, let me see if i can find it

18:10 joshua__: Wed Dec 22 15:10:50 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating

18:10 That doesn't look right..

18:12 It is actually happening in my command line too.

18:12 Not just when I start up swank

18:12 amalloy: joshua__: are you root? permission-denied errors often look like not-found errors to java

18:12 this is to start the server, not to connect to it

18:12 joshua__: amalloy, I didn't grok what you said?

18:13 oh

18:13 yea I rank sudo mongod

18:43 zkim: Is there any way to clone a java class in clojure? I'd like to muck with a static member on a class (specifically c.l.LispReader), but I don't want to interfere with the operation of other consumers.

19:19 programble: um

19:20 cake isn't working

19:20 i run it and after a while it says it's taking long to connect to the JVM, but it never starts a JVM

19:21 ninjudd: programble: i need more information than that. which version are you using? how did you install it? etc...

19:22 programble: 0.5.8 from gem

19:23 oh it works if i'm not in a project dir...

19:23 but fails in my clone of penumbra

19:23 ninjudd: programble: ah

19:23 you have to upgrade to the latest cake to use penumbra

19:24 i just fixed that yesterday actually

19:24 use the "Git repository" installation method from https://github.com/ninjudd/cake

19:25 lancepantz was working on adding cake tasks for the penumbra examples actually

19:26 lancepantz: jees, i can't tell if it's penumbra or cake gaining in popularity :)

19:27 programble: but yeah, i have some commits i'm queueing up for https://github.com/lancepantz/penumbra i'll push later today

19:27 ninjudd: programble: you're the second person to ask about using penumbra with cake in the past two days. and nobody ever asked before that

19:27 programble: well i'm just looking at penumbra cuz i'm bored

19:29 ninjudd: that explains it!

19:29 programble: and i'm using cake because it is apparently "oh so much" better than lein

19:29 guys

19:29 on every run of cake i get this:

19:29 $ cake

19:29 which: invalid option -- 's'

19:30 /usr/bin/wget

19:30 ninjudd: doh

19:30 that's from a commit i just added. i guess that is an os x only opt

19:30 fixing

19:31 programble: fixed


19:32 ninjudd: hahah

19:32 did you start it with cake?

19:32 programble: i started it from a cake repl

19:32 ninjudd: you exited the repl?

19:32 'cake kill' will work

19:33 on os x, clicked the 'x' on the window works too

19:33 programble: it doesn't get a window border here

19:33 ninjudd: oh no

19:34 ctrl-c in the repl

19:34 * programble reads the pong source and gets a headache

19:34 ninjudd: if it is still running after that, 'cake kill'

19:35 programble: do not understand opengl at all

19:40 clizzin: if i pass a lazy sequence as an argument to a function that uses it only for the first instruction, do all the realised members of the lazy sequence stay in memory until the function exits? or is the sequence garbage collected after the last use of it?

19:41 technomancy: clizzin: as long as you're on 1.2 or newer, you're clear after the last use.

19:42 "fine-grained locals-clearing", in the vernacular

19:43 clizzin: technomancy: cool, thanks for the information. is there any way to tell the lazy seq not to bother caching realised members?

19:43 i've got a case where the cost of computing the sequence members is cheap but there are a whole lot of them, so i don't want them to be cached in memory

19:43 technomancy: clizzin: no, you have to ensure references to the head are GC'd

19:46 clizzin: technomancy: hmm okay. what is the behaviour of a lazy sequence if iterated over using loop? are the members still cached?, e.g. (loop [i (lazy-seq foo)] ...)?

19:47 technomancy: clizzin: depends. if you recur on (rest i) you're probably clear.

19:48 you can construct a test with an infinite seq to be sure

19:51 clizzin: technomancy: interesting. so my situation is that i'm doing (foo (lazy-seq...)) where foo is (defn foo [s] (bar s)) and bar is (defn bar [s] (loop [sequence s] ... (recur (rest s))). it sounds like keeping things decomposed into separate functions like this would result in all the members of the lazy sequence getting cached because the foo and bar scopes retain references to the head.

19:51 so now i'm tempted to mash them all into one big function so that the lazy sequence is passed directly into the loop.

19:52 or is clojure smart enough to figure out that this chain of calls ends with a loop that recurs on (rest s)?

19:53 mabes: how could I tell if a certain deftype/defrecord implements a fn.. you can use satisfies? to see if it "implements" the protocol, but I've noticed that def[record|type] does not enforce a method be defined for each signature

19:53 technomancy: clizzin: I suspect it will be smart enough, but you will need to confirm this with Science.

19:53 clizzin: technomancy: Science!

19:53 technomancy: clizzin: http://www.topatoco.com/merchant.mvc?Screen=PROD&Store_Code=TO&Product_Code=DC-BISCUIT&Category_Code=DC

19:53 mabes: I know you can look at the protocol and that the methods should live on it somewhere, but I'm having a hard time finding them

19:53 clizzin: alright, time to give it a shot. thanks for the help!

19:54 technomancy: haha nice

19:54 technomancy: np

19:59 joshua__: Is there a way to tell congomongo to declare an index on a key?

19:59 declare/create

20:00 or do I need to do that within mongodb itself

20:05 mids: joshua__: add-index!

20:07 joshua__: thanks!

20:15 mids, any idea where I can get more thorough documentation of congomongo?

20:22 Best I've seen: http://clojuredocs.org/incanter/1.2.3-SNAPSHOT/incanter.mongodb

20:35 Where can I find info on query maps for mongodb?

20:59 arohner: does anyone have any good tricks for figuring out what part of performance problems are caused by cache misses?

21:33 datka: Are multimethods supposed to hold on to their dispatch fn, or is it possible to change that function dynamically. I made a change to my dispatch fn, and it wasn't picked up. (1.3)

21:33 amalloy: datka: i don't know what is "supposed" to happen, but that is the behavior in 1.2 also

21:34 datka: it's probably by design and for performance reasons, but it's a bit annoying

21:34 amalloy: agreed

21:39 pdk: oh snap is 1.3 out

21:40 tomoj: I don't see it

21:40 joshua__: (GET "/item?id=:id" [id] (archive-item id)) Why is this not matching /item?id=2312312?

21:41 datka: I'm jumping the gun on upgrading to 1.3, it's not out yet. (unless I missed something)

21:44 joshua__: To answer my own question the ?id is being treated as a get parameter.

22:01 brehaut: anyone here know much about moustache ?

22:05 bhenry: brehaut: depends on how much

22:05 brehaut: bhenry: how easy is it to use moustache's pattern matcher outside of moustache

22:06 bhenry: brehaut: uhh. i've only ever used it the standard way. what are you trying to do?

22:06 brehaut: bhenry: minimise the amount of repetition in a pingback implementation

22:07 bhenry: pingback is xml-rpc which means it tunnels through http and then dispatches itself based on the method not the resource

22:07 but pingback also has to check that the resource being pinged back exists

22:09 bhenry: brehaut: well i guess i'm not the man for this, but moustache is only one file, so you should take a look at it. https://github.com/cgrand/moustache/blob/master/src/net/cgrand/moustache.clj

22:09 brehaut: bhenry: that was my next step.

22:13 judging by the number of private functiosn that i think i would need, i might be screwed

Logging service provided by n01se.net