#clojure log - Apr 19 2011

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

0:17 choffstein: anyone know why I might be getting this error: java.lang.Exception: Unable to find static field: parseDouble in class java.lang.Double

0:17 seems ... strange

0:17 amalloy: you're trying to call parseDouble with no arguments, and the compiler's best guess is that maybe it's a field

0:18 &(Double/parseDouble)

0:18 sexpbot: java.lang.NoSuchFieldException: parseDouble

0:18 amalloy: &(. Double (parseDouble))

0:18 sexpbot: java.lang.IllegalArgumentException: No matching method: parseDouble

0:18 choffstein: Ah. So I can't do something like map Double/parseDouble

0:19 amalloy: ^ is how you could force it to act like a method, if there actually were a no-arg version

0:19 choffstein: but should do map #(Double/parseDouble %)

0:19 amalloy: choffstein: no. methods are not first-class functions; they require wrappers

0:19 exactly

0:19 choffstein: thanks :)

0:29 tomoj: beautification tips? https://gist.github.com/5b709e90dbb330d1fb62

0:29 amalloy: whee i love this kind of assignment

0:29 * amalloy looks

0:30 tomoj: the idea is to go through each x in s until you get the same (f x) n times

0:30 then return any such x (my implementation returns the first iirc)

0:30 amalloy: tomoj: seems like you should use partition-by

0:31 tomoj: aha

0:31 then (first (filter #(= (count %) n) ...)) ?

0:31 amalloy: right

0:31 well

0:31 tomoj: shoot

0:31 amalloy: >, not =

0:31 tomoj: d'oh

0:31 thanks!

0:32 I don't even understand that nasty stuff I wrote

0:33 gist updated, beautification achieved

0:34 except, oshit, ffirst

0:34 I don't think I've ever used any of those

0:34 amalloy: tomoj: i know, i was excited to suggest ffirst

0:34 but then you went and took the fucking idea before i could finish typing it

0:34 tomoj: wait

0:34 this doesn't work, though

0:35 I remember considering some function and giving up for this problem, but I don't think it was partition-by

0:35 amalloy: tomoj: you have your <= written backward, i think. happens to me all the damn time

0:35 tomoj: problem is the seq might be infinite

0:35 amalloy: so?

0:36 tomoj: partition-by chokes on (repeat 1)

0:36 amalloy: partition-by is lazy, isn't it?

0:36 oh, i see

0:36 tomoj: lazy in partitions, not in each partition

0:36 amalloy: if a given partition is infinite, yes

0:37 tomoj: the real point is to approximately find the value (iterate f other-s) converges on

0:37 if n is big enough the last partition actually will be infinite because you really will have found the convergence

0:38 amalloy: tomoj: perhaps (map f the-collection), then (partition n 1) to get it into chunks of the right size

0:38 tomoj: oh, but I think can just use the ugly trick in my first version with this one?

0:38 amalloy: then you can check each chunk to see if they're identical

0:38 tomoj: i didn't even read the first version :P

0:39 tomoj: nope, doesn't work :(

0:39 my ugly trick I mean

0:40 (partition n 1) sounds prettier than what I've got but intuitively much slower

0:40 since I said that I guess I have to test it

0:41 amalloy: certainly if your data is AAABBBAAABBBAAAA and N is 4 it won't be that great

0:41 but it seems like a pretty small difference

0:43 tomoj: hmm, tried something like that, but it returns (f x) instead of x

0:43 amalloy: tomoj: (map (juxt identity f) ...)

0:44 * amalloy loves (juxt identity f g h) so much he's made another function for it

0:45 tomoj: eww https://gist.github.com/d37cc1b6a4855cce3581

0:46 amalloy: what did you call it?

0:46 amalloy: decorate

0:46 i also wrote a version that immediately applies the juxted function: annotate

0:46 tomoj: I think I've wanted at least one of those before

0:47 amalloy: tomoj: ask and ye shall receive. just depend on amalloy/utils

0:48 also the (comp) stuff there looks like a mess. why not just (filter (comp (partial apply =) (partial map first)))?

0:51 tomoj: :)

0:56 only a bit slower than my version, at least including the actual work I'm doing

0:58 even with my work cut out it's only 22% slower

0:58 and this certainly won't be the bottleneck. thanks

1:02 amalloy: welcome

1:04 seancorfield__: every time someone mentions juxt i have to go and look up what it does

1:05 and i always see "Alpha - name subject to change" and wish it was dist or distribute because then i'd know what it did :)

1:06 amalloy: seancorfield__: i'd never know, if it were called one of those :P

1:07 juxt is so memorable and unique, as a name, that it sticks in my mind. and it *juxt*aposes (f x) with (g x)

1:07 seancorfield__: one man's obvious is another man's wtf? :)

1:08 amalloy: heh, indeed

1:09 brehaut: seancorfield: in haskell its called (&&&)

1:09 and it has a related (***)

1:09 i can never remember which is which

1:13 seancorfield__: instead of "more cowbell" it looks like "more punctuation"...

1:13 tomoj: wonder how they pronounce them

1:13 I vote "triple-{amp,star}"

1:14 brehaut: tomoj: haskell programmers dont talk to each other, they just share publish papers

1:14 tomoj: :D

1:14 conal's talk where he says that some category-theoretical properties of his types makes him feel like he's got the right abstraction still leaves me a bit awestruck

1:15 brehaut: hah

1:15 tomoj: seen patternsinfp.wordpress.com/ ?

1:17 tomoj: diagrams like that are a sign to me that I'm in over my head

1:17 brehaut: :)

1:18 tomoj: "coalgebras for the costate comonad" FUCK

1:18 brehaut: im pretty sure they are category theory stuff

1:18 tomoj: I've tried reading the rosetta stone at least several times and given up

1:19 brehaut: back when i was a postgrad i had this guy lecturing us on this stuff (he was a visiting lecturer)

1:19 i dont think i could have been less prepared for that class

1:32 amalloy: $findfn " " "+"

1:32 sexpbot: []

1:32 amalloy: where do we have url-encoding?

1:36 brehaut: amalloy: https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/util/codec.clj ?

1:36 uses java.net.URLEncoder

1:36 amalloy: yeah, i guess

1:36 feh

1:37 building clojure wrappers for everything is silly, but if there's something *i* want without a clojure wrapper that's a bug

1:46 tomoj: I'm still waiting for someone to write a clojure thrift impl

1:47 znutar: Is there some order in which you should install paredit, clojure-mode and swank-clojure in emacs? The 3 times I've tried it on different boxes different things seem to be broken.

1:47 tomoj: but I guess I'm the only one crazy enough to think that's a good idea

1:47 don't install swank-clojure ever :P

1:47 znutar: But if I do that it works!

1:47 tomoj: it's deprecated

1:48 znutar: This explains a lot.

1:48 tomoj: instead you should start a swank server with lein or cake, no swank-clojure.el needed to connect

1:48 you also need a newer version of paredit than is in the standard elpa repo

1:49 I use http://mumble.net/~campbell/emacs/paredit-beta.el but I think (my memory is foggy) there may be a special clojurista's version floating around somewhere?

1:49 znutar: Is the marmalade-pointing current emacs starter kit version workable?

1:49 tomoj: the clojure-mode in there should be good, what version of paredit is it?

1:50 21 or greater should be OK

1:50 znutar: I think it was 22... it's stopped responding since I deleted swank-clojure though

1:51 tomoj: .. paredit has stopped responding?

1:52 znutar: emacs in its entirety has

1:52 tomoj: does C-g save?

1:53 znutar: No, went ahead and kill -9'ed it

1:53 tomoj: ouch

1:53 znutar: No big deal, I'm just fooling around with my old .emacs saved off somewhere

1:53 What were you doing with thrift, btw?

1:54 tomoj: for a while I'd hoped to get my team to use it, if only to force some thought into shared data/service design

1:54 and the idea of implementing it with gloss/aleph is still attractive, even if this would end up being a highly nonstandard implementation

1:55 and with ztellman's promise of amqp in aleph, txamqp looks more tenable

