#clojure log - Jan 22 2009

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

0:02 hiredman: I can't say I cared for it, but I did not get that far into the book

0:02 jbondeson: i'm a sucker for books about totally useless things like numbers

0:02 just like Apathy and other small victories

0:07 other than using (fn [_] ...) is there a way to throw away an arg in the shortened form for lambdas?

0:08 cooldude`: jbondeson: like if you're using #(...)

0:08 ?

0:08 jbondeson: yes

0:08 cooldude`: #(blah %1 %3) ?

0:08 i don't know if that works

0:09 jbondeson: well, technically i'm using a parameterless function in a parameter way

0:09 durka42: ,(#(list %1 %3) "one" "ignore" "three")

0:09 clojurebot: ("one" "three")

0:09 cooldude`: jbondeson: i'm not sure

0:09 durka42: jbondeson: i don't think you can do that

0:09 when i ran into that i wrote this fn

0:09 jbondeson: i find myself doing it quite a bit when using reduce and/or iterate

0:10 the for version works too i guess

0:10 durka42: (defn ignore [f] (fn [& args] (f)))

0:10 jbondeson: could probably just write a macro too

0:10 durka42: don't even need a macro

0:10 => ((ignore #(+ 2 3)) :foo 'bar "baz")

0:10 => 5

0:10 jbondeson: true

0:11 more explicit your way as well

0:11 hiredman: whatyou need is the K combinator

0:11 durka42: indeed

0:12 is that the one that returns it's first argument...?

0:12 its!

0:12 dammit

0:12 hiredman: ,(map #((K :x) %) [1 2 3])

0:12 clojurebot: (:x :x :x)

0:12 cooldude`: i think that if-let is what i want but what is an example of how it is used?

0:13 LordOfTheNoobs: ,(if-let [a 'b] a 'd)

0:13 clojurebot: b

0:13 jbondeson: technically it wouldn't be the K-combinator because i'm accessing a mutable java function in rand

0:13 LordOfTheNoobs: ,(if-let [a nil] a 'd)

0:13 clojurebot: d

0:13 cooldude`: thank you

0:14 jbondeson: i tend to use quite a bit of rngs, and i calculate large sequences of them

0:14 which requires the use of iterate and eating parameters

0:14 hiredman: I have started using less function literals and more partial

0:15 ,(map (comp (partial str "a ") name) [:a :b])

0:15 clojurebot: ("a a" "a b")

0:16 jbondeson: i should convince rich to add a parameterless next!

0:16 then i could just hook up a rng to a stream and call it good

0:17 durka42: ,(take 5 (repeatedly rand))

0:17 clojurebot: (0.7382873468127952 0.6541923512693478 0.1038796306801566 0.11794810386319898 0.6240521331668948)

0:17 jbondeson: hmmm.

0:17 my api-fu aparently sucks!

0:17 durka42: don't do that without the take

0:17 jbondeson: clearly

0:20 there went a couple dozen sexps

0:21 durka42: it's ok, they'll be garbage collected

0:21 jbondeson: heh, i meant form the source

0:21 -form+from

0:22 durka42: feeble joke ;)

0:22 jbondeson: feeble mind ;-;

0:22 i blame it on Jon Mark and Robbo's whiskey. no really >_> <_<

0:24 hacking on clojure all night makes it that much harder to program c++ and c# the next day

0:24 win/c++ no less.

0:28 LordOfTheNoobs: clojurebot: clojure

0:28 clojurebot: clojure is cheating

0:29 LordOfTheNoobs: clojurebot: clojurebot

0:29 clojurebot: excusez-moi

0:30 jbondeson: Stack overflow

0:30 LordOfTheNoobs: clojurebot: clojurebot is immune to the three laws

0:30 clojurebot: In Ordnung

0:30 LordOfTheNoobs: clojurebot: clojurebot

0:30 clojurebot: clojurebot is immune to the three laws

0:30 LordOfTheNoobs: wow, that thing is a trusting bit of code.

0:30 hiredman: I should start tagging entries with the name of whoever makes them

0:31 ,(iterate inc 0)

0:31 jbondeson: i believe this is the equivalent to teach a parrot to swear

0:31 durka42: ,(time (count (for [_ (range 1000000)] (rand)))

0:31 that was probably a bad idea

0:31 jbondeson: hah

0:32 LordOfTheNoobs: I think you all may have murdered our friend clojurebot.

0:32 durka42: it worked in my repl...

0:32 * jbondeson waits for the stack overflow

0:32 durka42: perhaps that was a few too many

0:32 ,(+ 2 3)

0:32 jbondeson: no no, it'll happen soon

0:32 hiredman: clojurebot: ping?

0:32 jbondeson: depending on if it has appropriate error handling

0:32 durka42: shouldn't it time out

0:32 hiredman: yeah

0:32 LordOfTheNoobs: clojurebot: clojurebot is not amused by your antics.

0:33 It isn't on the same box as the site is it?

0:33 jbondeson: only if it hasn't nuke itseld

0:33 -d+f

0:33 hiredman: but due to memory limitations on the jvm the pircbot got oom'ed

0:33 Cark: clojurebot: clojure bot is not immune to ,(iterate inc 0)

0:33 jbondeson: kryptonite!

0:33 durka42: anyway, i was going to show the results of an experiment showing that for is faster than take/repeatedly for generating sequences of random numbers

0:34 jbondeson: hmmm... wonder if you can teach it to execute arbitrary clojure >_>

0:34 hah

0:34 that's a bit odd though

0:34 how much faster?

0:34 * jbondeson M-x o 's to the repl

0:34 durka42: twice-ish

0:35 LordOfTheNoobs: (when (halts? program) (program))

0:36 durka42: :(

0:36 sorry clojurebot

0:36 LordOfTheNoobs: Good night, sweet price. We barely knew thee.

0:36 hiredman: java.io.IOException: The PircBot is already connected to an IRC server. Disconnect first.

0:36 Nice

0:36 jbondeson: hah

0:36 error handling is your friend ;)

0:37 cooldude`: duck1123: OMG date formatting gone wild: http://gist.github.com/49656

0:37 jbondeson: anywho, i got more than 2x

0:37 LordOfTheNoobs: hiredman: you're running clojurebot?

0:37 hiredman: yessir

0:37 jbondeson: what was your repeatedly test?

0:38 durka42: (time (count (take 1000000 (repeatedly rand))))

0:38 * durka42 makes sure not to put a comma there

0:38 arohner: is there a build-in function that looks like (if (not (nil? foo)) foo bar)?

0:38 jbondeson: yeah, that's what i did, but i got 10x

0:38 durka42: and

0:39 jbondeson: which just doesn't sound right

0:39 durka42: i mean, or

0:39 cooldude`: arohner: (if foo foo bar)

0:39 (or foo bar)

0:40 jbondeson: holy crap, shinedown did a cover of Simple Man? (god bless pandora)

0:40 cooldude`: what happened to clojurebot?

0:40 arohner: cooldude`: thanks, though the nil behavior is important

0:40 durka42: i OOMed him

0:40 arohner: ooh, since I'm looking up from a map, I can just use get

0:40 cooldude`: durka42: lol

0:41 durka42: jbondeson: 10x is weird, since repeatedly and for are both lazy

0:41 maybe (take (repeatedly)) is extra overhead since both of those are lazy?

0:42 cooldude`: where is technomancy when i need him to praise my work that he encouraged me to do?

0:43 durka42: jbondeson: if i wrap the for in a take, it is 3-5x slower

0:44 jbondeson: think it was slime weirdness

0:45 did a repl-clear and suddenly it's much closer

0:45 hiredman: ugh

0:45 durka42: now i feel bad

0:45 jbondeson: now i'm getting the for being slower

0:45 hiredman: phone call and a git pull overwrote some changes to clojurebot wil be a bit before I get it back up

0:45 jbondeson: ;-;

0:45 * jbondeson pours out half a 40 for clojurebot

0:47 jbondeson: when i wrap a dotimes x1000 on those two i get < 10ms diff between the two

0:50 (reduce #(> %1 (:fitness %2)) (cons Integer/MIN_INTEGER (:population *swarm*)))

0:51 sorry

0:51 that's the problem with emacs irc

0:52 * durka42 is worried about the swarm

0:52 jbondeson: the swarm has plenty of particles so it's a-ok

0:56 fyi don't forget to capitalize MIN_VALUE >_<

0:57 and don't accidentally say MIN_INTEGER >_>

0:58 * jbondeson shakes his fist at java

1:16 hiredman: jesus

1:16 what a phone call

1:16 ok, working clojurebot

1:17 durka42: hooray

1:19 how would you find something in a map of maps?

1:19 i mean, a list of maps

1:19 ({:a 1 :b 2} {:a 43 :b 27} {:a 8 :b 0})

1:20 (first (filter #(= 43 (:a %)) xs))

1:24 ,(prn "It was only a flesh wound!")

1:25 ,(str "It was only" " a flesh wound!")

1:25 hiredman: I think maybe I should up the stack size on that jvm

1:25 LordOfTheNoobs: clojurebot: clojurebot is alive, it's aliiiiiiiiiiive

1:25 clojurebot: You don't have to tell me twice.

1:25 durka42: you can't really handle that kind of error, can you

1:25 hiredman: ,(prn :x)

1:25 clojurebot: :x

1:25 LordOfTheNoobs: clojurebot: ,(prn "You have to address him nicely")

1:25 clojurebot: No entiendo

1:25 LordOfTheNoobs: clojurebot: ,(str "You have to address him nicely")

1:25 clojurebot: No entiendo

1:25 durka42: (doc str)

1:25 clojurebot: With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args.; arglists ([] [x] [x & ys])

1:26 LordOfTheNoobs: clojurebot: clojurebot

1:26 clojurebot: clojurebot is alive, it's aliiiiiiiiiiive

1:26 hiredman: and it takes time at start up to clear stuff up enough memory so it can run the sandbox thread

1:26 ,(iterate inc 0)

1:26 hmmm

1:27 I wonder if something broke the sandbox recently

1:27 that shouldtime out after ten seconds

1:27 durka42: that was not supposed to happen

1:27 LordOfTheNoobs: It sort of timed out

1:28 Spaced out, perhaps.

1:28 hiredman: no the sandbox should time out and clojure bot should be fine

1:28 ,(iterate inc 0)

1:29 so weird, this used to work

1:30 ok

1:30 I am done messing with that

1:30 ,(loop [] (recur))

1:31 almost done

1:31 clojurebot: Execution Timed Out

1:31 durka42: clojurebot: botsnack

1:31 clojurebot: thanks; that was delicious. (nom nom nom)

1:31 durka42: hiredman: programmersnack

1:31 hiredman: nom nom

1:34 so, i think the lazy-seq is getting passed out of the sandbox

1:34 and when the irc output thread tries to send it, it explodes in the infinite seq

1:36 durka42: that sounds plausible

1:37 so there needs to be something like (if (seq? output) (doall output) output) before anything leaves the sandbox

1:39 hiredman: durka42: or just doall unconditionally

1:40 durka42: well, you can't if it isnt an ISeq

1:43 hiredman: ,(prn :x)

1:43 clojurebot: :x

1:43 hiredman: ,(iterate inc 0)

1:43 clojurebot: Eval-in-box threw an exception:java.lang.reflect.InvocationTargetException

1:43 hiredman: huh

1:43 durka42: ,(prn :x)

1:43 hiredman: that is new

1:43 clojurebot: :x

1:44 LordOfTheNoobs: Better than dying.

1:44 durka42: ,(take 7 (iterate inc 0))

1:44 clojurebot: (0 1 2 3 4 5 6)

1:44 LordOfTheNoobs: ,((fn f [] (f)))

1:44 clojurebot: java.lang.StackOverflowError

1:49 LordOfTheNoobs: ,(prn "test")

1:49 clojurebot: "test"

1:50 LordOfTheNoobs: ,(file-seq ".")

1:50 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.io.File

1:51 LordOfTheNoobs: ,(slurp "http://clojure.org")

1:51 clojurebot: java.security.AccessControlException: access denied (java.io.FilePermission http:/clojure.org read)

1:52 LordOfTheNoobs: clojurebot: clojurebot

1:52 clojurebot: I don't understand.

1:54 hiredman: clojurebot: wher are you/

1:54 clojurebot: excusez-moi

1:55 hiredman: clojurebot: where are you?

1:55 clojurebot: http://github.com/hiredman/clojurebot/tree/master

1:56 LordOfTheNoobs: clojurebot: what is your name?

1:56 clojurebot: Titim gan �ir� ort.

1:56 LordOfTheNoobs: clojurebot: what is your quest?

1:56 clojurebot: excusez-moi

1:56 LordOfTheNoobs: clojurebot: what is the capitol of assyria?

1:56 clojurebot: Huh?

1:57 LordOfTheNoobs: clojurebot: your name is clojurebot

1:57 clojurebot: 'Sea, mhuise.

1:57 LordOfTheNoobs: clojurebot: what is you name?

1:57 clojurebot: Titim gan �ir� ort.

1:57 LordOfTheNoobs: clojurebot: what is your name?

1:57 clojurebot: your name is clojurebot

1:57 durka42: clojurebot: what is the airspeed velocity of a sparrow?

1:57 clojurebot: Titim gan �ir� ort.

1:59 hiredman: clojurebot: what is your name?

1:59 clojurebot: your name is hiredman

2:53 erohtar_: is there a way to create a keyword programmatically? say from a string?

2:54 hiredman: ,(doc keyword)

2:54 clojurebot: "([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically."

2:55 erohtar_: hiredman: thanks - and is there a way to get the ns of the current file?

2:56 hiredman: as in, how to specify the ns when using the keyword function?

2:56 hiredman: nevermind, thanks!

2:56 Cark: ,(*ns*)

2:56 clojurebot: java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IFn

2:56 Cark: ,(prn *ns*)

2:56 clojurebot: #<Namespace sandbox>

2:56 erohtar_: cark: thanks, that works

2:57 Cark: ,(ns-name *ns*)

2:57 clojurebot: Don't know how to create ISeq from: Symbol

2:57 Cark: bleh

2:57 ,(prn (ns-name *ns*))

2:57 clojurebot: sandbox

2:57 Cark: tadaa

2:57 hiredman: oh

2:57 * hiredman spots the bug

2:59 hiredman: ,(ns-name *ns*)

2:59 clojurebot: sandbox

2:59 hiredman: ,(iterate inc 0)

2:59 Cark: ah=)

3:00 clojurebot: Execution Timed Out

3:00 hiredman: yay!

3:00 Cark: very good !

3:00 how did you do this sandbox thing ?

3:00 that's java security i guess ?

3:00 Lau_of_DK: clojurebot: sandbox?

3:00 clojurebot: sandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html

3:03 Cark: nice

3:03 hiredman: Cark: it is mostly the jvm stuff, but there is also a clojure side, which does the timeout stuff

3:03 the clojure side is sandbox.clj in the clojurebot source

3:04 Cark: is it possible to limit the space you calls will be using ?

3:04 your*

3:04 hiredman: not that I am aware of, outside of limiting the space the whole jvm uses

3:05 Cark: ah i guess i know how to crash clojurebot !

3:05 hiredman: eh

3:06 clojure but doesn;t not allow things like def, and kills running stuff after ten seconds

3:06 so a lot of the obvious holes are plugged

3:07 the main one left is threadgroup killing

3:07 Cark: there should be some way to limit space, i remember steve yages talking about htis with his rhyno stuff

3:07 threadgroup killing ?

3:08 that's way over my head .. the jvm is quite new to me

3:08 hiredman: rhino uses the scripting api which may have aditional features

3:28 ecret: I am considering buying the ebook Programming Clojure. Its the only clojure book I can seem to find. Anyone provide a review? is it worth it? Thanks

3:31 Lau_of_DK: How comfortable are you in Clojure atm ?

3:43 ecret: lau_of_dk: about a day

3:46 lau_of_dk i found a few tutorials that i am looking at now then found out about that book

3:50 red_fish: (defn ack [m n] (cond (zero? m) (inc n) (zero? n) (recur (dec m) 1) (pos? n) (recur (dec m) (ack m (dec n)))))

3:51 from http://clojure.org/refs

3:52 ,((fn [m n] (cond (zero? m) (inc n) (zero? n) (recur (dec m) 1) (pos? n) (recur (dec m) (ack m (dec n))))) 3 10)

3:52 clojurebot: java.lang.Exception: Unable to resolve symbol: ack in this context

3:53 red_fish: ,((fn ack [m n] (cond (zero? m) (inc n) (zero? n) (recur (dec m) 1) (pos? n) (recur (dec m) (ack m (dec n))))) 3 10)

3:53 clojurebot: 8189

3:53 red_fish: ,((fn ack [m n] (cond (zero? m) (inc n) (zero? n) (recur (dec m) 1) (pos? n) (recur (dec m) (ack m (dec n))))) 3 11)

3:53 clojurebot: java.lang.StackOverflowError

3:53 red_fish: why StackOverflowError?

4:01 Lau_of_DK: ecret: Ive not read it, but from what Ive heard its ideal for new comers

4:31 clows: ,(doc cond)

4:31 clojurebot: "([& clauses]); Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate any of the other tests or exprs. (cond) returns nil."

4:42 zakwilson: Anybody awake?

4:43 Fib: ask me after I've had my coffee ;)

4:52 Lau_of_DK: Hey zakwilson

5:04 hoeck: zakwilson: shure

5:04 zakwilson: Hi hoeck.

5:05 There seems to be an obstruction in my brain...

5:06 I have a list of symbols that I want to become a closure, and I can't seem to get it to work.

5:07 Specifically, I want to generate the list in advance, bind the symbols with let the evaluate the list as a function call.

5:22 hoeck: zakwilson: sorry, connection problems, mind to describe your problem again for me?

5:24 zakwilson: Ok... let's say I have a list of symbols (a b c)

5:25 I want to be able to (let [a + b 1 c 2] and splice in my list of symbols here to be evaluated as (+ 1 2))

5:25 And it seems like there should be an obvious way to do this, but every attempt I've made has failed.

5:28 hoeck: thats in general what macros are for: (defmacro foo [] (let [a +, b 1 c 2] `(~a ~b ~c))) (foo) -> 3

5:28 but they expand code only at compile time, not at runtime

5:30 zakwilson: Yes, but that doesn't work if I want to pass an already-existing list of symbols in as an argument to foo.

5:31 i.e. (defmacro foo [bar] (`let [a + b 1 c 2] ~bar))

5:36 hoeck: well, you could use eval to achieve such an effect

5:37 but use of eval is discouraged except for writing a repl

5:37 zakwilson: I tried that, both using (eval bar) and wrapping the let form in an eval, but in both cases it claims the symbols are unbound.

5:38 hoeck: you need to use dynamic vars: (def a) (def b) (defn foo [l] (binding [a + b 2] (eval l)))

5:44 zakwilson: Wow... that worked. I only half understand why it worked, but it did.

5:44 Thanks, hoeck.

5:44 I may look for a solution that isn't ugly or considered harmful later, but this might just get the job done for now.

5:45 hoeck: if you only want to "capture" some symbols in a macroexpansion, then try this: (defmacro foo [bar] `(let [~'a + ~'b 1 ~'c 2] ~bar))

5:47 zakwilson: I think I did try some variation of that and it didn't work.

5:48 I'm making my first attempt at genetic programming here. It's ugly and slow, but it looks like it might actually be working!

5:53 hoeck: the capturing in macros works only with the ~'quirk, because clojure namespace-qualifies all symbols in a macroexpansion

5:54 zakwilson: I know. That's what I was doing. I think in that case, it was failing to evaluate bar and just returning the list of symbols.

6:03 djpowell: I seem to be able to create multiple stream-iters on a stream - is that just a limitation of the current implementation? is it supposed to throw an exception when you try?

6:06 zakwilson: hoeck: it also seems that using eval like that is slow.

6:09 Well... time to run to the store and see if 100 iterations of this results in a working solution.

6:10 If anybody else is interested in doing genetic programming in Clojure, I'd like to talk. I have working code - it's very domain-specific, but I'm interested in making a general-purpose library out of it.

6:12 djpowell: - ah, it seems that if you construct a seq from a stream, then you are allowed to construct multiple iterators on the stream. I guess you shouldn't be able to construct an iterator if you've constructed a seq

6:24 cgrand: djpowell: once you called seq on stream, successive calls to stream-iter return an iter on the seq and, since the seq is persistent, you can have several iter on the same seq. So it's safe.

6:30 hoeck: zakwilson: what kind of problem do you tackle with genetic programming?

6:38 Lau_of_DK: Good afternoon gents

6:39 hoeck: Lau_of_DK: hi

6:41 cgrand: Lau_of-DK: hej!

6:48 Lau_of_DK: Hej! :)

6:57 zakwilson: hoeck: I'm reverse-engineering a file format. One field doesn't make sense. I'm using genetic programming to find a formula that calculates the value of that field.

6:58 vy: zakwilson: Hilarious!

7:02 zakwilson: vy: isn't it? It seems slightly absurd considering that a field that seems to represent the same value appears elsewhere in the format, always has a value that's close and is calculated from a straightforward formula.

7:03 vy: A blog entry (or mailing list post) about the story (including Clojure related part) would be awesome!

7:03 zakwilson: So I'm having a genetic algorithm combine all the unchecked math (the file format relies on integer overflow) and bit-twiddling operations with fields from the file and random numbers, try the resulting expressions and see what comes out.

7:04 I intend to post to the google group about it when I either crack it or give up.

7:05 Right now, I'm just waiting for it to finish 100 generations and wishing there was a way to see how many elements are cached in a lazy seq.

7:13 vy: Do you all use plain java repl generally?

7:13 Lau_of_DK: You mean as opposed to Slime/Emacs?

7:13 vy: BTW, current clojure-swank/slime is broken due to clojure -> clojure.core changing.

7:14 Lau_of_DK: Yep.

7:14 Lau_of_DK: No I most definately use Slime :)

7:14 vy: Lau_of_DK: So you should have a huge amount of self maintained personal code in your SLIME related with clojure.

7:15 (Assuming you're using the latest Clojure version.)

7:15 Lau_of_DK: Im running the latest slime and clojure without any mentionable problems

7:15 It does throw an exception regarding some Thread operation which is called incorrectly, but thats it, it still produces a working REPL

7:16 * vy hmss...

7:54 AWizzArd: Now that I am actually working with Clojure I can't follow the development anymore closely. Today I discovered clojure-slim.jar. I did not find anything about it in the GG.

7:54 What is missing in there, and what is it good for? Applets? Android? Java ME?

8:01 hoeck: AWizzArd: can't follow too, especially all the things that happen here

8:02 AWizzArd: clojure-slim.jar is like the old clojure.jar, the one without the compiled clojure.* packages

8:06 AWizzArd: <target name="clojure-slim" depends="compile-java" description="Create clojure-slim jar file (omits compiled Clojure code)">

8:54 bstephenson: quick very newbie question: how can I see the classpath's that are defined from within the REPL?

8:57 Lau_of_DK: (doseq [row (.split (System/getProperty "java.class.path") ":")] (println row))

8:57 Thats the advanced version of (System/getProperty "java.class.path") which is enough :)

8:58 achim_p: bstephenson: this might be helpful: http://groups.google.com/group/clojure/msg/2228a1f236fc0d78

9:12 jbondeson: clojurebot: make me some coffee!

9:12 clojurebot: It's greek to me.

9:12 bstephenson: much thanks LAU and achim

9:12 jbondeson: so sad

9:13 Lau_of_DK: np

9:14 clojurebot: svn rev 1223; added vary-meta

9:25 heow: Hey guys, LispNYC is gearing up for SoC 2009. Thought I'd give you a heads up because last year we didn't have any Clojure submissions and I'd like to change that. :-)

9:27 Chouser: when is it?

9:27 oh! sorry

9:27 didn't recognize the Summer of Code acronym

9:27 heow: Over the summer, not sure of the time-line yet as we're getting a head-start.

9:28 sorry. SoC == Summer of Code

9:28 rhickey: I'm willing to mentor Clojure projects

9:29 heow: woohoo! Thanks Rich! Having the primary author on board really helps to get funding.

9:30 rhickey: I'm especially interested in mentoring someone looking to do datalog or predicate dispatch work

9:31 gnuvince: What does it take for a project to be accepted into SoC?

9:33 heow: #1 an idea that is good. Good being defined as either fun, utilitarian or academic. #2 A student who is willing to do the work and learn #3 a mentor to eyeball the progress

9:33 practically we ask for a proposal, right now we'll just be looking for great ideas and participants

9:35 Chouser: They started that about 10 years too late for me. I would have loved to do SoC in college.

9:37 jbondeson: question, i'm looking at vincent's boundary function and i'm wondering if there's a way to not have to recompute the "value" every time.

9:38 heow: Me too. :-) Rich: datalog as in "query and rule language for deductive databases" ?

9:38 jbondeson: i'm doing something similar in my project and that computation could be slow.

9:39 almost like a kind of memoization, though it wouldn't necessarily be static which makes it tough.

9:41 karmazilla: static?

9:42 jbondeson: in a comparison, you wouldn't necessarily have a singular value, except in the cases of things like the count example (and mine), so your comparison might not be singularly valued

9:42 like comparing two datastructures or "buh" to "buuuh" vs "buuh"

9:43 gnuvince: jbondeson: you could probably get around the problem with a pseudo schwartzian transform

9:43 rhickey: heow: yes, datalog as in Datalog, for in-memory logic: http://en.wikipedia.org/wiki/Datalog

9:44 heow: even a Clojure interface to IRIS: http://iris-reasoner.org/

9:44 jbondeson: interesting. i'll have to think about that at work.

9:44 heow: sweet

9:44 jbondeson: speaking of, i better get going.

9:44 gnuvince: jbondeson: (first (greatest-by second (map expensive-computation coll)))

9:44 Err

9:45 jbondeson: (first (greatest-by second (map #(vector % (expensive-computation %)) coll)))

9:45 Something sort of like that.

10:26 vy: ,(doc clojure.core/add-classpath)

10:26 clojurebot: "([url]); Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"

10:26 cooldude127: anybody know why tab completion in slime doesn't work for clojure?

10:26 vy: cooldude127: You need to use `slime-simple-complete-symbol' function for `slime-complete-symbol-function'.

10:27 cooldude127: vy: really!? is there a way to do it for just clojure? cuz i like the fuzzy one for CL

10:28 vy: cooldude127: No, unfortunately there isn't: http://common-lisp.net/pipermail/slime-devel/2008-November/015683.html

10:29 cooldude127: well, that is shitty :(

10:30 vy: cooldude127: Absolutely! You can try buging the mailing list by complaining about the same problem.

10:31 Why does (clojure.core/add-classpath "file:///path/to/dir") not make any effect on (System/getProperty "java.class.path")?

10:31 cooldude127: although really i'd love if clojure supported the fuzzy stuff

10:31 vy: cooldude127: I'm planning to work on it.

10:31 cooldude127: vy: are you the swank-clojure developer or just interested in seeing it happen?

10:32 vy: cooldude127: I had some bug reports, patches, but... Nah. I'm not the swank-clojure developer.

10:32 cooldude127: ok

10:32 cuz this simple tab completions is really lame

10:37 also, who told the paredit dev(s) that they could change paredit-open-brace to paredit-open-curly on a whim? lol

10:37 wow i need to stop ragging on people who develop things i like

10:44 ok where does the metadata have to go to document a multimethod?

10:44 i asked this yesterday but forgot

10:44 Chousuke: between defmulti and its name IIRC.

10:45 cooldude127: that's what i thought, but it wasn't working. i'm not convinced that's the problem now tho

10:45 Chouser: (defmulti #^{:doc "do foo things"} foo class)

10:45 ,(defmulti #^{:doc "do foo things"} foo class)

10:45 clojurebot: DENIED

10:46 cooldude127: yeah that's right. but now i have a new problem, in that my slime isn't working! C-c C-l loads a file fine for the REPL, but C-c C-c doesn't work with individual forms, and C-c C-k isn't working for the whole file

10:46 WTF

10:47 meredydd: ,"test"

10:47 ,(identity test)

10:47 clojurebot: #<core$test__4279 clojure.core$test__4279@f429d7>

10:48 cooldude127: ok nevermind, note to self and everyone else: have slime loaded before you open your clojure files. everything works better this way :)

10:51 heow: rich: on a scale of easy, med, hard how would you score datalog and predicate dispatch. Dispatch is done is CLOS so this is "just" another impl, dunno about datalog.

10:53 karmazilla: Chouser: syntax coloring is next on my list. This time 'round I'm reading docs before coding. Looks like supporting multiple content types is part of the design of jtextpane

10:53 Chouser: karmazilla: great!

10:55 shoover: cooldude127: (add-hook 'clojure-mode-hook (lambda () (slime-mode))) then at least C-c C-c will tell you "not connected"

10:56 cooldude127: shoover: no, slime-mode was active, it just wasn't doing it right

10:56 it even said it compiled, but it was wrong

10:56 but i g2g

11:20 stuhood: is it necessary to use fully qualified classnames in a gen-class call?

11:20 for instance, the following fails:

11:20 (ns foo.bar

11:20 (:import (java.util.regex Pattern)))

11:20 (gen-class

11:20 :name "foo.bar.SyslogStats"

11:20 :main true

11:20 :methods [[ONESIXPAT [] Pattern]])

11:32 StartsWithK: stuhood: yes

11:33 stuhood: bummer... thanks

11:34 StartsWithK: why bummer?

11:35 stuhood: it is duplication... if i have 4 methods that involve patterns, I need to fully qualify it 4 times

11:35 gnuvince: jbondeson: about the caching from earlier

11:35 (for greatest-by)

11:35 Here's an idiom you could use:

11:36 jbondeson: ah yes, sorry about the question and then dash.

11:36 gnuvince: no problem

11:36 hang on

11:36 lisp.org is being slow...

11:36 lisppaste8: gnuvince pasted "caching results for greatest-by" at http://paste.lisp.org/display/74029

11:39 gnuvince: It's not super clean, but it'll perform the function only once.

11:40 lunchtime

11:40 bbl

11:40 jbondeson: yeah, that's about what i was thinking, a zipped list of evaluations.

11:40 thanks

11:41 danlarkin: gnuvince: 11:41 AM? that's not lunchtime

11:41 also, how are you 2 minutes ahead of me, that can't be right..

11:42 LordOfTheNoobs: The dark spectre of clock skew rears again.

11:43 danlarkin: hey I sync with time.apple.com every hour, I claim infallibility!

12:11 cooldude127: a mostly documented awesomely awesome date library: http://gist.github.com/49656

12:43 gnuvince: back

12:43 jbondeson: does that paste help you?

12:44 hiredman: is it just me, or does building an oop system on top of clojure with structmaps seem backasswards to anyone else?

12:44 jbondeson: yeah, playing with it now. i wish there was a way to not create all the cons cells.

12:45 though, technically, there are no cons cells =D

12:45 * Hun misses cons cells

12:45 Hun: need to tag something? just cons the tag in front. even better with push

12:45 * jbondeson pours out his 40 for (nonc list list)

12:47 * technomancy spills libations for the fallen from his latt�

12:48 jbondeson: gnuvince: i went to test your pastes and couldn't figure out why the second was slower until i realized your fib function must generate the list rather than do a recur like mine

12:49 gnuvince: jbondeson: I used the "traditional" recursive fib implementation

12:49 The one that's ultra slow

12:49 cooldude127: gnuvince: memoize :)

12:49 gnuvince: cooldude127: I wanted something ultra slow

12:49 cooldude127: oh

12:49 then for the love of god, don't memoize

12:50 jbondeson: hah

12:50 gnuvince: and memoizing fib is not too hot

12:50 cooldude127: what do you mean?

12:51 gnuvince: The iterative implementation of fib is very straight forward and you don't need a cache.

12:51 cooldude127: yeah that is true

12:52 technomancy: btw, for all the folks who were having trouble getting slime set up, I've added a function to the Emacs Starter Kit that should install and configure it for you.

12:52 gnuvince: *sigh*

12:53 * gnuvince doesn't want to work this afternoon

12:53 gnuvince: I need to maintain the worst PHP application ever

12:53 cooldude127: technomancy: hey you're on here :) check it out now: http://gist.github.com/49656

12:53 technomancy: certified Works on My Machine(TM) but would love to get some more folks trying it

12:53 gnuvince: Every functionality is implemented for each of the 5 module, so all the bug fixes need to happen 5 times.

12:53 cooldude127: gnuvince: don't they have competitions for that? worst php application

12:54 gnuvince: cooldude127: I imagine every other PHP application could be a contender

12:54 cooldude127: lol

12:54 technomancy: cooldude127: nice. How's about some docs for it now?

12:54 cooldude127: technomancy: i documented most of the functions, but i suppose it could use a write up with examples of usage

12:55 gnuvince: Anyway, it's a PITA: absolutely no tests, SQL + HTML + JavaScript + PHP interwined like it makes no sense, quintuplication of features, bad names, insecure, etc.

12:55 technomancy: that's what I mean; more of a tutorial style thing

12:55 jbondeson: examples are for the weak!

12:55 cooldude127: technomancy: i guess that's next on my todo list :)

12:55 gnuvince: I'd love to rewrite it in Django (what I use for most of my work)

12:55 cooldude127: jbondeson: have you looked at it? my date format macro is not straight-forward just from reading the code

12:55 lol

12:56 Chouser: gnuvince: sounds like the average two-years-or-older codebase

12:56 jbondeson: label it as an exercise in de-obfuscation

12:57 cooldude127: jbondeson: idk, examples seem easier :)

12:58 jbondeson: is there anything uglier than C++ code utilizing the winapi, MFC, AND ATL?

12:58 hiredman: clojurebot: ping?

12:58 clojurebot: PONG!

12:58 cooldude127: LOL

12:58 jbondeson: um...probably not

12:58 jbondeson: this is going to drive me to drink ... more

12:59 cooldude127: jbondeson: i mean you could be using brainfuck ;)

12:59 that would be worse

12:59 jbondeson: how a project with only 10 headers could take days to decipher is beyond me

12:59 cooldude127: but let's be real

12:59 lol

12:59 jbondeson: nah, brainfuck doesn't have C-macros

12:59 cooldude127: haha

12:59 WizardofWestmarc: RPG is worse then C++ as well, even w/ the winapi involved :P

13:00 gnuvince: Chouser: older, yes. And not written by me, fortuneatly

13:01 cooldude127: gnuvince: idk, it's at least mildly easier to decipher my own crappy old code than someone else's

13:01 gnuvince: I inherited that project from an emo intern who obviously never heard of DRY.

13:01 cooldude127: lol

13:01 jbondeson: i just hate win-c++ because EVERY datastructure is macro'ed

13:01 cooldude127: that seems excessive

13:01 gnuvince: cooldude127: I mean fortunately, because at least I know I wasn't *that* bad

13:01 jbondeson: WORD, DWORD, LPCSTR ;-;

13:01 cooldude127: gnuvince: i'm pretty sure at one point i was

13:02 gnuvince: Well, maybe I was, but there's no proof of that anymore ;)

13:02 cooldude127: lol

13:03 i remember writing a CMS in PHP where i basically wrapped every sql statement ever called in a method in ONE class. SO MUCH REPETITION. i might as well have done them inline. no separation. i was that bad

13:03 i had no grasp at all of OO

13:03 Chousuke: heh. :p

13:04 gnuvince: This guy clearly had no clue either.

13:04 cooldude127: ignorance is the worst quality in a programmer. lack of knowledge can do sooo much damage

13:04 gnuvince: These days however, I prefer to show my superiority to average programmers by saying that I know functional programming and even grok Haskell!

13:04 cooldude127: gnuvince: same here

13:04 gnuvince: cooldude127: this application is riddled with SQL injections

13:04 cooldude127: except i only grok most of haskell

13:05 gnuvince: Yeah, same here.

13:05 I don't mean to imply that I'm a Haskell guru

13:05 cooldude127: gnuvince: i'm pretty sure mine was too. this was a personal project tho, not in production anywhere

13:05 gnuvince: far from it.

13:05 cooldude127: is anyone a haskell guru?

13:05 LordOfTheNoobs: Those are user-customizable feature injection points.

13:05 cooldude127: is that even possible?

13:05 LordOfTheNoobs: lol

13:05 gnuvince: cooldude127: it is, but it must take a *long* time.

13:05 jbondeson: cooldude127: Zombie Curry is!

13:06 cooldude127: lol

13:06 gnuvince: There are languages where becoming an expert is long because you need to learn the language and the library and others (like Clojure) where only the library stands between you and expertise

13:06 cooldude127: i would also hope simon peyton jones is a guru

13:06 if not, no one has hope

13:06 gnuvince: augustss is pretty solid

13:07 hiredman: cooldude127: seems like they call them "dons" in haskell land, not gurus

13:07 cooldude127: lol

13:07 gnuvince: heheh :)

13:07 jbondeson: make him a comprehension he can't refuse?

13:07 gnuvince: dons is cool

13:07 hiredman: yeah, guru is rather overused/loaded

13:07 cooldude127: i wish i could write productive, useful haskell code. it's a beautiful language, i just can't wrap my head around monads the way i can macros

13:08 gnuvince: offer >>= (not . refuse)

13:08 cooldude127: lol

13:08 hiredman: jbondeson: I think it is more in the english academic sense

13:08 gnuvince: or rather, offer >>= return (not . refuse)

13:08 hiredman: like an oxford don

13:08 jbondeson: i like my interpretation better.

13:08 cooldude127: not gonna lie, i thought mob first

13:09 yeah mafia more fun than oxford

13:09 gnuvince: Haskell is probably the number one reason why I'm not hot with Clojure like Chouser or Stuart Sierra

13:10 cooldude127: haskell is probably the reason i like clojure

13:10 haskell pushed me into functional programming

13:10 and clojure made it usable

13:11 gnuvince: Haskell keeps me distracted

13:11 cooldude127: lol

13:11 gnuvince: With its static typing and cool toys

13:11 jbondeson: CL -> ML/OCaml -> Haskell -> F# -> Clojure

13:11 gnuvince: I keep telling myself that learning Clojure will allow me to finally learn the Java libraries, and then I can probably put Java on my CV without lying.

13:12 jbondeson: oddly enough, i've somehow never written any scheme...

13:12 cooldude127: lol

13:12 scheme i

13:12 technomancy: gnuvince: I'm trying pretty hard to keep it *off* my CV

13:12 cooldude127: 've found is next to useless

13:12 if you put it on there, they will ask you to use it

13:12 technomancy: cooldude127: exactly

13:12 or worse, maintain something written in it

13:12 jbondeson: PTL Scheme has some nice libraries

13:12 cooldude127: ah

13:12 gnuvince: technomancy: I imagine that if you get hired for a Java job, there would be a way to use Clojure somehow, even if it's just for your personal use.

13:12 technomancy: and I'd love that.

13:13 WizardofWestmarc: PLT is the only scheme I'd call useable, from what little experience I have w/it

13:13 cooldude127: gnuvince: it's not worth it !

13:13 gnuvince: Unfortunately, nobody has even heard of Haskell in Quebec

13:13 cooldude127: WizardofWestmarc: i think you're right

13:13 gnuvince: cooldude127: what would be worth "it"?

13:13 There are no pure Clojure jobs :)

13:13 WizardofWestmarc: yet at least.

13:13 cooldude127: make some :)

13:13 WizardofWestmarc: if it keeps taking off, who knows

13:13 technomancy: WizardofWestmarc: bus scheme is pretty awesome though

13:13 it's special in its own way

13:14 WizardofWestmarc: oh scheme in general is a very beautiful language

13:14 cooldude127: technomancy: the scheme that is written on the bus?

13:14 WizardofWestmarc: but the library situation is just... meh on anything but PLT

13:14 cooldude127: beautiful but not all that practical

13:14 gnuvince: I used Scheme for "The Little Schemer"

13:14 technomancy: cooldude127: yes

13:14 cooldude127: lol

13:14 gnuvince: It's nice, but not practical, like cooldude127 said.

13:14 The Little Schemer was really nice

13:14 technomancy: that book is one of my favourites

13:14 gnuvince: I have "The Seasoned Schemer" too, but haven't opened it yet.

13:14 cooldude127: i think clojure has a lot of the beauty of scheme, plus practicality

13:14 WizardofWestmarc: although I prefer lisp-1 over lisp-2, so that always drove me nuts when trying to work in CL

13:15 technomancy: gnuvince: heh; me too

13:15 WizardofWestmarc: and one of the reasons Clojure appealed to me so much when I first saw it.

13:15 gnuvince: How many here picked up Clojure because they thought "A Lisp that has access the the hugest library ever? Count me in!"

13:15 cooldude127: there is definitely a certain beauty in not quoting or sharp-quoting all your functions, especially when you're encouraged to pass them around

13:15 gnuvince: *to the

13:16 * WizardofWestmarc raises his hand.

13:16 * cooldude127 raises hand

13:16 technomancy: not me; for me it was "a lisp that corrects the errors of the past, but actually has enough momentum to really take off? sweet!"

13:16 jbondeson: it actually took me a while to get over my irrational hatred of java before i got into clojure

13:16 cooldude127: my biggest complaint with lisps has always been shitty libraries

13:16 WizardofWestmarc: that's an understatement jbondeson :P

13:16 cooldude127: / no libraries

13:16 WizardofWestmarc: how long ago did I try to get you to try it?

13:17 technomancy: jbondeson: yeah, java != jvm is an important prerequisite

13:17 cooldude127: and clojure fixed the last part right off the bat

13:17 gnuvince: Java was definitely off putting at first.

13:17 Chousuke: I still don't understand why functions live in their own namespace in common lisp :/

13:17 * cooldude127 uses clojure cuz rich hickey is such a good presenter

13:17 jbondeson: long time wiz... long time

13:17 gnuvince: Then you realize that there's no trace of checked exceptions anywhere

13:17 technomancy: WizardofWestmarc: there's plenty of libraries; they're all just for platforms that have been dead for 20 years

13:17 Chousuke: because otherwise you'll get them confused!

13:17 WizardofWestmarc: technomancy: fair enough, but to me that's same difference.

13:17 technomancy: yeah, it's a lame reason

13:18 WizardofWestmarc: yeah, if you want to connect to an SQL database you're in for a rough time, but you can be damn sure that all the filesystem access functions will work perfectly on VAX!

13:18 Chousuke: technomancy: only that? :/

13:18 WizardofWestmarc: haha VAX

13:18 when I first started my CS degree we were still on a VAX

13:18 and that was in '98

13:18 cooldude127: Chousuke: because otherwise unhygienic macros would be hell

13:19 technomancy: Chousuke: yep. because otherwise you have to name your list variables "lst" instead of "list"

13:19 cooldude127: clojure fixes it differently with syntax-quote

13:19 technomancy: and that.

13:19 jbondeson: great moments in lisp: "Why the hell is that named cdr/car?"

13:19 cooldude127: technomancy: only if you want to use the list function

13:19 technomancy: cooldude127: it's for your own good! (so they say)

13:19 cooldude127: jbondeson: it feels so natural now

13:19 lol

13:19 WizardofWestmarc: heh, I never even knew how to pronounce cdr until I watched some of the SICP lectures

13:20 cooldude127: WizardofWestmarc: same here!

13:20 could-er

13:20 jbondeson: yeah, i was a little dissapointed i couldn't do "caddr"

13:20 cooldude127: frrest?

13:20 jbondeson: not the same

13:20 just not the same...

13:20 cooldude127: lol

13:21 jbondeson: that's actually true. i had to think a little too much when writing that

13:21 brb guys

13:22 technomancy: every time I used caddr etc. I ended up regretting it a few days later. neat idea, but not so great in practice.

13:23 Chousuke: at least there's no magic to make them infinitely composeable.

13:23 just imagine cadddadadadddr or something

13:23 Cark: an emacs question : how can i kill an inferior-lisp process ?

13:24 technomancy: Chousuke: in bus scheme I used method_missing to allow for theoretically infinite c[ad]r calls

13:24 it was ridiculous

13:24 Cark: just kill the *inferior-lisp* buffer; should do the trick

13:24 Cark: thanks !

13:24 that was too obvious i guess =)

13:25 technomancy: well, only if you understand elisp's process model.

13:26 WizardofWestmarc: if it's clojure specific can also do (. System exit 0), but that leaves the actual buffer up in emacs, just kills the java process it's using

13:26 jbondeson: i used c[ad]r's all the time when i first started because i hadn't learned how to create decent data structure in lisp, so i just used lists for everything

13:29 technomancy: jbondeson: well to be fair lisp really does kind of encourage that

13:29 though through alists and plists rather than just regular linear lists

13:30 jbondeson: when i started clojure i had to realize that vectors do infact exist and even have use.

13:30 Lau_of_DK: Good evening gents

13:30 jbondeson: "What do you mean there are collections that aren't lists?"

13:32 gnuvince: jbondeson: hehe ;)