1:55 znutar: It seems to be lovely for its purpose, although I've barely used it personally.

1:56 tomoj: I think most of the implementations are crappy

1:56 I couldn't find one that properly handled the seqid for instance

1:57 if the clojure proto library wasn't so tied to cake I'd jump to protobufs with no hesitation

2:00 holy shit, apt-get install maven2 says it wants to install 121 extra pacakages

2:02 seancorfield__: heh, i just did mvn test on a new system and it downloaded the entire internet!

2:02 znutar: wow, the java thrift generates is a LOT uglier than the c++ equivalent it generates.

2:03 seancorfield__: that's just because it's java :)

2:03 tomoj: my idea was that a clojure impl could just generate some pretty macro calls

2:03 then the accompanying clojure library could do all the hard work by defining the macros

2:03 maybe I liked this idea just so that I wouldn't have to muck around in C much

2:57 abadr: reading the Joy of Clojure, it gives (1 2 3 4) as an example of a list, but this produces an error for me on the repl -- I'm guessing because 1 isn't a "function, macro, or special form". what's the story?

2:59 seancorfield__: '(1 2 3 4)

3:00 thorwil: ^ quote it like that, so clojure doesn't try to evaluate it

3:00 seancorfield__: ,'(1 2 3 4)

3:00 clojurebot: (1 2 3 4)

3:00 seancorfield__: ,[1 2 3 4]

3:00 clojurebot: [1 2 3 4]

3:00 abadr: i see, thanks

3:00 seancorfield__: ,(map inc '(1 2 3 4))

3:00 clojurebot: (2 3 4 5)

3:01 seancorfield__: ,(map inc [1 2 3 4])

3:01 clojurebot: (2 3 4 5)

3:01 seancorfield__: ,(list 1 2 3 4)

3:01 clojurebot: (1 2 3 4)

3:01 seancorfield__: hth

3:01 abadr: it does :)

3:02 seancorfield__: time for me to turn into a pumpkin... gotta be up early to get my CNG-powered car in for a service :(

3:24 markoman: now my function got so ugly I need your help

3:27 basically im trying to do: (assoc-in map [:args] (do (some-side-effect) {})))

3:28 amalloy: markoman: it sounds like you're mixing mutability and functional code a little too closely for comfort here. but style aside, your code seems like it should work?

3:29 markoman: yes, I need to update session information on function and return a map at the same time

3:30 im confuced because updating session is a function call and it returns something, that I dont need. instead after update I continue creating map

3:32 so what happens to assoc-in map when do gives nil and {}. it the last one returned or?

3:40 amalloy: markoman: surely this would be easier to try in your repl than wait around for help on irc

3:45 markoman: connection broke so...

3:46 ,(assoc-in {:args {}} [:args] (do nil {:k 1}))

3:46 clojurebot: {:args {:k 1}}

3:46 markoman: ,(assoc-in {:args {}} [:args] (do (println "side effects") {:k 1}))

3:46 clojurebot: side effects

3:46 {:args {:k 1}}

3:47 Fossi: markoman: you can message clojurebot in private as well

3:47 or just start a repl ;)

3:48 markoman: oh im doing it too, just continue discussion. but how do you message bot private?

3:48 I got that, clicking the name gave private chat

3:48 Fossi: depends on your client

3:51 markoman: k, added clojurebot to my buddy list, best friends, lol

5:12 how do you check if nested vector has keywords: [[:a {}][:b {}][:c 1]] [:a :b] any of these

5:14 true or false

5:14 ejackson: ,(map coll? [:a :b :c])

5:14 clojurebot: (false false false)

5:15 ejackson: ,(and (map coll? [:a :b :c]))

5:15 clojurebot: (false false false)

5:17 ejackson: i'm trying to figure out the opposite of every?

5:18 some !

5:18 ,(some coll? [:a :b :c])

5:18 clojurebot: nil

5:19 ejackson: ,(some coll? [:a [:b] :c])

5:19 clojurebot: true

5:19 ejackson: markoman: ^^^

5:19 oh wait.... i answered the wrong question.... where's my coffee gone

5:20 markoman: you're going to have trouble pulling the keys and vals apart

5:20 markoman: well I learned some and coll? anyway :)

5:21 ejackson: if not for that I'd suggest (some coll? (flatten x))

5:22 markoman: yes! flatten makes it close

5:23 but now i need to compare

5:24 if (flatten [[:a {}][:b {}][:c 1]]) has any of these keys [:a :b]

5:24 fliebel: Does anyone know a Java lib that can play ALAC? It's rarely used outside of Mac, so most of those cross-platformy things don't play it. About anything that deals with audio in Mac plays it, but that's all C and most of it Objective C.

5:37 Chousuke: markoman: try (some #{:a :b} [:c :d :b])

5:40 markoman: that works: (some #{:q :b} (keys (into {} [[:a {}][:b {}][:c 1]])))

5:43 raek: (some #{:q :b} (map first [[:a {}] [:b {}] [:c 1]]))

5:44 markoman: any particular reason you have a vector of vectors and not a map?

5:46 markoman: hmh, maybe not. i was thinking i could add some additional "params" like [:a {} {}] on vector

5:47 but perhaps i can do it with one, so I guess {:a {}} is preferred here?

5:47 brehaut: ,(keep (fn [a] (when (#{:a :b} (first a)) a)) [[:a {}] [:b {}] [:c 1]])

5:47 clojurebot: ([:a {}] [:b {}])

5:49 markoman: but then the order of items need to be fixed: [{:a {}} {:b {}} {:c 1}]

5:50 raek: markoman: then you could as well do {:a [{} {}]} if you want to associate multiple things with a key

5:50 brehaut: markoman: step back from your immediate question and tell us what you are trying to solve

5:51 markoman: i think its solved, but maybe not best way. i need to think original data structure too

5:51 brehaut: http://mywiki.wooledge.org/XyProblem

5:53 * raek bookmarks

5:53 brehaut: i wonder if i can teach clojurebot that

5:53 clojurebot: xy is http://mywiki.wooledge.org/XyProblem

5:53 clojurebot: Ok.

5:54 brehaut: clojurebot: xy?

5:54 clojurebot: xy is http://mywiki.wooledge.org/XyProblem

5:55 markoman: Xy I'm aware. Usually when I come here and ask the question, I begin to see the solution when forming the question better way. and then ppl give really good tips and side notes on subject

5:55 Fossi: great page

5:56 fliebel: But the other side of the story if that if you ask for a specific Y, you get a solution to Y that is to general.

5:57 brehaut: fliebel: i dont think i understand you

5:58 fliebel: brehaut: Well, sometimes I want to do Y, but have a *very* good reason to want to do X, not not Z, which is the common way to do it.

5:58 brehaut: oh right. yes agreed

6:00 ahihi2: is there a way to set the OS X application name in clojure? I tried (System/setProperty "com.apple.mrj.application.apple.menu.about.name" foo) as I'd do in java, but I still end up with "clojure.main"

6:11 markoman: im still struggling with empty? seq and nil

6:13 say (for [i (range 0 2)] nil) gives (nil nil) which is not empty, so how can I see, if for loop gives only nils which should be regarded as empty / no hits?

6:14 raek: markoman: (nil nil) is a list of 2 elements, not 0. that's why it's not empty

6:14 markoman: ideally id like return value to be either [nil nil] to be [] or [nil "val"] to be ["val"]

6:14 __name__: (map not-nil? …)

6:15 ehm, (map #(not (nil? %)) …)

6:15 raek: markoman: ##(for [i (range 10), :when (odd? i)] i)

6:15 sexpbot: ⟹ (1 3 5 7 9)

6:15 raek: markoman: you can use :when inside for to pick out only some of the values

6:16 markoman: ah I see, it could work

6:17 raek: you can also combine it with let: [... :let [x (some-function i)] :when (some-pred? x)] x

6:17 in case you need to filter on the final value

6:17 markoman: but I think it doesnt work, because I need to do stuff outside for []

6:18 ok, :let changes the game again

6:47 hoeck: ahihi2: maybe there is some strange limitation to when calling .setProperty is guaranteed to have an effect (only at class-initialization time or so)

6:48 I remember having related problems when doing java gui stuff and trying to set swing properties, it wasn't as easy and dynamic as the setProperty method suggests :/

6:49 ilyak: Hi *

6:49 ahihi2: well, it turns out apple's .jar -> .app bundler has a field for the app name

6:49 hoeck: hello ilyak

6:49 ahihi2: so I can just use that

6:49 ilyak: Is there something that works like (take-while), but is eager and also returns the rest of the sequence

6:50 hoeck: ilyak: split-with

6:50 ilyak: i.e. starting from the element that failed predicate, if it failed immediately then the same sequence as was input

6:50 cool, I'd check it

6:51 hoeck: ahihi2: I think I did something similar, setting properties on jvm startup or so

6:52 ahihi2: yeah, that's probably what the bundled app does

7:17 bsjd: hello

7:19 clgv: &(println "hello to you too. ;)")

7:19 sexpbot: ⟹ hello to you too. ;) nil

7:30 TobiasRaeder: Hi :)

7:30 Is there a way to set system properties when running tests via leiningen?

9:03 rhickey: const! https://github.com/clojure/clojure/commit/8296b5f752fdb2926a309a7248d0d1bf6cb436b5

9:11 TimMc: Is this a metadata keyword? What does it do?

9:12 I presume it does what :static is mistaken to do?

9:12 clgv: loo

9:12 ups

9:12 looks like it specifies a constant

9:13 TimMc: Sure, but does that imply inlining?

9:14 clgv: TimMc: cant tell from that diff. I guess the intersting part is that one:

9:14 if(RT.booleanCast(RT.get(v.meta(),RT.CONST_KEY))) +      return analyze(C.EXPRESSION, RT.list(QUOTE, v.get()));

9:15 I don't know enough about the internal java implementation to guess if it does ;)

9:27 is there something like an alter-if function/macro?

9:28 e.g. (let [m (alter-if mymap empty? (assoc k v))] ...)

9:29 I noticed the need for something like this for a couple of times now

9:34 fliebel: Python just beat Clojure for playing a ALAC file.

9:34 clgv: Not in core at least, as far as I know.

9:36 rhickey: What is const about? My best guess would be symbol macros or inlining or something like that.

9:37 clgv: fliebel: you'll know if you understand the meaning of: analyze(C.EXPRESSION, RT.list(QUOTE, v.get()));

9:40 hmm there is a "when-first" in core but no "if-first"

9:43 rhickey: sorry, got called away right after I posted

9:44 (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

9:44 avysk: what's the easiest way to create something like {:foo 1 :bar 2} out of [:foo 1 :bar 2]?

9:45 I can do that, but is there something built-in?

9:45 clgv: avysk: ##(apply hash-map [:foo 1 :bar 2])

9:45 sexpbot: ⟹ {:foo 1, :bar 2}

9:45 avysk: !!!

9:45 Thanks

9:46 Looks obvious when one knows the right answer :)

9:46 clgv: $findfn [:foo 1 :bar 2] {:foo 1 :bar 2}

9:46 sexpbot: []

9:46 clgv: $findfn hash-map [:foo 1 :bar 2] {:foo 1 :bar 2}

9:46 sexpbot: [clojure.core/apply]

9:47 clgv: hmok. I found a nice-to-have feature for sexpbot, I guess ;)

9:47 Fossi: ,(into {} [:foo 1 :bar 2])

9:47 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

9:47 rhickey: if you re-def x, no code will see that value until it's recompiled

9:47 fliebel: rhickey: So symbol macros indeed!

9:48 rhickey: fliebel: nope

9:48 manutter: rhickey: nice :)

9:48 rhickey: fliebel: symbol macros would in turn get evaluated, this is just straight constant data

9:49 clgv: $findfn [1 2 3 4 5 6] [2 5 6] [1 3 4]

9:49 sexpbot: []

9:49 fliebel: rhickey: So what is it used for?

9:49 rhickey: fliebel: speed

9:49 clgv: $findfn [1 2 3 4 5 6] #{2 5 6} [1 3 4]

9:49 sexpbot: []

9:50 rhickey: without const, if you said (defn foo [] x), that code would have to get the value of x from the var every time

9:52 gotta run , have fun with const

9:53 cemerick: We need a rhickey batlight, so he can swoop in when disaster strikes. :-)

9:53 dn

9:53 o

9:53 bah

9:54 dnolen: I wish I could make your talk tomorrow. Any chance it'll be recorded?

9:55 dnolen: cemerick: unsure, sort of last minute thing for me. Got some work to do...

9:55 cemerick: Yeah, I figured. Good luck.

10:05 dnolen: cemerick: thanks!

10:35 anonymouse89: is there a built-in to insert into a certain position of a list/vector/etc?

10:35 (it's flat so I don't think I'm looking for zippers)

10:45 raek: anonymouse89: no, not for lists/sequences and vectors.

10:45 hoeck: anonymouse89: but vectors only support assoc

10:45 anonymouse89: raek, hoeck: thanks!

10:46 hoeck: so creating a new vec with a single element changed works

10:46 anonymouse89: hoeck: right, but still no insert

10:46 raek: you can still do it with (concat (take i coll) (drop (inc i) coll)) for sequences and (into (subvec coll 0 i) (subvec coll (inc i)))

10:46 those run in linear time though

10:47 hoeck: I'm usually using (apply vector (subvec src 0 X) [new elems] (subvec src X)) to 'insert' into vectors

10:47 raek: finger trees is a persitent data structure that allows you to do these kind of things efficiently

10:48 hoeck: raek: is there a working implementation?

10:49 anonymouse89: raek: yeah, I saw the recorded talk from the conj. I'm also wondering about working implementation.

10:49 raek: https://github.com/clojure/data.finger-tree

10:49 it's available, but I haven't tried it myself

10:51 hoeck: raek: last time I heard from finger trees, there was only a gist with an implementation, this looks better now :)

10:52 Fossi: finger tree sounds creepy

10:54 hoeck: sounds like "magic nose goblin" to me

10:55 fliebel: These trees have been sitting in the back of my head for a while now, waiting for a legitimate use case.

10:55 Fossi: urgh. the image doesn't get better

10:56 fliebel: Fossi: Have you seen the image in the presentation?

10:56 Fossi: nope

10:57 now i'm not sure whether i want to either ;)

10:57 anonymouse89: reminds me of The Labyrinth

10:57 (sorry, very offtopic)

10:58 fliebel: Fossi: http://talk-finger-tree.heroku.com/#5

10:58 Fossi: as if the topic at hand was that important ;)

10:58 ah

10:58 anonymouse89: fingers! what is more important

10:58 Fossi: funky

10:58 pjstadig: clojurebot: const is <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x

10:58 to be as if you wrote 42 instead

10:58 clojurebot: 'Sea, mhuise.

10:58 pjstadig: clojurebot: const is <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

10:58 clojurebot: 'Sea, mhuise.

10:59 fliebel: const

10:59 TimMc: const?

10:59 clojurebot: <rhickey> (def ^:const x 42) will cause any compiled reference to x

10:59 pjstadig: clojurebot: forget const |is| <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x

10:59 clojurebot: I forgot that const is <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x

10:59 pjstadig: const?

10:59 clojurebot: <rhickey> (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

10:59 TimMc: const?

10:59 clojurebot: <rhickey> (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

11:00 pjstadig: clojurebot: forget const |is| <reply>(def ^:const x 42) will cause any compiled reference to x

11:00 clojurebot: I forgot that const is <reply>(def ^:const x 42) will cause any compiled reference to x

11:01 pjstadig: clojurebot: const is <reply>(def ^:const x 42) will cause any compiled reference to x

11:01 clojurebot: Ik begrijp

11:01 TimMc: what

11:01 pjstadig: clojurebot: forget const |is| <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x

11:01 clojurebot: I forgot that const is <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x

11:01 pjstadig: const?

11:01 clojurebot: <rhickey> (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

11:01 pjstadig: clojurebot: forget const |is| <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x if you wrote 42 instead

11:01 clojurebot: I forgot that const is <reply><rhickey> (def ^:const x 42) will cause any compiled reference to x if you wrote 42 instead

11:01 pjstadig: const?

11:01 clojurebot: <rhickey> (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

11:01 pjstadig: gah

11:02 i'm in over my head

11:02 TimMc: Can this be done in PM with clojurebot ?

11:02 pjstadig: thought right might not want the notifications...

11:02 yeah

11:02 TimMc: 123456789?

11:02 clojurebot: 987654321

11:02 TimMc: Yeah, it can.

11:03 danlarkin: pjstadig causin' problems

11:04 TimMc: pjstadig: clojurebot is currently a blank slate for const

11:04 pjstadig: fixed :p

11:04 const?

11:04 clojurebot: (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

11:04 TimMc: Looks good.

11:06 I have a list of values, how do I tell if they are all truthy?

11:08 raek: ,(every? identity [true 1 0])

11:08 clojurebot: true

11:08 TimMc: hah!

11:08 Raynes: &(every? identity [1 2 3 false 0 true])

11:08 sexpbot: ⟹ false

11:08 Raynes: raek: I hate you. :<

11:08 TimMc: Thanks, that makes sense.

11:09 Raynes: My downfall is that I test my code in my own REPL before spewing solutions.

11:09 TimMc: haha

11:09 Raynes: It's a bad habit, I'm sure. ;)

11:18 TimMc: Context: I'm rewriting clojure.test/are to return logical true if all tests pass.

11:22 Now I can pass predicates like #(are [k v] (= (k %) v) :a 1, :b 2) to helper functions in my test classes that set up complicated data structures.

11:22 (Testing the tests and whatnot.)

11:24 anonymouse89: pmapcat?

11:25 fliebel: anonymouse89: Nope, (aply concat map)

11:25 *pmap

11:25 *apply

11:25 * fliebel does not test his code in his own REPL

11:25 anonymouse89: fliebel: i got the idea :)

11:55 cemerick: http://cemerick.com/2011/04/19/clojure-atlas-preview/

11:57 osoleve: from a complete newbie's standpoint, looks like a very interesting and useful tool

11:59 aww, 'try it' fooled me :(

12:00 cemerick: osoleve: your interest is duly noted :-)

12:00 The ontology is woefully incomplete still. When it's only staggeringly incomplete, I'll open things up.

12:01 osoleve: looking forward to it

12:01 fliebel: cemerick: Do you count the number of people that tried vs bought?

12:01 cemerick: fliebel: ah, that would've been smart, huh? :-)

12:02 I doubt very many would click on the buy link straight off in any case.

12:02 fliebel: cemerick: Well, just append a hash to one and google analytics will count for you ;)

12:02 osoleve: cemerick, i clicked it when i realized 'try it' didn't work :[

12:02 haha

12:03 fliebel: cemerick: Is the $20 for real, or is the button as a while a joke?

12:03 *whole

12:04 cemerick: fliebel: real?

12:04 fliebel: cemerick: In other words, will it cost $20 when it's done?

12:05 cemerick: fliebel: It'll definitely be paid, yes. Where the price lands in not yet certain.

12:05 s/in/is

12:05 sexpbot: <cemerick> fliebel: It'll defisitely be paid, yes. Where the price lands is not yet certais.

12:05 osoleve: haha

12:06 fliebel: cemerick: Do you make the relations yourself, or do you use extensive introspection?

12:06 cemerick: fliebel: The source, docs, and class hierarchies I can gather in an automated fashion. Everything else needs to be built manually.

12:06 osoleve: cemerick, is it written in clojure?

12:07 fliebel: cemerick: It would be cool to get 'everything else' as metadata upstream in Clojure.

12:07 cemerick: If I could build an accurate ontology like this in an automated way, I'd go build a $10K-per-site app.

12:07 osoleve: Certainly, though there's probably more javascript in the source repo than clj.

12:08 osoleve: cemerick, neat

12:08 cemerick: fliebel: The clojure jar would be a *lot* larger than it is now :-)

12:08 osoleve: i'm excited to start learning clojure, i've had a lot of fun in the past with scheme/CL

12:08 cemerick: And Rich would simply quit

12:08 fliebel: haha

12:10 cemerick: Good luck with that. I could never do such a thing. I'm the kind of person who would rather spend an hour(or even a day) writing a script to do some repetitive task that takes ten minutes.

12:11 cemerick: fliebel: where there's muck, there's (hopefully) brass :-)

12:11 ieure: Interesting, cemerick.

12:11 It looks nice, I hope it works out ofr you.

12:11 *for

12:11 fliebel: cemerick: I'm no american, so I have no idea what that means… not exactly anyway.

12:12 ejackson: hm.... looks like I arrived into an interesting conversation...

12:12 manutter: it started here: http://cemerick.com/2011/04/19/clojure-atlas-preview/

12:13 fliebel: ah http://www.phrases.org.uk/meanings/408900.html

12:13 osoleve: guys, quick question. for a newbie, cake or lein?

12:13 fliebel: osoleve: Whatever name sounds better to you.

12:13 manutter: I'm still fairly noobish and I'm partial to lein

12:14 though to be frank I haven't played much with cake

12:14 cemerick: fliebel: that's the best answer I've heard to that question in a while :-)

12:14 ieure: I’m intermediate. Lein works great, I haven’t messed with cake.

12:14 osoleve: mmk, thanks

12:14 ejackson: pish, butterflies.

12:15 fliebel: cemerick: you have these pointy things on your lambda, have you considered using the maps api for real?

12:15 I mean, zooming, searching, paning, it's all there.

12:15 ejackson: cemerick: I'd like to volunteer as a concerned citizen.

12:15 cemerick: fliebel: You mean for the actual visualization?

12:16 fliebel: cemerick: Yea, the only thing that'd remain is putting the data through graphviz.

12:16 cemerick: ejackson: :-) drop your email into the allotted space, and you'll get a note sooner or later :-)