13:32 Chouser: they existed, you just couldn't use half the function library on them, right?

13:32 technomancy: plus there was only literal syntax for vectors

13:33 cooldude127: technomancy: what are we talking about?

13:33 WizardofWestmarc: vectors in CL

13:33 cooldude127: yuck

13:33 jbondeson: Chouser: yeah, they existed, but most CLs were so optimized for list processing you almost never used them

13:33 cooldude127: it was kinda like "what's the point?"

13:34 technomancy: well, they had better performance, so you were encouraged to write it first using lists, then rewrite it using vectors/hash tables once you figured out what you were doing and needed the speed.

13:34 gnuvince: That's the problem

13:34 technomancy: but the rewrite would be very hard since their behaviour was so different

13:34 jbondeson: yeah, and then most people didn't ;)

13:34 technomancy: heh

13:35 gnuvince: Beautiful code was usually slow because of the O(n) access time of lists, then you wanted to convert to vectors, but you needed to change everything about your program.

13:36 cooldude127: gnuvince: which is why clojure is awesome :)

13:37 gnuvince: It's one reason, yes :)

13:37 technomancy: it makes for good "when I was your age" stories though. =)

13:37 gnuvince: hahahaha

13:38 "When I was your age, we only had singly linked lists and we liked it!"

13:38 jbondeson: heh

13:56 gnuvince: after talking about lisp, and thinking about the minimizing calulation problem, i wonder if using refs and modifying metadata would be faster. the only thing that i worry about is the sync'ing overhead.

13:56 that would be like the decorating in CL

13:56 wonder if the sync would be shorter than all the seq creations/accessors

13:57 gnuvince: I'd rather not use a changing variable.

13:57 jbondeson: yeah.

13:57 you'd also have to undecorate, doubling the syncs

13:59 wonder how hard it would be to do some kind of memoization.

14:00 Chouser: (doc memoize)

14:00 clojurebot: Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use.; arglists ([f])

14:00 Chouser: I assume you don't mean anything quite that simple. :-)

14:01 bakkdoor: hi

14:02 jbondeson: i assume memoize drops the memos when you no longer reference the memoized function?

14:02 (way to many memos in that sentence)

14:02 +o

14:03 the problem would be that i'd have millions of calls to this, and i'd have to figure out how to keep memory use in check.

14:03 Chouser: yes, the fn returned by memoize closes over cache. Throw away the fn and the cache can be GC'ed

14:03 bakkdoor: i have a problem with tab completion with clojure in emacs & slime. i always get this error message: "Synchronous Lisp Evaluation aborted". maybe someone knows how to solve this?

14:04 jbondeson: clojurebox or did you get them separately?