12:16 ejackson: groovy.

12:16 Raynes: mirah.

12:16 * fliebel is cutting corners

12:17 cemerick: fliebel: graphviz would produce an unintelligible muck. You need to be able to restrict the scope of the visualization or you'll be blinded by the proliferation of edges.

12:17 Raynes: cemerick: What do you use to draw illustrations in Clojure Programming?

12:18 cemerick: Raynes: we don't; O'Reilly has illustrators that take care of it

12:18 Raynes: My book is illustrationless. Makes Rayne sad.

12:18 fliebel: cemerick: Okay, very true.

12:18 Raynes: I suppose I could just sketch some and No Starch would take care of it.

12:18 But that feels weird for some reason.

12:18 manutter: what kind of illustrations do you need?

12:19 Raynes: I doubt I'll need anything more interesting than lines and boxes. I could do that in gimp, but meh. I don't like drawing on a computer.

12:19 fliebel: Raynes: At least Manning has these whateverth-century figures they use :)

12:20 manutter: check out VUE from tufts.edu, it might give you some ideas

12:20 It's actually concept mapping but I was playing with it and it seems like it has some interesting applications

12:20 fliebel: cemerick: What kind of data do you display that can't be retrieved by introspection?

12:21 cemerick: fliebel: The manual bits include defining the "concept" nodes, and all of the edges everywhere.

12:22 fliebel: ah, okay.

12:44 markoman: anyone familiar with hiccup?

12:45 technomancy: clojurebot: hiccup is also http://tinyurl.com/426og7n

12:45 clojurebot: In Ordnung

12:46 technomancy: clojurebot: wait a minute, you're not fsbot

12:46 clojurebot: I don't understand.

12:46 technomancy: clojurebot: forget hiccup |is| also http://tinyurl.com/426og7n

12:46 clojurebot: I forgot that hiccup is also http://tinyurl.com/426og7n

12:47 technomancy: clojurebot: hiccup is both https://github.com/weavejester/hiccup and http://tinyurl.com/426og7n

12:47 clojurebot: You don't have to tell me twice.

12:54 KirinDave: markoman: Yes. But you should be using enlive 90% of the time.