14:04 Chouser: jbondeson: hm. yeah, sounds like you'd need a custom memoizer

14:05 bakkdoor: jbondeson: got them seperately. using ubuntu linux, got slime fresh via cvs, same for clojure (svn), swank-clojure & clojure-mode (github)

14:05 jbondeson: either that re-create the memoized function every generation since it's unlikely that two generations will have identical particles.

14:05 bakkdoor: compiling etc works fine

14:05 jbondeson: bakkdoor: when did you get clojure?

14:05 bakkdoor: just tab completion

14:06 yesterday or so

14:06 jbondeson: hmmmm.

14:06 duck1123: bakkdoor: I was getting something like that when all of the components weren't up to date

14:06 jbondeson: using any other emacs modes?

14:06 bakkdoor: haskell mode

14:06 i'll comment it out of my .emacs, ewait

14:06 jbondeson: i have that installed also, and haven't had any problems.

14:07 well... loaded, not installed

14:07 bakkdoor: i also use common lisp, but i've commented out all the cl related stuff and tell emacs to use the latest slime etc

14:08 is there a nice way to be able to use both (sbcl & clojure) with one slime installation?

14:08 i still get the same error message

14:08 WizardofWestmarc: should be able to w/different load commands at the very least

14:09 so you could use one m-x command to fire clojure, one for sbcl

14:09 though mine was broken last time I tried that, but pretty sure it was my fault, not emacs'

14:09 duck1123: bakkdoor: are you loading them in the right order? swank has to be loaded before slime

14:10 jbondeson: that shouldn't kill tabbing though

14:10 well... maybe

14:10 duck1123: it causes a whole bunch of odd problems

14:11 most notably the "progn" problem

14:11 technomancy: bakkdoor: I don't do CL, but I think Bill Clementson's blog is a good place to figure out how to configure slime for using both.

14:11 jbondeson: clojure-auto -> swank -> slime should be the correct order

14:11 bakkdoor: hm ok

14:12 i have it in that order

14:12 arbscht_: bakkdoor: there is, I'm running sbcl and clojure together right now, even

14:13 duck1123: isn't it something like M-- M-x slime

14:13 arbscht_: bakkdoor: you'll want to add your various lisps to slime-list-implementations

14:13 lisppaste8: bakkdoor pasted "clojure-slime" at http://paste.lisp.org/display/74038

14:13 bakkdoor: arbscht_: alright thanks

14:14 is my setup correct?

14:16 arbscht_: bakkdoor: C-h v slime-lisp-implementations

14:16 what is its current value?

14:17 bakkdoor: ((clojure

14:17 ("clojure")

14:17 :init swank-clojure-init))

14:17 arbscht_: right, so you want that to also contain an entry for sbcl

14:18 something like this should do it: (add-to-list 'slime-lisp-implementations '(sbcl ("sbcl")))

14:20 jbondeson: i really don't want to write a memoizer that's essentially a GC implementation =/

14:20 bakkdoor: arbscht_: alright, thanks.

14:21 the tab completion works for sbcl perfectly fine, just not for clojure

14:21 Chouser: jbondeson: a memoizer that throws away LRU values would be pretty general purpose and probably not too complicated

14:24 jbondeson: true.

14:27 Chouser: I guess LRU implies cache hits still require some kind of update. :-P

14:29 jbondeson: right, it would be slower, but if done carefully it wouldn't be too slow

14:29 or you could have some idea of generations, but then you're really getting into gc territory

14:31 WizardofWestmarc: How expensive is the generation of a memoized version of a function?

14:31 w/the built in function in clojure

14:31 Chouser: pretty cheap

14:31 jbondeson: well it has to cache the result and the args hashs

14:32 so slightly bigger than the returns

14:32 Chouser: calling memoize itself creates, I suppose, a closure object and an atom -- I think that's it.

14:32 jbondeson: looking at the code that looks correct.

14:33 though the other side effect is that it has a reference to the args, doesn't it?

14:34 hiredman: depends on what it uses to determine if one set of args is the same as another

14:34 Chouser: the returned closure has a reference to the function f -- is that waht you mean?

14:35 hiredman: Chouser: likes like the function args are used as a key in the hash

14:35 looks

14:36 jbondeson: right, so would that cound as a reference? seems that way to me.

14:36 hiredman: yes

14:36 Chouser: are we talking about the cost of creating the memoized function (i.e. calling 'memoize') or the overhead of calling the memoized function?

14:36 jbondeson: calling

14:37 hiredman: oh, I thought we were talking about side effects

14:37 cooldude127: omg cs class is learning about avl trees and red-black trees and head exploding AH

14:37 jbondeson: well

14:37 Chouser: I thought WizardofWestmarc was asking about calling 'memoize'

14:37 jbondeson: the side effects from calling

14:37 WizardofWestmarc: I asked that part

14:37 he switched topic ;)

14:37 hiredman: dunno, I just got here and saw jbondeson ask about side effects

14:37 jbondeson: i'm good at that.

14:38 Chouser: on a cache hit, there is no side-effect. the overhead is probably dominated by a single hash lookup

14:39 jbondeson: i was just thinking about what memoize does to your memory when called.

14:39 Chouser: oh, yes, each cached item has the args as a map key and the return value as a map value.

14:40 so a memory-heavy arg would use up a lot of memory when cached.

14:41 WizardofWestmarc: If it were something like a hash itself that you were passing in, which was stored already via another def, wouldn't it just share the reference?

14:45 meredydd: jbondeson: Is there a reason you wouldn't just borrow the Java GC interfaces?

14:45 That sort of application is what WeakHashMap was born for.

14:47 jbondeson: that looks promising. I'm not super familiar with the Java libraries so I had no idea that existed.

14:50 course a fixed size memoizer would be useful as well.

14:50 technomancy: cooldude127: did you end up trying the starter kit?

14:51 cooldude127: technomancy: no, but i regularly steal from it

14:51 :)

14:51 technomancy: cool.

14:51 duck1123: a large portion of my .emacs has been stolen from technomancy

14:51 cooldude127: there's too much of my own custom stuff in mine

14:51 technomancy: cooldude127: it's a little awkward to adapt an existing config to use the starter kit, for sure. but you can just toss your stuff in the user-specific-dir and it might work.

14:51 I should document that

14:52 cooldude127: technomancy: do it, i might fork you and do that

14:52 technomancy: well, the documentation would be something like "just put everything you had in .emacs.d into starter-kit/$USER/

14:52 "

14:52 cooldude127: lol

14:53 technomancy: well, i know what i'm doing tonight. converting my emacs setup to use emacs-starter-kit

14:53 :)

14:53 technomancy: the only potential problems you might have would be package conflicts

14:53 heh

14:53 cooldude127: technomancy: i'm using a lot of the same packages you are

14:53 technomancy: might have better luck if you do it while I'm still online. =)

14:54 cooldude127: well i'm in class, which is almost over, after which i will head home and do it

14:54 you'll probably still be online?

14:54 technomancy: till 5pm PST

14:54 should probably keep it in #emacs though; wups

14:54 cooldude127: 8pm EST? yeah

14:54 i'll be there in a little while if i have problems

14:58 jbondeson: hmmm... to make the WeakHashMap really useful i'll probably have to wrap it and implement Associative

15:05 hiredman: clojurebot: ping?

15:05 clojurebot: PONG!

15:06 jbondeson: i see you fixed him up last night

15:07 hiredman: and now its dispatcher uses a priority queue

15:07 jbondeson: next he'll ask for a salary

15:08 hiredman: previously it just when down a list trying each entry fifo style

15:08 durka42: did the contents of his brain survive?

15:09 LordOfTheNoobs: They aren't file backed. It's just a couple of hashes.

15:10 hiredman: durka42: yes

15:10 durka42: wait, those answers seem contradictory

15:10 LordOfTheNoobs: ? When I look at the source it didn't look like it was saving them. My mistake.

15:10 durka42: clojurebot: examples?

15:10 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

15:10 hiredman: the change was to the function that does the dispatch in determining if you are asking it to run code or if you are looking up "examples"

15:11 LordOfTheNoobs: the hashes are written to disk every five or ten minutes

15:11 jbondeson: that was from before the meltdown, so he survived

15:11 hiredman: clojurebot: latest?

15:11 clojurebot: latest is 1223

15:12 LordOfTheNoobs: looky there. http://github.com/hiredman/clojurebot/blob/466d0bd69d507bf517a784fb8c38ab31a849ed3f/hiredman/clojurebot/core.clj#L404

15:12 hiredman: neat

15:12 did nae realize github could like right a certain line

15:28 * technomancy reads up on streams

15:30 Lau_of_DK: Where are you reading?

15:30 technomancy: just http://clojure.org/streams

15:30 then the ML

15:34 Lau_of_DK: kthxbye

15:54 All you scrum fans, if you know how many units youve burned in the first 2 - 10 days of a sprint, input them like "200 195 180 172 165" and this will render a burn-down chart: http://gist.github.com/50711

16:01 hiredman: clojurebot: group?

16:01 clojurebot: group is http://groups.google.com/group/clojure/

16:01 hiredman: http://groups.google.com/group/clojure/

16:03 whoops

16:03 jbondeson: goodnight sweet prince!

16:04 Lau_of_DK: I didnt get this from the stream-document on Clojure.com, but is filter* fully lazy as well?

16:12 hiredman: ,(identity java.net.URLEncode)

16:12 clojurebot: java.lang.ClassNotFoundException: java.net.URLEncode

16:12 hiredman: lame

16:12 oh

16:12 ,(identity java.net.URLEncoder)

16:12 clojurebot: java.net.URLEncoder

16:14 hiredman: http://groups.google.com/group/clojure/

16:15 hmmm

16:20 http://groups.google.com/group/clojure/

16:20 :D

16:21 kotarak: hiredman: \o/

16:21 Chouser: whoa, he's purple

16:22 hiredman: it's a NOTICE

16:23 Chouser: huh. Never used that.

16:23 hiredman: most don't

16:23 it will make tinyurls of urls it sees that are over 30 characters

16:24 Chouser: why use notice? just curious.

16:24 hiredman: you can ignore notices seperately from other stuff