12:55 markoman: Hiccup is most useful for A -> NodeSeq transformations to feed enlive when it's awkward to use its for loops.

12:56 markoman: hmh.. so far everything has worked well inside html form. i think i once had a strange situation where it didnt work like i expected

12:58 KirinDave: has enlive made any attemption to automate translation of terms inside html forms?

12:58 KirinDave: markoman: Nope.

12:59 markoman: But... really?

12:59 markoman: The 18 lines of code it would take to make that happen, with the gain being a much-improved model and superior modularity, are not worth that minor investment?

13:00 markoman: yes, I was thinking this last week [:div "some content" [:a "link text"]]

13:00 manutter: That's something I've been wondering lately too

13:01 markoman: would it be bad idea to use html tag path to the text content and msomehow automate translation of terms?

13:02 manutter: I've got an enlive setup where english page templates are under html/en/ and french under html/fr, etc, but how to internationalize the messages generated internally?

13:02 KirinDave: Well that's where something like hiccup could be part of a solution.

13:02 markoman: KirinDave: what do you mean with 18 lines of code?

13:03 thorwil: Raynes: for anything even vaguely resembling a technical diagram, choose inkscape over gimp. the difference is kinda like a scripting language vs assembler

13:03 redinger: cemerick: Okay, signed up for Atlas. Looking forward to trying it out!

13:03 KirinDave: markoman: If I understood what you're saying, it's not terribly difficult to write code to take an incoming request and pull out/check/retype/escape form paramters.

13:05 markoman: manutter, KirinDave: right, I'm sure there is a pretty simple solution there for this task. and I would be more than happy to find it and test on my code

13:05 cemerick: redinger: Thanks :-)

13:05 It's coming soon enough, just wanted to get a feel for the level of concrete interest before committing to the bulk of the manual work.

13:06 manutter: In my day job, we have a gazillion-line php app, full of code that looks like __("Please enter your password") -- the double underscore is a function call that uses the english text as a key to look up a translation

13:06 there's a command-line script that scans all the php files and builds dictionary files for all the double-underscored prompts, and then you can send the files to a translator to edit/translate

13:06 markoman: exactly

13:06 manutter: Is there something similar in the clojure/java world?

13:07 joegallo: http://download.oracle.com/javase/6/docs/api/java/text/MessageFormat.html

13:07 amalloy: manutter: you could write one in like an hour

13:08 markoman: somehow i think if you write templates like: [:div "some content" [:a "link text"]] you could get context related terms nicely as a side effect so to say

13:08 cemerick: manutter: resource bundles are the JVM-standard way to do these sorts of things: http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/

13:08 joegallo: MessageFormat + Locale + ResourceBundle basically does it

13:08 manutter: Cool, I figured there'd be something like that

13:09 thanks

13:15 markoman: idk, you need to specify these terms: GOODBYE_TEXT, CANCEL_BUTTON_TEXT,... zillions of those, it seems a lot of work

13:15 extra duplicious work

13:15 manutter: Oh, it works with predefined keys and such?

13:15 I haven't had a chance to look up the refs yet.

13:16 markoman: i briefly looked ResourceBundles

13:16 manutter: The php stuff is nice (can't believe I'm saying that!) because it uses the actual strings instead of predefined constants

13:17 The downside is that if you have __("Last Name") and __("Last Name:"), it will create separate entries for the versions with and without the colon

13:18 amalloy: manutter: that is not a downside

13:18 markoman: but __() is still a function, would be easy on clojure too i think. but like you said, there is repeating stuff, contextual stuff and other going on on

13:18 manutter: amalloy: Yeah, not the best example off the top of my head, but you get the idea

13:19 the translator sometimes ends up translating the same string multiple times with only slight cosmetic variations.

13:19 amalloy: yeah

13:19 but it's often hard for you to know what variations are really cosmetic, so it's not really something i'd worry about

13:19 markoman: id like to get around it by thinking I have already specified the path and text, now how can I get them on separate language files using what I already wrote as a default value

13:20 cemerick: using actual strings instead of semantically-significant keys seems like a recipe for very subtle translation bugs

13:22 manutter: could be

13:22 markoman: but i would still like to test that path

13:22 amalloy: cemerick: atlas looks pretty shiny

13:22 cemerick: amalloy: Thanks :-)

13:23 The site is not horrible, but I think the actual visualization is really ugly at the moment.

13:23 Thus, "preview".

13:26 osoleve: how do you represent characters? like, in Scheme, for a you'd put #\a

13:26 manutter: just \a

13:26 osoleve: okay, thanks

13:26 and does that work for parens?

13:27 manutter: I believe so

13:27 osoleve: nifty. thank you.