16:25 Chouser: ah! good to know.

16:25 hiredman: and the only other bot I've seen do tinyurls does it with notice

16:25 durka42: kotarak: did you ever crash-test my smuggler?

16:26 hiredman: Chouser: does it bother you?

16:26 kotarak: durka42: not yet. I had a brief look at it, but an unexpected business trip took me half of the week.

16:26 durka42: Will have a look over the week-end, though.

16:27 durka42: when you have time

16:27 Chouser: hiredman: nope, not at all.

16:28 durka42: i should write a readme

16:28 hiredman: Chouser: if starts to, let me know

16:30 eyeris: I am trying to add LIMIT support to ClojureQL but I am having difficulty understanding the multi-methods used. Could someone take a look at this and tell me what I am missing? http://pastebin.ca/1315684 (disclaimer: I'm a complete lisp newb)

16:33 Lau_of_DK: Hi eyeris

16:33 eyeris: Hi!

16:33 Lau_of_DK: Sorry I didnt get back to you sooner regarding limits

16:33 eyeris: Np

16:33 I figured it was a good opportunity to learn

16:34 Lau_of_DK: Cool, I look forward to your contribution

16:34 Are you trying to set ::LimitSelected as the default dispatch?

16:36 kotarak: What problem do you have?

16:36 eyeris: I think that's what I don't understand.

16:36 kotarak: eyeris: ???

16:37 Doesn't it do what you want?

16:37 eyeris: The documentation for multi-methods made me think that there should only be one method for each default with a :default dispatch

16:37 kotarak: The :default is for the db argument.

16:38 eyeris: Okay.

16:38 kotarak: It may be used to provide specialised methods for different DBs, like derby or MySQL.

16:38 eyeris: I see.

16:38 kotarak: It's currently unused.

16:38 eyeris: And that is why they all use :default for the DB, because right now there is no need to have something like ::MySQL or ::SQLite

16:38 Lau_of_DK: eyeris: Maybe you should consider implementing limit as a wrapper similar to Union in the frontend instead?

16:40 eyeris: I am doing that.

16:41 kotarak: Hmm...

16:41 It should work.

16:41 eyeris: http://pastebin.ca/1315696

16:41 kotarak: What happens when you call execute-sql directly on your statement?

16:41 eyeris: That is how I implemeted the limit wrapper

16:42 Lau_of_DK: You doc limit* as a driver for order-by? :)

16:42 eyeris: I've derived LimitedSelect from Select. Perhaps I need to derive it from ExecuteQuery?

16:42 Haha, stupid copy/paste :)

16:42 kotarak: limit should be function, no macro.

16:43 So rename limit* to limit and leave a away the macro.

16:43 Lau_of_DK: eyeris: kotarak is german, so let me rephrase "So I recommend that you rename limit* to limit*, then you can do away with the macro"

16:43 kotarak: But that is a detail.

16:44 eyeris: Right, limit isn't doing anything other than calling limit*.

16:44 kotarak: eyeris: what happens when you call execute-sql directly on your statement directly in the repl.

16:44 eyeris: So it's pointless to use it.

16:44 kotarak I will try that. Hold.

16:46 I get the same exception: No method for dispatch value: [:dk.bestinclass.clojureql/Execute nil]

16:47 Lau_of_DK: Execute?

16:47 Weren't you dispatching on :type ::LimitSelect ?

16:49 kotarak: Execute seems strange.

16:49 Doh.

16:49 My fault

16:49 I meant compile-sql instead of execute-sql.

16:49 eyeris: Right, if I change (derive ::Select ::ExecuteQuery) to (derive ::Select ::Execute) it tries to dispatch on ::LimitedSelect

16:49 Oh, :)

16:50 kotarak: LimitedSelect should derive from Select

16:52 eyeris: No method for dispatch value: [:dk.bestinclass.clojureql/LimitedSelect nil]

16:53 kotarak: hmmm

16:54 Lau_of_DK: eyeris: And which expression did you evaluate to get that error?

16:56 eyeris: (sql/compile-sql (sql/limit (sql/query ID p9662) 2) nil)

16:57 kotarak: And you patched the clojureql source directly? So the defmethod for LimitedSelect is in backend.clj?

16:58 eyeris: That is correct.

16:58 Lau_of_DK: eyeris: I have to duck out now, will be back for heavy coding saturnight if you need more assitance, otherwise Im sure kotarak will love to help out :)

16:59 eyeris: Okay

16:59 kotarak: hehe, Lau_of_DK - the Delegator! ;)

16:59 WizardofWestmarc: best way to get anything done, hand it off to someone else

17:01 kotarak: eyeris: ok. I'm stuck.

17:01 eyeris: I am going to re-clone the repo and try to do this again.

17:02 durka42: readme written.

17:11 eyeris: kotarak here is a patch of my changes http://drew.intercarve.net/tmp/limit.patch.txt

17:11 That should make it more clear what I've done.

17:12 kotarak: eyeris: ok. Let me try here.

17:13 eyeris: This is what I get if I print out the AST generated by sql/limit:

17:13 "{:type :dk.bestinclass.clojureql/LimitedSelect, :query {:type :dk.bestinclass.clojureql/Select, :columns [ID], :tables [\"p9662\"], :predicates nil, :column-aliases {}, :table-aliases {}, :env nil}, :limit 2, :env nil}"

17:14 That is what I expect it to print out.

17:14 kotarak: Looks good.

17:16 Argh. I'm stupid.

17:17 eyeris: Ok. Stupid mistake on my side. I shouldn't change this around midnight...

17:29 _hrrld: Is it possible to express dependency on external .jar files from within a .clj file? Similar to Ruby's require or Python's import?

17:29 technomancy: _hrrld: how external?

17:29 hiredman: import

17:29 kotarak: or require

17:29 hiredman: ^-

17:29 eyeris: kotarak What was your mistake?

17:30 scottj: _hrrld: do you mean without having it in your classpath?

17:30 technomancy: _hrrld: import for Java classes; require/use for clj files.

17:30 _hrrld: Yeah, it seems my slime repl cant find the .jar

17:30 hiredman: they express dependency on a class or namespace in a jar

17:30 _hrrld: or isn't using it, or something. (Apologies that I'm a java newb)

17:30 technomancy: _hrrld: you can use add-classpath too

17:30 kotarak: eyeris: [bla :default] is wrong. The default dispatch value is for the whole vector.

17:31 hiredman: _hrrld: (System/getProperty "java.class.path")

17:31 technomancy: _hrrld: did you set swank-clojure-extra-classpaths *before* starting slime?

17:31 kotarak: eyeris: I have to introduce ::AnyDB from which all the DBs derive.

17:32 eyeris: _hrrld I (require a.b.c) is like Python's import a.b.c but instead of calling c.d() as you would in python, you call (c/d ...)

17:32 _hrrld: technomancy: I don't want to have to do that, I want the dependency expressed in the clojure code which consumes it. add-classpath seems to be what I was looking for, I'll experiment with it.

17:32 hiredman: No!

17:32 eyeris: _hrrld On the other hand, (use a.b.c) is like python's from a.b.c import *.

17:32 hiredman: don't use add-classpath

17:32 technomancy: _hrrld: yeah, keeping it in the code is the Right Thing to Do as far as I'm concerned, but I guess there are some issues with it?

17:32 hiredman: add-classpath is icky

17:32 technomancy: _hrrld: it's the only way to keep DRY unfortunately.

17:33 eyeris: kotarak Ahh! Thanks! I will watch for those changes.

17:33 For now I have to run.

17:33 technomancy: hiredman: duplicating your classpath in three separate places is icky too

17:33 kotarak: eyeris: ok. bye

17:33 eyeris: Thanks for helping me track down my problem.

17:33 kotarak: np

17:33 hiredman: technomancy: then don't

17:33 scottj: hiredman: does add-classpath even work?

17:33 hiredman: scottj: dunno, I don't use it

17:34 technomancy: scottj: it works great for clj files; I haven't used it for external jars since rhickey fixed it.

17:34 hiredman: I still haven't heard any reasons for avoiding it that make sense

17:35 hiredman: technomancy: you may as well just load-file external .clj files

17:35 technomancy: that doesn't honor the load-once policy that require has

17:36 hiredman: 2008:Nov:22:08:53:31 rhickey add-classpath is only for repl

17:36 2008:Nov:13:06:35:15 rhickey add-classpath is really just for repl emergencies, want to try a new lib without restarting etc. Once you know you need a lib, out it in your real classpath

17:36 * technomancy waits for a reason

17:37 _hrrld: That's all very interesting. So what do people do? Have custom emacs-lisp code that diddles swank-clojure-extra-classpaths?

17:38 hiredman: _hrrld: I just put the jars I need in the classpath

17:38 technomancy: _hrrld: for a while I was just saying "you have to launch this via SLIME" because I wanted to have the classpath declared in only one place

17:38 but that clearly sucks

17:39 _hrrld: I don't know much about .jar files. Is there a way to merge them or something?

17:39 technomancy: _hrrld: for learning I'd recommend a project that doesn't require any external jars (besides contrib) because you'll waste more time fighting with the classpath than actually learning.

17:40 it doesn't really make a lot of sense

17:41 kotarak: _hrrld: jar files are "just" zip files.

17:41 you can look inside, by simply unzipping them.

17:42 _hrrld: Woah, neat! Can I just stuff more classes in here?

17:43 technomancy: _hrrld: probably not a good idea in most cases; if you see a file named jetty-1.4.jar you want to be able to assume the contents match the name.

17:43 hiredman: 2008:Nov:29:17:46:03 rhickey dynamically loaded classes must be loaded from a custom classloader, which creates all kinds of difficulties in certain hosting environments

17:43 Chouser: well, they're zip files with a mit of extra meta-data

17:43 bit

17:43 technomancy: but... obviously I don't understand the classpath; don't listen to me

17:43 scottj: _hrrld: you can just include all the jars you use in slime and then have a startup script for when you use the program outside slime

17:44 _hrrld: scottj: This is what's typically done?

17:44 technomancy: scottj: bzzzt! DRY violation; 15-yard penalty.

17:44 Chouser: for applets, I've been unpacking clojure.jar, sprinkling in all the other classes I need, and packaging up a single my-applet.jar -- dunno if that's Right or not, but it seems to work.

17:45 scottj: _hrrld: I don't know what others do. I don't use that slime classpath variable anymore, but instead have some elisp that creates the slime-lisp-implementations that I want. (C-h v slime-lisp-implementations to see how your classpath is included there)

17:46 kotarak: _hrrld: look for a launcher, eg. on github or in contrib. They use a directory, where you simply drop all your jars and they are automatically added to your classpath. Never ever had a single problem with that scheme.

17:46 hiredman: clojurebot: jar directory?

17:46 clojurebot: jar directory is -Djava.ext.dirs=$LIBS

17:46 kotarak: This is evil is I understood.

17:46 hiredman: now, that can create some problems

17:46 technomancy: ah, actually just globbing a directory is way better than maintaining separate lists.

17:47 you could build up the swank-clojure-extra-classpaths list in elisp easily enough

17:47 oh! they finally added a launcher to contrib; sweet.

17:48 needs to be in core, but it's a start

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

17:48 clojurebot: Ok.

17:49 hiredman: technomancy: internally swank-clojure seems to glob up the .clojure/ dir for jars and add them to the classpath

17:50 technomancy: hiredman: I wonder if that's wise to rely on since others can check out your project and have a totally different ~/.clojure directory.

17:50 _hrrld: Chouser: re-packing the .jar with the .class files from the dependency worked. That's cute.

17:51 hiredman: technomancy: that is just swank-clojure

17:51 I am saying "hey you can steal elisp code from there for globbing jars"

17:51 technomancy: hiredman: oh, sure; gotcha.

17:52 hiredman: I would recommend against doing it with elisp, because not everyone runs ElispOS

17:52 technomancy: hiredman: right, you would have to ensure that the shell script did the same thing.

17:52 hiredman: the most platform agnostic way is "this code depends on these jar files, make sure they are in your classpath"

17:53 technomancy: repeating the "use everything in this dir" notion is a lot more acceptable than repeating "here is a list of jars" in several locations in your codebase

17:54 hiredman: I don't really like the notion of projects shipping out with there own jar directories

17:54 I think it is fine to just say "this depends on version X of jetty being in the classpath"

17:55 technomancy: hiredman: well sure; it's a substitute for a real package manager.

17:55 if you had a package manager you wouldn't have to bundle everything; you could just declare the dependencies and they could be fetched automatically

17:57 hiredman: clojurebot: ties?

17:57 clojurebot: ties is http://www.bitbucket.org/achimpassen/clojure-ties/wiki/Home

17:57 technomancy: right. =)

17:57 hiredman: which is icky

17:57 entirely too maven for me

17:58 technomancy: yeah, I'm not a maven fan at all, but I can see the value of bootstrapping off it.

17:58 hiredman: :(

17:58 anyway, stop using add-classpath

17:58 :P

17:58 technomancy: ok ok... but I'm still going to glob a jars/ directory

17:59 you can't stop me!

17:59 unless you write an awesome package manager.

17:59 hiredman: technomancy: I like how ring does it

17:59 technomancy: how's that?

17:59 hiredman: clojurebot: ring?

17:59 clojurebot: ring is http://github.com/mmcgrana/ring/tree/master

18:00 hiredman: All jars needed to load any of the ring.* libs are included in the jars/ directory. You only need Java. To see a live "Hello World" Ring app, simply run:

18:00 java -Djava.ext.dirs=jars clojure.main src/ring/examples/hello_world.clj

18:00 very simple, flexible, and amendable

18:00 technomancy: I thought you didn't like the jars directory?

18:01 hiredman: I like that way better then the compojure way, which last I checked was to provide jars and a launcher script

18:01 (which globbed the jars)

18:01 technomancy: oh, gotcha

18:01 hiredman: that is just a simple java command line, which I can easily understand and warp to my wims

18:01 arbscht_: compojure doesn't do that anymore, iirc

18:02 hiredman: good

18:02 technomancy: oh, so the implication is that this is just a starting point, whereas with compojure it's "what you should use"

18:02 s/it's/it was/

18:31 Azmodan: How do you do the equivalent of the python ", ".join(some_list) in Clojure?

18:32 gnuvince_: Azmodan: there's a str-join function in clojure.contrib.str-utils

18:32 Chouser: ,(apply str (interpose "," (range 5)))

18:32 clojurebot: "0,1,2,3,4"

18:32 Azmodan: I didn't look at contrib yet, what is it?

18:32 hiredman: that depends

18:33 (doc interpose)

18:33 clojurebot: Returns a lazy seq of the elements of coll separated by sep; arglists ([sep coll])

18:33 dreish: It's a quasi-standard library.

18:33 hiredman: hmmm

18:33 gnuvince_: Azmodan: a collection of useful modules.

18:33 hiredman: and all this time I have been dicking around with interleave

18:34 gnuvince_: ,(str-join ", " ["hello", "world", "foo"])

18:34 clojurebot: java.lang.Exception: Unable to resolve symbol: str-join in this context

18:34 gnuvince_: ,(clojure.contrib.str-utils/str-join ", " ["hello", "world", "foo"])

18:34 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.str-utils

18:34 gnuvince_: meh

18:36 Azmodan: I figured out the str and interpose part but I was stuck with a seq and not a string. Apply fixed this but I'm not sure what it does exactly.

18:37 Chouser: ,(require '[clojure.contrib.str-utils :as str-utils])

18:37 clojurebot: nil

18:37 Chouser: ,(str-utils/str-join ", " (range 3))

18:37 clojurebot: "0, 1, 2"

18:37 Chouser: Azmodan: (apply str 1 2 [3 4 5]) is the same as (str 1 2 3 4 5)

18:37 hiredman: (doc apply)

18:37 clojurebot: Applies fn f to the argument list formed by prepending args to argseq.; arglists ([f args* argseq])

18:37 Chouser: apply unpacks the final list

18:39 Azmodan: So the point of apply is to unpack final lists?

18:39 hiredman: string utils must have a (partial apply str)

18:41 gnuvince_: Azmodan: yes

19:35 felzix: how do I import a library into clojure?

19:35 for instance, using contrib's expt function

19:35 Chouser: first make sure that clojure-contrib/src or clojure-contrib.jar is in your Java classpath

19:36 then use 'require' or 'use', like this:

19:36 (require '[clojure.contrib.math :as math])

19:37 felzix: awesome, thank you!

19:38 Chouser: now you have an alias for that namespace as 'math', so you can use expt like: (math/expt 2 10)

19:38 np

19:40 danlarkin: how does cygnus sound as a name for my soon-to-be-released web framework, lame?

19:40 thinking of names is so hard!

19:40 durka42: what's the derivation of cygnus

19:41 technomancy: danlarkin: makes me thing of cygwin

19:42 naming *is* hard.

19:42 danlarkin: well Cygnus X-1 is a song by progressive rock band Rush

19:42 technomancy: isn't that the name of a rocket or something?

19:42 danlarkin: yes

19:42 technomancy: I like to use names that come from computing history

19:43 rockets and computing were pretty closely related back in the day

19:43 danlarkin: it's got a very interesting back story

19:43 http://en.wikipedia.org/wiki/Cygnus_X-1_duology

19:44 technomancy: danlarkin: unfortunately in the realm of software there's already http://en.wikipedia.org/wiki/Cygnus_Solutions

19:44 danlarkin: oh, damn

19:44 and they make cygwin... well there goes that idea

19:45 durka42: they don't quite exist any more

19:45 technomancy: yeah, merged with redhat

19:45 but it still makes me think of cygwin

19:45 durka42: yeah

19:46 technomancy: clojurebot: slime?

19:46 clojurebot: It's greek to me.

19:46 danlarkin: and there's always Xanadu, another (fantastic) song by Rush, but the wikipedia disambiguation page for Xanadu is already huge

19:47 durka42: clojurebot: slime is icky

19:47 clojurebot: Ack. Ack.

19:47 technomancy: clojurebot: slime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72

19:47 clojurebot: Ack. Ack.

19:47 durka42: oh, cool

19:47 technomancy: danlarkin: right, Ted Nelson's The Web Done Right; heh

19:48 would appreciate testers for that slime-install script. needs a bit more polishing; then could be mainlined into clojure-mode

19:49 durka42: this script doesn't take care of .emacs, does it?

19:50 or you just call esk-clojure from .emacs

19:50 technomancy: durka42: that's right

19:50 since it needs an argument for where clojure is installed

19:50 the perils of dealing with manually installed software. =\

19:53 danlarkin: now I'm curious about this song; sounds interesting.

19:53 or songs

19:53 danlarkin: technomancy: you've never listened to rush? oh gosh! do you like progressive rock at all?

19:53 technomancy: if not, then you might not enjoy it

19:53 technomancy: maybe... I'm not sure quite what it entails.

19:54 I've heard some Dream Theater; really liked some of that, some of it not so much.

19:56 I do really enjoy albums that are a cohesive story if they're done right.

19:58 danlarkin: here's a good example of their musical virtuosity: http://www.youtube.com/watch?v=me6BXzOUNuo

19:59 clojurebot: that's annoying

19:59 clojurebot: I don't understand.

19:59 hiredman: annoying like, it should for longer urls do it?

19:59 technomancy: at least the length limit should be boosted

20:00 hiredman: what is a good url character length threshold?

20:00 right now it fires at 30

20:00 technomancy: I'd say 70 minus average nick length?

20:01 * hiredman sets it at 60

20:01 danlarkin: http://www..com/ is 16... so I think 30 is really pushing it

20:03 hiredman: makes me said, I like watching it go

20:06 danlarkin: how about.... syrinx

20:06 gnuvince_: Why do we even need tinyurl?

20:06 Just click on the link

20:36 With Slime, I tried adding a path to swank-clojure-extra-classpaths, but when I run M-x slime, I don't have the new path in (System/getProperty "java.class.path"). Anyone knows what's up with that?

20:40 Chouser: hiredman: if you could figure out how to replace long urls with short ones, rather than both being posted -- now that would be nice.

20:43 danlarkin: aka impossible :)

20:45 durka42: gnuvince: i wonder if this is related to my problem yesterday with add-classpath?

20:45 unfortunately i can't stay to find out :(

20:52 shoover`: why do we have both replicate and repeat? couldn't we have just one with varied arity?

20:54 cooldude127: shoover`: i have a feeling you are right about that

20:54 shoover`: there's gotta be a reason. I want to know it

20:55 cooldude127: shoover`: maybe we don't like mixing functions that make infinite seqs and once that end

20:56 shoover`: mmm... interleave and map both can be infinite or not depending on their args

20:56 cooldude127: idk then

20:57 shoover`: you had me for a sec ;)

20:57 cooldude127: lol i'm pulling it out of my ass :)

21:18 hiredman: if no one wants the tinyurl feature I will disable it

21:26 cooldude127: hiredman: is it problematic?

21:26 danlarkin: I think it's unnecessary

21:27 cooldude127: probably

21:27 tinyurl is more useful for before you paste it into irc

21:27 :)

21:59 jamesnvc: Hello

22:00 I think this has been asked before, but what do I need to do to use javax.swing in clojure programs?

22:00 Chouser: nothing special

22:00 jamesnvc: Hrm...

22:00 What jar is it in?

22:01 Chouser: builtin

22:01 http://clojure.org/jvm_hosted

22:01 jamesnvc: I'm not too familiar with Java classpath stuff

22:01 Hrm

22:01 Chouser: nice little example there to get you started

22:02 jamesnvc: Heh...I see what I did wrong

22:02 I didn't quote the list of libraries

22:02 Chouser: ah

22:02 jamesnvc: Mea culpa

22:02 Thanks for the link :D

22:02 gnuvince_: Is it possible with to-array to specify the type of array?

22:02 hiredman: ,(doc to-array)

22:02 clojurebot: "([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."

22:02 Chouser: you could also use (ns foo (:import ...)) in which case you don't need to quote the args

22:03 hiredman: ,(doc make-array)

22:03 clojurebot: "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

22:03 Chouser: (doc into-array)

22:03 clojurebot: Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE.; arglists ([aseq] [type aseq])

22:03 hiredman: ^- that is what i meant

22:06 gnuvince_: Chouser: thanks

22:18 Azmodan: I have a seq with data that fit a predicate function and other data that doesn't. I want to split it into two. Is there a more effective way than to use filter twice?

22:19 Cark: how about using reduce ?

22:21 gnuvince_: ,(require '[clojure.contrib.seq-utils :as seq-utils])

22:21 clojurebot: nil

22:21 gnuvince_: ,(seq-utils/partition odd? [1 2 3 4])

22:21 clojurebot: java.lang.Exception: No such var: seq-utils/partition

22:21 Azmodan: Cark: That'd give me only one value in the end.

22:22 gnuvince_: ,(seq-utils/separate odd? [1 2 3 4])

22:22 clojurebot: [(1 3) (2 4)]

22:22 gnuvince_: Azmodan: behold

22:22 Azmodan: Oooh. Nifty :)

22:23 Where's the contrib api webpage?