13:31 hm. how come (contains? '(\+) \+) evaluates to false?

13:32 fliebel: osoleve: You want `some`

13:32 (contains? '(\+) 0)

13:32 &(contains? '(\+) 0)

13:32 sexpbot: ⟹ false

13:33 amalloy: contains?

13:33 clojurebot: contains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains

13:33 fliebel: hm… ##(some #{:a} [:b :a c])

13:33 sexpbot: java.lang.Exception: Unable to resolve symbol: c in this context

13:33 fliebel: (some #{:a} [:b :a :c])

13:33 grrr

13:33 osoleve: &(some (\+) \+)

13:33 sexpbot: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn

13:33 * fliebel gives up

13:33 amalloy: clojurebot: contains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use clojure.core/some or the java method .contains

13:33 clojurebot: 'Sea, mhuise.

13:34 amalloy: &(some #{'+} '[- a +])

13:34 sexpbot: ⟹ +

13:34 amalloy: &(some #{'*} '[- a +])

13:34 sexpbot: ⟹ nil

13:35 osoleve: is there a way to get that to work for characters instead of symbols?

13:35 amalloy: osoleve: it already does

13:35 just take my last example, swap the symbols for characters, and BAM

13:37 osoleve: ohhhkay. thanks.

13:41 i promise my questions will have more substance before long, by the way :)

13:44 amalloy: heh

14:20 osoleve: what's wrong with this function? i get "unable to resolve symbol: stack in this context" and two unmatched parentheses, but I can't find them. :( https://ideone.com/Oq8d8

14:21 amalloy: well the former is caused by the latter, i'm sure

14:21 osoleve: ' doesn't delimit strings in clojure

14:22 osoleve: ...oh, that fixed it. thanks!

14:22 amalloy: you also don't *have* to quote '(), but it's no crime to do so

14:23 osoleve: okay, good to know

14:23 choffstein: Hey all -- quick question. Does clojure have a pattern similar to Ruby Facet's ergo, the gem andand, or try (http://ozmm.org/posts/try.html). Basically -- it allows you to say, 'perform this method if the object is not nil'. I run into this pattern a lot and created a macro to do it for me -- but I was wondering if clojure had something more elegant. It's basically a Maybe Monad...

14:23 osoleve: is it weird to feel like there *aren't enough* parentheses in clojure?

14:24 TimMc: osoleve: Like in let bindings and maps?

14:24 amalloy: clojure.contrib.core/-?>

14:24 osoleve: specifically, in cond

14:24 amalloy: or just use (or), choffstein

14:25 i guess or is a silly solution

14:25 choffstein: amalloy: can I carry you around in my pocket?

14:25 * amalloy demands to be fed delicious morsels if so

14:25 TimMc: amalloy: botsnack

14:26 amalloy: Thanks! Om nom nom!!

14:26 choffstein: you are quite amazing.

14:26 gotta reboot the computy. thanks for the quick answer :)

14:29 * amalloy wonders if he remembered sexpbot's botsnack message right

14:29 amalloy: $botsnack

14:29 sexpbot: amalloy: Thanks! Om nom nom!!

14:56 raek: technomancy: Getting Started with Emacs links to your repo for package.el. Where should the user put the file in order to use it? Should something be added to the .emacs file also? (I'm thinking about the non Emacs Starter Kit case here)

14:57 technomancy: raek: yeah, that should be http://bit.ly/pkg-el23 these days.

14:57 raek: ok, I'll change that

14:58 technomancy: either my wiki privileges got reverted or I am not smart enough to figure out confluence or I would do it myself

14:58 raek: the Edit button appears if you have write access. it should be left to the Add button

14:59 I had to ask clojure-dev after the move to confluence to get write access

15:01 technomancy: also, i vagely recall that you had doubts regarding whether lein repl would work as an inferior-lisp-program. well, it works fine for me.

15:01 technomancy: yeah, I had access at one point. dunno what happened.

15:01 oh nice

15:03 raek: I think they restricted the write access to members of the clojure-dev group only a while ago

15:04 redinger: technomancy: You have access again

15:04 Sorry about that

15:28 osoleve: how do you differentiate, visually, between a predicate and a clause in a cond?

15:28 emacs clojure-mode is lining them up for me and it's throwing me off

15:29 cemerick: preds and clauses generally are paired on the same line

15:29 malkomalko: what's the best way in a for loop to build up some type of seq? is it really something like (def v (conj v 1)) ? that seems anti clojurish

15:30 cemerick: If you have a degenerate case where your case and/or clause are very large, put each on their own line, with an additional line on either side of the pair

15:30 osoleve: cemerick, ahh, okay. thank you.

15:31 amalloy: malkomalko: holy moly no

15:31 malkomalko: I know :)

15:31 ataggart: malkomalko: the for loop creates the seq, you just need to have the body emit the element, e.g. (for [x (range 10)] (* x x))

15:32 malkomalko: but we need to keep track of certain things from iterating through the loop

15:32 we just don't want to return things from the loop, but push things into a stack, and do certain things based on some type of logic

15:33 ataggart: then you don't want to use for. Perhaps reduce.

15:33 amalloy: malkomalko: putting a :when clause in your for loop would solve your issue but you're being pretty vague so it's unclear if that's what you mean/want

15:33 ataggart: untrue! ##(for [x (range 5) y (range 5) :when (> y x)] [y x])

15:33 sexpbot: ⟹ ([1 0] [2 0] [3 0] [4 0] [2 1] [3 1] [4 1] [3 2] [4 2] [4 3])

15:34 ataggart: yes, but my statement was based on "push things into a stack"

15:34 amalloy: obviously a dumb toy example, but you can arrange for your for to not include some elements

15:34 malkomalko: we need to iterate through a list, and capture every "foo", then for every "foo" we need to tell when the last "bar" event form the same sequence happened and assign it to the proper "foo"

15:34 amalloy: ataggart: we're both guessing at what he actually wants

15:34 fliebel: xy?

15:34 clojurebot: xy is http://mywiki.wooledge.org/XyProblem

15:34 malkomalko: #/form/from/

15:35 fliebel: weee

15:35 amalloy: ~o/

15:35 clojurebot: \o ... High five!

15:35 amalloy: cutest command ever

15:36 fliebel: malkomalko: Yea, sounds like reduce with a compound reduction should work.

15:36 amalloy: fliebel: well, reduce *always* works

15:36 fliebel: :)

15:36 amalloy: it's like a sledgehammer of doom

15:37 great tool, super-powerful, but if you solved *everything* that way it'd be awkward

15:37 malkomalko: We're working with a iterator-seq and need to accomplish this in one pass

15:37 fliebel: amalloy: True, but what else? Plain loop/recur? I don't see much else, besides atoms and such doing this.

15:38 malkomalko: think we need a reduce.. you might be right

15:39 amalloy: fliebel: reduce looks like the best solution to problem X, indeed

15:40 raek: malkomalko: I think of something like (reduce (fn [foos x] (cond (foo? x) (assoc foos ... x ...), (bar? x) (update-in foos [(foo b)] ... x ...), :else foos)) {} coll)

15:41 malkomalko: thanks.. gonna give that a go and pull it a part

15:42 raek: here, "foos" is passed to the function and the new "foos" is returned. this might remind you of assignment, but no mutation is actually performed

15:46 ataggart: malkomalko: https://gist.github.com/929424

16:05 technomancy: redinger: aha; thanks.

16:05 (was at lunch)

16:05 I'm never sure with confluence/jira if it's a pebkac or not.

16:16 markoman: hmh, how do you catch exceptions on clojure? Im getting null pointer and hard to debug what causes it

16:16 java.lang.NullPointerException

16:17 ieure: markoman, http://clojure.org/special_forms#Special Forms--(try expr* catch-clause* finally-clause?)

16:17 Hm, not sure if Chrome bungled that URL or what.

16:17 But you should get the idea.

16:20 markoman: thanks. it ways catch classname name, what should I use in these?

16:21 java.lang.NullPointerException is classname, what is name then?

16:24 ieure: I think you want (catch NullPointerException)

16:31 markoman: lets see, maybe i should really study to use emacs gdb

16:32 if I just knew how to put debug point on file

17:49 raek: technomancy: I'm about to change the link in the confluence wiki to http://bit.ly/pkg-el23 now, but I would also like to add some instructions on what do with the file... So, what is the recommended way? Just put it in .emacs.d/ and add (require 'package) to .emacs or something?

17:51 technomancy: raek: oh... yeah, you need to add marmalade as a package source. the instructions on http://marmalade-repo.org are good.

17:51 raek: yes, the marmalade part is already in place

17:52 it's the package.el installation process I'm concerned about now

17:53 technomancy: oh, sure. download, require, add-to-list is all.

17:53 znutar_: is there any risk to adding extra sources for elpa packages if I want extra stuff like haskell mode through elpa? Is there an ordering that matters, or does it just look for the latest version of any packages available?

17:55 technomancy: I think highest version wins.

17:57 raek: technomancy: so this is what I will use as an example: https://gist.github.com/929822 any comments?

17:57 (note that I don't have much experience with how these things should be done prooperly)

17:59 technomancy: raek: that should work.

17:59 raek: technomancy: ok, thanks a lot for the help!

18:00 technomancy: np; thanks for curating

18:14 raek: updated: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs

18:59 eckroth: I want to switch to clojure 1.3 to use priority-map; I've listed org.clojure.contrib/command-line 1.3.0 in my project.clj; but if I try to :use it, I get an error

19:00 is there a way to determine if 1.3 command-line is being loaded or if 1.2 is being loaded (since other deps bring in contrib 1.2)?

19:00 adding :verbose true to the :use statement shows: (clojure.core/load "/clojure/contrib/command_line") and so on but no info about version

19:02 _ato: eckroth: try (-> (clojure.lang.RT/baseLoader) (.getResource "clojure/contrib/command_line.clj"))

19:02 should tell you the jar it's from

19:03 eckroth: _ato, awesome, it worked: #<URL jar:file:/.../lib/clojure-contrib-1.2.0.jar!/clojure/contrib/command_line.clj>

19:04 now I just need to "force" version 1.3.0 to be :use'd

19:12 carllerche: do all protocol implementations have to be in the same namespace?

19:12 amalloy: carllerche: definitely not

19:13 carllerche: I defined a protocol and implemented it in other namespaces... if I require the namespace, how can I refer to the function? It seems that I have to refer to it w/ the namespace

19:14 I'm probably misunderstanding something wrt protocols & records

19:15 amalloy: do I refer to a function by the namespace that defines the protocol then?

19:15 amalloy: yes

19:17 (ns a) (defprotocol Animal (noise [])) (ns b (:require a)) (extend-protocol a.Animal Dog (noise [] (bark))) (a/noise (Dog.)) ; vaguely

19:17 i don't have the syntax right because i don't use protocols much, but the protocol stuff all lives in the originating namespace

19:18 raek: so it's not a/Animal?

19:19 amalloy: raek: i dunno. like i said, syntax

19:19 it's in a, anyway

19:19 raek: ok, I played a bit with it in the repl

19:19 should be a/Animal

19:20 and protocol methods require at leas one "this" arg

19:21 carllerche: protocols and protocol methods follows the same rules as regular defs and defns when considering namespaces

19:21 carllerche: ok... let me see if I can get this to work...

19:22 raek: deftypes/defrecords though... they need to be imported (since they become java classes)

19:23 carllerche: In amalloy's example, (noise...) doesn't take an argument, but one is passed. is it implied?

19:23 raek: also, you don't need to qualify the protocol method names, only the protocol name

19:23 no, it's a syntax error

19:23 * amalloy is full of syntax errors. it's a feature

19:23 carllerche: hehe

19:23 raek: better than "syntactic salt"?

19:25 eh, the comment re. namespace qualified names was meant to refer to the (extent-protocol ...) form

19:26 amalloy: raek: i got that part right, didn't i? qualified Animal but not noise

19:26 raek: yup, I just read that incorrectly

19:33 joshua: How do I write a function in Clojure which returns a recursive function?

19:34 amalloy: (fn foo [x] (foo (dec x)))

19:34 brehaut: (constantly reduce)

19:35 eckroth: well I thought I could just update libraries to use clojure 1.3; but I can't update them all; how can I force :use of a certain version of a clojure.contrib library?

19:35 ieure: joshua__, Can you be a little more specific? Do you really mean a function which _returns_ a different, recursive function?

19:35 amalloy: brehaut: i'm aware that you're kidding, so i'll play along: reduce isn't really recursive, it uses loop/recur. you must mean (constantly iterate)

19:35 ieure: joshua__, Or are you asking how to write a recursive function?

19:36 joshua__: ieure, Yes. I mean a function which returns a different recursive function.

19:36 amalloy: i think joshua__ just means http://stackoverflow.com/questions/5626641/non-tail-recursive-anonymous-functions-in-clojure/5626864#5626864

19:36 brehaut: amalloy: reduce abstracts recursion; the implementation is merely a detail

19:36 eckroth: joshua__, can you just return a (fn myfunc [x] ....) so that you can use myfunc as the recursive call

19:37 joshua__: eckroth, I'll let you know. I hadn't realized I could give an anonymous function a name like that.

19:37 ieure: joshua__, I’m not 100% sure you’re asking the right question; but you’d just say: (fn [] (let [recursive-function (fn [x] (recursive-function (dec x)))] recursive-function))

19:38 amalloy: ieure: that doesn't work actually

19:38 ieure: amalloy, :(

19:38 eckroth: ieure, isn't it easier to do (fn myfunc [x] ... (myfunc (dec x))) etc.?

19:38 amalloy: which is what (fn the-local-name [...]) form is for

19:38 ieure: eckroth, Guess so, I wasn’t aware that you could label functions like that.

19:38 eckroth: ieure, right, I haven't yet used it myself either

19:38 * amalloy gestures subtly up towards the SO link he posted that explains how to do exactly this

19:39 ieure: Of course you probably really want to return a method that uses loop/recur to avoid blowing the stack.

19:39 raek: if you use letfn, it will do both (let [foo ...] ...) and (fn foo ...)

19:39 amalloy: ieure: i actually use this feature semi-regularly

19:39 to implement anonymous lazy-seq functions that call themselves lazily instead of with loop/recur

19:39 raek: "named anonymous functions"...

19:40 eckroth: this stuff is complicated. basically, you should never have two versions of the same lib on the classpath at the same time

19:41 eckroth: raek, thanks for the response; yeah it sucks but some deep dependency (of incanter I think) pulls clojure.contrib 1.2

19:42 raek, frankly I'd rather drop incanter than muck with this for hours :(

19:42 joshua__: amalloy, thanks amalloy. Got it workingg.

19:42 ieure: joshua__, I would recommend that you check out loop/recur.

19:42 You don’t have to mess with labeling your fn at all, and you won’t blow the stack.

19:42 raek: hrm, I guess maven can't figure out that they are the same thing in this case, since you have one monolithic contrib version and one contrib module (and those are treated as different libs)

19:43 joshua__: ieure, ieure I was actually using those, but they didn't work in this case. It wasn't a tail recursive function call if I wanted to express it in the form in which I wanted to express it.

19:43 eckroth: raek, well problem (probably) solved: dropping incanter dropped c.contrib 1.2 plus a whole lot of other junk (eg. servlet-api, log4j, etc.) a bit ridiculous I think

19:45 ieure: joshua__, Okay, just making sure you’re aware of the risks and the tools to mitigate them.

19:48 raek: eckroth: hopefully, this will be less painful when everyone has migrated to "new contrib"

20:09 carllerche: Is there a way to recompile everything in emacs instead of C-c C-k for each buffer?

20:12 technomancy: carllerche: M-x mark-buffer C-c C-r

20:12 or C-c C-l to force all other required namespaces to reload

20:13 amalloy: technomancy: C-x h is bound to M-x mark-whole-buffer

20:13 carllerche: technomancy: thanks

20:13 technomancy: amalloy: ah... I rebound that ages ago and recently dropped my rebinding, so it's missing from my mental mapping

20:14 carllerche: hard to say what's best without knowing why you don't want to use C-c C-k though

20:15 amalloy: brb, gotta go tweet that i knew something about emacs that technomancy didn't

20:15 carllerche: technomancy: I changed a protocol implementation it seems in one file and ran the tests, and got an error saying the protocol wasn't implemented

20:16 technomancy: and the "fix" (unless I did something wrong) was running C-c C-k in all buffers that used functions from that protocol

20:17 eckroth: carllerche, I'm glad you asked this question; hopefully someone knows the answer; I always resort to lein clean in such cases :(

20:17 carllerche: I had the files in question already opened so i just went to them and recompiled, but I can see how that could get out of hand

20:19 eckroth: carllerche, actually, the problem strongly discouraged me from using records, so I brought their use down to just one; maybe I am missing some great benefits, though

20:19 technomancy: my solution so far has been not to work on files that involve protocols and records. =\

20:27 carllerche: eckroth: do I have to bounce lein swank after running lein clean?

20:28 eckroth: carllerche, ugh, good question; I'm still figuring this out (the best way to manage a repl)

20:29 carllerche, obviously that'd work, but I hope it's not necessary; you might want to google for how to clean the repl's definitions

20:31 carllerche, you might try this: http://stackoverflow.com/questions/5409345/clojure-repl-doesnt-pick-up-changes-made-to-defrecord/5409404#5409404

20:32 carllerche, or: http://www.learningclojure.com/2011/01/cleaning-old-definitions-from-repl.html

20:45 carllerche: eckroth: the reload-all trick didn't seem to reload the protocol / record stuff :(

21:37 cemerick: That Steve Yegge thread is bizarre.

21:37 KirinDave: cemerick: He is, as a rule, a weird guy with a weird following.

21:37 cemerick: Like, you'd think he'd be really into certain aspects of FP. Ask him about it tho, and he gets a slightly agitated demeanor.

21:38 cemerick: Mentioning Haskell to him is, it is reported, an excellent way to get blown off.

21:38 cemerick: He goes on and on about nonlocal exits, as if that's the ticket to nirvana or something.

21:38 Just really strange.

21:38 KirinDave: cemerick: This is not really an industry known as a bastion of stable people. :)

21:39 brehaut: got a link for this thread?

21:39 hiredman: first thing approaching a conversation I've had with him (didn't make it to the seajure meet up) and I am already convinced he is a complete tool and can no longer bring myself to read anything he has written :(

21:39 * cemerick hesitates to bring attention to it… :-/

21:39 cemerick: http://groups.google.com/group/seajure/browse_frm/thread/18baa18ffdbdd790

21:40 I'm generally all about inclusiveness and marketing, but I found myself nodding along with hiredman's replies, so there's a data point. ;-)

21:40 lancepantz: heh

21:41 scary

21:41 johnmn3: hi

21:41 KirinDave: Well let's consider why Yegge is famous.

21:41 1. Epically long rants

21:41 2. Very approachable theory

21:41 3. Really long rants

21:41 cemerick: I didn't realize people got burnt for wanting to use CL-style loop macros.

21:42 pprint is driven by CL-style format, fer cryin' out loud

21:42 it's not like we're a bunch of raving lunatics (for the most part)

21:43 KirinDave: I had bought into the theory that he was building the acceptable lisp (i.e. better javascript) when he went to Google.

21:43 Goes to show just how not-plugged-in I am.

21:44 hiredman: I may be a lunatic, but I am an engaged lunatic

21:48 ataggart: has anyone seen Steve submit a patch for clojure?

21:49 cemerick: No; that was one of hiredman's points.

21:49 hiredman: I asked him to point them out so they won't be overlooked

21:49 cemerick: heh

21:51 brehaut: wtf "What Clojure needs is to be non-prescriptive." the prescriptive parts are what make it so damn great. sigh

21:51 hiredman: I almost pulled the trigger on an email to stu saying he is "no moses" and "rich is no god" so "when he comes back from the mount with tablets I have questions"

21:51 cemerick: There's a lot of very sad gems.

21:51 hiredman: (been listening to jewish reggae)

21:55 znutar_: less prescription, more proscription

21:55 ataggart: the only clear issue he brings up is single-passI see only one clear issue he brings up, single-pass compilation. He seems to have a lot of free time on his hands.

21:55 oh well, portal2 just finished downloading.

21:56 hiredman: it will be interesting to see what he comes up with for a debugger

21:57 I don't think single pass compilation is a burden, but I will admit that maybe if it went away suddenly some hitherto undiagnosed malaise might go away

21:57 but I have no firm feeling that it is a problem

21:59 brehaut: also i am under the impression that his beloved javascript is single pass

22:00 hiredman: well, I think he ended up on js because he didn't see an viable alternatives, so hardly his beloved

22:01 brehaut: sure.

22:03 cemerick: The merits of this compiler design or that one are sort of moot in the big picture. Clojure's not "dead at the starting gate" because of a choice there or bit shift operators or what-have-you.

22:04 It's just a list of local problems that likely seem REALLY IMPORTANT in a local context.

22:04 Anyway.

22:06 znutar_: Doesn't a tendency towards non-prescriptivism in the language idiom combined with macros and such just lead to a kind of language-learning hell where you have to learn a different DSL for every nook and cranny?

22:07 I'm not a lisper so I don't really have much context, but that'd seem to be the peril of that approach.

22:08 johnmn3: and clojure offline html preprocessors out there? Like this: http://dorward.me.uk/software/dolt/

22:08 cemerick: Every language is prescriptive, it's just a matter of degrees and orientations and cliques.

22:09 "Multiparadigm" just means that there's multiple prescriptions all operating in parallel.

22:18 ttmrichter: cemerick: Often with painful sharp edges clashing over your rapidly-cooling corpse. :)

22:19 cemerick: ttmrichter: did someone mention C++? ;-)

22:19 * ttmrichter laughs.

22:20 ttmrichter: I wonder why that language leaped to the forefront of your thoughts....

22:21 brehaut: it had to be that or javascript

22:32 TimMc: brehaut: JS doesn't really have prescriptions...

22:32 brehaut: TimMc: it does, its just got 6 of them and they are only half implemented

22:33 TimMc: I think of it more as layers of fads in JS architecting.

22:33 brehaut: there is at least: procedural, prototypal, classical, functional

22:33 and they have all been there since ever

22:34 TimMc: Hmm, I think I was on a slightly different track.

22:34 I'll agree with that assessment.

22:34 brehaut: TimMc: i will agree that it has fads

22:35 TimMc: I don't think I've seen prototypal in the wild.

22:35 brehaut: TimMc: one of the things i like least about JS is how every library has a radically different style

22:35 TimMc: http://jslint.com/

22:35 TimMc: What, is that done in JS?

22:35 prototypally?

22:36 brehaut: yes

22:36 TimMc: Unfortunately, I need to get back to studying for my comp graphics exam, so I can't keep on in this discussion. :-(

22:36 brehaut: JS Lint is written by crockford who is the most vocal proponent of prototypal JS

22:36 TimMc: aha

22:36 yes he is

22:36 brehaut: in particular check out the parser

22:36 its a prototypal pratt operator presendce parser

22:37 TimMc: will do

22:46 chewbran1a: hi all, anyone using clj-http to get gzipped content?

22:47 the readme on https://github.com/getwoven/clj-http says "The client transparently accepts and decompresses the gzip and deflate content encodings." but the content is still coming in as binary for me

22:53 brehaut: chewbran1a: are you using clj-http.core/request or clj-http.client/request ?

22:53 (or one of the verb specific wrappers in client)

22:55 chewbran1a: brehaut: clj-http.client/get

22:57 brehaut: chewbran1a: version ?

22:58 chewbran1a: https://github.com/getwoven/clj-http/blob/master/src/clj_http/client.clj#L52-63 https://github.com/getwoven/clj-http/blob/master/src/clj_http/client.clj#L167

22:59 chewbran1a: http://pastebin.com/Qwd0G8JR

22:59 brehaut: clojure 1.2 and clj-http 0.1.2

23:00 brehaut: chewbran1a: ok. does it have a reasonable content type?

23:00 (the page)

23:01 huh it does

23:01 chewbran1a: yeah encoding gzip content type json

23:01 looking at wrap-decompression right now

23:02 brehaut: chewbran1a: i wonder if its not the gzip that is failing, but its not decoding the string correctly

23:04 technomancy: hiredman: I literally have a google image search for "so let it be written; so let it be done" open in my browser right now as I read what you said.

23:05 hiredman: great minds think alike!

23:07 chewbran1a: brehaut: I just double checked, get basically the same output from curl: http://pastebin.com/5n7wDnu0

23:08 brehaut: chewbran1a: im not an expert on curl, but i thought it handled gzip just fine

23:11 chewbran1a: brehaut: not sure, but it works fine piping curl to gunzip: http://pastebin.com/jhNeeT0J

23:11 brehaut: chewbran1a: curious. unfortunately i have to get back to my actual dayjob

23:12 chewbran1a: brehaut: no problem, thanks for taking a peek

23:14 technomancy: it's really disappointing to me that there's no "motivational poster" style image of "so let it be written; so let it be done"

23:14 but that's probably just because all the images of Yul Brenner as Pharaoh are in portrait orientation.

23:32 xcv: I'm having some trouble with leiningen; the project compiles just fine, but 'lein uberjar' hangs halfway through... Anyone seen this before?

23:34 jlf`: technomancy: http://wigflip.com/automotivator/

23:40 xcv: (I'm using Leiningen version 1.4.2)

23:41 technomancy: jlf`: powered by common lisp! nice. =)

23:42 jlf`: yeah, that's a xach production

23:43 technomancy: http://p.hagelb.org/so-let-it-be-written.jpg

23:44 xcv: you probably have some side-effects in a top-level form. you want the code that's supposed to be run when your uberjar is executed to live in a -main function.

23:44 xcv: also, why not run "lein upgrade" to get onto 1.5.2?

23:49 xcv: pretty awesome to get feedback from the creator so quickly! :)

23:50 the top level -main function calls one function that produces side-effects

23:51 but it still compiles fine...

23:51 (the side-effects are just IO statements, it's a compiler)

23:51 technomancy: oh right; hmmm... it pauses in the middle of "including foo..."?

23:52 xcv: the output looks like this just before it hangs:

23:52 http://pastie.org/1814154

23:53 I can't see where it's stuck

23:53 technomancy: interesting; it's running dependencies twice

23:54 does "lein jar" hang as well?

23:54 xcv: yes, seems to hang

23:54 shouldn't take this long, I think

23:55 technomancy: is the source public?

23:55 xcv: sure

23:55 it's a school project

23:55 I haven't shared it anywhere, but I could paste the code

23:56 here it is

23:56 http://pastie.org/1814156

23:56 don't let the Icelandic freak you out :P

23:57 technomancy: it's ok; I've read Journey to the Centre of the Earth.

23:57 any dependencies?

23:58 xcv: right now, the end result is a bunch of println calls, which will be changed to file IO calls, but I was trying the project build anyway

23:58 here's the project.clj file: http://pastie.org/1814158

23:59 technomancy: where's SchemeLexer coming from?

23:59 xcv: that's a java file in the root of the project directory

23:59 (by the way, Swank-Clojure is awesome)

23:59 technomancy: ah, that wasn't really me

Logging service provided by n01se.net