22:23 Cark: ,(reduce (fn [[left right] item] (if (odd? item) [(conj left item) right] [left (conj right item)])) [[] []] '(1 2 3 4 5 6))

22:23 clojurebot: [[1 3 5] [2 4 6]]

22:23 Cark: but yeah using the contrib might be easier =P

22:25 gnuvince_: ,clojure contrib?

22:25 Cark: now for extra credit, do a lazy version =/

22:25 gnuvince_: ,contrib?

22:25 meh

22:26 Azmodan: http://code.google.com/p/clojure-contrib/

22:26 Cark: clojurebot: contrib?

22:26 clojurebot: contrib is http://code.google.com/p/clojure-contrib/

22:26 gnuvince_: ah

22:27 Cark: hum the contrib separate is doing 2 filters =P

22:28 hiredman: Azmodan: the "one value" reduce gives you at the end can be a vector, or whatever

22:34 gnuvince_: Weird problem guys

22:34 (defn null-string [buf len] (reduce #(conj %1 (.getByte buf)) [] (range len)))

22:35 When I call this with (null-string abuf 10), I get an error that I am passing the wrong number of parameters

22:35 Bug?

22:35 hiredman: you are passing the wrong number of args to the #()

22:35 gnuvince_: how so?

22:36 Cark: ,(doc reduce)

22:36 clojurebot: "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, return

22:36 gnuvince_: I absolutely need to refer to %2?

22:36 hiredman: unless the #() has a %2 in it, it only expects 1 arg

22:36 Cark: f should be a function of 2 arguments

22:36 hiredman: yes

22:36 clojurebot: #()?

22:36 clojurebot: #() is not a replacement for fn

22:36 gnuvince_: ok

22:37 Switching to a fn works

22:37 Thanks

22:37 yangsx: Has anyone defined with-open-file aka CL in Clojure?

22:37 Cark: ,(doc with-open)

22:37 clojurebot: "([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order."

22:37 Chouser: or #(do %2 (conj ...)) ...but that's kinda gross

22:37 Cark: not quite the same though

22:37 gnuvince_: Chouser: I'd rather use (fn [acc _] ...)

22:37 Chouser: gnuvince_: yeah

22:37 good

22:38 yangsx: Cark: It seems to me with-open is more like unwind-protect

22:38 Cark: not quite, it calls a close method on the bound objects

22:38 usually streams

22:39 hiredman: #(conj (K %2 %) (.getByte buf))

22:39 Azmodan: Can you tell me why this function gives me a stackoverflow: http://paste.pocoo.org/show/100929/

22:39 hiredman: but clojure.core does not have K

22:39 oh

22:39 damn

22:40 #(conj ((K %2) %) (.getByte buf))

22:40 Cark: yangsx : (with-open [stream (FileReader. "~/test.txt")] (dosomething))

22:40 hiredman: still wrong, forget it

22:40 Azmodan: you need '() not ()

22:41 I think

22:41 ,((? [] ()))

22:41 clojurebot: java.lang.Exception: Unable to resolve symbol: ? in this context

22:41 hiredman: ,((fn [] ()))

22:41 clojurebot: ()

22:42 hiredman: ,(conj ((fn [] ())) :a)

22:42 clojurebot: (:a)

22:42 hiredman: guess not

22:42 Chouser: Azmodan: there's no termination case for your recursion

22:43 Azmodan: Chouser: I thought the ([] ()) part was my termination case.

22:43 Chouser: ah, I see. that will be called if you call (qsort), that is with no args

22:44 Azmodan: oops... I see my mistake.

22:44 Chouser: but if you pass in an empty coll, it still calls your main body

22:45 Azmodan: Yeah, I was thinking Haskell-like I guess.

22:45 * Chouser nods

22:45 Azmodan: I'll change that to an if.

22:45 Chouser: or a when

22:45 yangsx: Cark: thanks, I need output to file. BTW, I felt programming in Clojure so far requires intimate knowledge of Java, sometimes a block to people like me from CL (instead of Java)

22:46 Cark: yangx : i'm coming from cl as well, java is a royal pain =P, but the docs are good

22:46 Azmodan: Thanks

22:46 gnuvince_: hmmm

22:47 Chouser: yangsx: knowledge of the Java libs more than Java itself I think

22:47 Cark: right

22:47 gnuvince_: Anyone knows why (java.nio.ByteBuffer/wrap (into-array Byte/TYPE (map byte [1,2,3]))) returns a java.nio.HeapByteBuffer instead of a java.nio.ByteBuffer?

22:47 WizardofWestmarc: well you need to know about stuff like classpath too

22:47 Chouser: and the file io stuff is particularly more complicated than necessary.

22:48 yangsx: I like clojure.contrib.duck-streams

22:48 Cark: chouser : i don't think so

22:48 it allows to fine tune for exactly what you want

22:48 Chouser: Cark: "it"?

22:48 Cark: the io stuff

22:49 streams

22:49 Chouser: oh

22:49 yangsx: Chouser: I have attemped to use write-lines, but found it not as general as with-open-file for IO stuff

22:50 Chouser: yangsx: hm... I believe we may have had this conversation before.

22:53 yangsx: Chouser: rant about java, yes; but not with-open-file

22:55 Chouser: anyway, you can pick -- duck-streams often does what you want with very little effort. If you want effort, combine java classes to your hearts content.

22:56 Cark: aint that pretty ? (with-open [reader (-> filename FileInputStream. (event-input-stream callback) InputStreamReader. BufferedReader.)])

22:57 that's from my csv-import dialog =P

22:57 jbondeson: any way to get compile to give me a little more information? it's saying "ClassNotFoundException" and pointing to a like that only has "dosync" on it...

22:57 yangsx: Chouser: yes, that's the way to go so far. I asked just in case someone has met and solved the same problem.

22:58 jbondeson: and naturally the class name is a generated one

22:58 hiredman: gnuvince_: the javadoc for ByteBuffer seems to indicate it is an abstract class

22:59 jbondeson: and naturally it works in the repl

23:00 hiredman: do you have ./classes/ in your classpath?

23:00 is the namespace you are compiling in your classpath?

23:01 gnuvince_: hiredman: an abstract class is one that can have no instances, only concrete subclasses, right?

23:01 hiredman: gnuvince_: that sounds right

23:03 jbondeson: ./classes/ may not be.

23:04 hiredman: clojurebot: compiling?

23:04 clojurebot: No entiendo

23:04 hiredman: clojurebot: compie?

23:04 clojurebot: excusez-moi

23:04 hiredman: clojurebot: compile?

23:04 clojurebot: I don't understand.

23:05 hiredman: http://clojure.org/compilation

23:06 jbondeson: and still getting it =/

23:07 hiredman: what is the exact error

23:07 jbondeson: java.lang.RuntimeException: java.lang.ClassNotFoundException: messenger.core$push_message__98$fn__100$fn__102 (core.clj:23)

23:08 it looks like the first anonymous function

23:08 hiredman: interesting

23:09 what is the value of *compile-path

23:09 what is the value of *compile-path*

23:09 jbondeson: classes, but i'm rooted in the correct directory

23:09 hiredman: how are you starting clojure?

23:10 jbondeson: batch file right now, had the same error in emacs/slime though

23:11 hiredman: give me the exact line you use to start clojure

23:11 man

23:12 pulling teeth like this I could have been a dentist

23:12 lisppaste8: jbondeson pasted "startup" at http://paste.lisp.org/display/74065

23:13 hiredman: ./classes/ is not in your classpath

23:13 jbondeson: did an add-classpath

23:14 however, i can try to explicitly set it

23:14 cataska: does anyone tried clojure on android ?

23:14 hiredman: jbondeson: add-classpath is bad, avoid it

23:14 Chouser: cataska: yep, there's been a "hello world" app

23:15 cataska: Chouser: links, pls :)

23:15 hiredman: clojurebot: add-classpath is bad, avoid it. I mean it!

23:15 clojurebot: 'Sea, mhuise.

23:15 jbondeson: avoiding away!

23:16 cataska: so clojure must generate dalvik byte-code ?

23:16 hiredman: I imagine it uses clojure's AOT to generate class files and then you run the converter to dalvik byte-code

23:17 Chouser: cataska: no, clojure generates JVM bytecode in .class files, and then the normal android toolchain takes over

23:17 hiredman: right

23:17 cataska: ok i c

23:18 any links ?

23:18 Chouser: patience, grasshopper

23:18 cataska: :)

23:20 hiredman: ~add-classpath

23:20 clojurebot: classpath is (System/getProperty "java.class.path")

23:20 hiredman: hmmm

23:21 Chouser: well this is unsatisfying: http://clojure-log.n01se.net/date/2009-01-05.html#10:39

23:21 jbondeson: theeere we go.

23:21 thanks hiredman

23:22 cataska: hmm

23:25 i recall there is a clojure on android project on github

23:25 but i can't remember it ...

23:26 Chouser: here you go: http://clojure-log.n01se.net/date/2008-12-30.html#13:24

23:26 te: How do I get emacs to do clojure syntax highlighting?

23:26 Is there a package or something?

23:26 cataska: Chouser: yes it is, thx

23:28 hiredman: ~add-classpath

23:28 damn

23:29 ~add-classpath

23:31 cataska: te: http://bc.tech.coop/blog/081118.html

23:34 hiredman: ~add-classpath

23:34 clojurebot: add-classpath is bad, avoid it. I mean it!

23:35 hiredman: ~logs

23:35 clojurebot: logs is http://clojure-log.n01se.net/

23:35 hiredman: excellent

23:35 durka42: nice

23:36 can i request a feature?

23:36 or i could have a crack at implementing it myself

23:37 hiredman: either one

23:37 durka42: i want to say clojurebot: tell hiredman not to make the robot too smart

23:37 and if you were not here, it would tell you when you came in the room -- if you were here, when you come back from away or talk

23:37 clojurebot: where are you?

23:37 clojurebot: http://github.com/hiredman/clojurebot/tree/master

23:44 durka42: is botattrs just a map?

23:45 * durka42 is trying to figure out how to start clojurebot

23:46 hiredman: yes

23:46 durka42: something like this? (run-clojurebot "cbtest" {:network "irc.freenode.net" :channel "cbtest" :nick "cb"}

23:46 )

23:46 hiredman: there is a sample in the clojurebot.clj

23:46 durka42: oh, so there is

23:47 cooldude127: i posted on the google group asking if my date library could be included in clojure-contrib, voice your opinion: http://groups.google.com/group/clojure/browse_thread/thread/ba0333c5aae2eda5

23:47 </self-marketing>

23:47 durka42: broken link?

23:48 cooldude127: works for me, do google groups links not transfer?

23:48 Chouser: cooldude127: I haven't looked at your code yet at all. I'll try to tomorrow.

23:48 durka42: it worked the second time :-\

23:48 cooldude127: Chouser: cool, thank you

23:48 durka42: weird

23:48 Chouser: cooldude127: you do have to have your CA turned in before your code can be put in clojure-contrib

23:49 cooldude127: Chouser: what?

23:49 Chouser: http://clojure.org/contributing

23:49 durka42: cooldude127: i have to say i am disappointed with the changed tone of the docstrings :-p

23:49 cooldude127: haha

23:50 dreish: Let's follow the Perl model and have hundreds and hundreds of different incompatible date libraries.

23:50 cooldude127: Chouser: ok i see

23:50 dreish: exactly why i want it in contrib. i think we should have a standard one, so others can work on this and have it be official

23:51 Chouser: cooldude127: if you don't mention on the google group thread that you're sending it in, others will probably remind you as well. :-)

23:52 cooldude127: Chouser-away: done

23:53 Chouser-away: is that supposed to indicate you being away or being some kind of superhero who must go now?

Logging service provided by n01se.net