#clojure log - Sep 16 2010

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

0:16 bhenry: practical use for binding outside of testing?

0:20 wwmorgan: bhennry: (binding [*out* *err*] (println "something")) ;print to standard error

0:40 sproust: Hi; I have a quick question about an install problem.

0:40 I'm trying to get penumbra (OpenGL bindings) working.

0:41 lein native-deps provides this error message: Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V

0:41 at clojure.contrib.java_utils$file__565.<init>(java_utils.clj:83

0:41 I looked in the source, couldn't find references to init.

0:42 Any hints where to dig next?

0:42 It seems to be leiningen issue. I upgraded to latest stable leiningen (1.3.1) and re-ran self-install.

0:43 hiredman: means you have some clojure code aot'ed (to class files) and they were aot'ed with a different version of clojure then the one you where using

0:44 sproust: hiredman: thx!

0:45 It must be one of the project's dependencies.

0:46 hiredman: Is there a way to get some sort of signature to find out which Clojure generated the class file? (I'm unfamiliar with Java, maybe this is a Java obvious one.)

0:46 hiredman: no

0:47 you can look through your dependencies for class files

0:47 sproust: There's a *bunch*.

0:48 I get two stack traces; from those, is there any way I could find out which dependency fails? (by inspection it isn't obvious, unless it's java-utils)

0:49 hiredman: can you pastebin the stacktrace?

0:49 sproust: http://pastebin.com/y41gze5z

0:51 hiredman: do you have maven installed?

0:52 you can have lein generate a pom.xml and then maven can generate a dependency graph

0:52 sproust: yep, maven2 (I don't know anything about it, I'm coming into Clojure from the LISP / dyn.lang angle)

0:52 Ha, nice.

0:52 Thx hiredman.

0:54 Well that'll just list the libraries.

0:54 Would be a nice feature to add to Clojure, to insert some marker in the jar files about which version compiled it, since it matters... wouldn't it?

1:12 re. penumbra: something's hokey with leiningen; I went the lazy route and rm'ed its repository (~/.m2), reinstalled it, and now it works!

1:33 Must be my lucky night, I managed to crash Java: # A fatal error has been detected by the Java Runtime Environment. Allright, to be continued. Thx again hiredman (G'night).

2:32 jjido: ,(pos? 0)

2:32 clojurebot: false

2:33 jjido: ,(nat? 0)

2:33 clojurebot: java.lang.Exception: Unable to resolve symbol: nat? in this context

2:35 phobbs: ,(let [nat? (partial >= 0)] (nat? 0))

2:35 clojurebot: true

2:36 jjido: phobbs: hey, you can put the operator between the operands?

2:36 ah I get it

2:36 "partial"

2:36 phobbs: yes

2:36 I wish clojure would automatically partial functions like haskell

2:36 tomoj: ,(let [nat? (partial >= 0)] (nat? 0.5))

2:36 clojurebot: false

2:36 tomoj: maybe I don't know what 'nat' stands for

2:36 phobbs: erm

2:37 ,(>= 0 0.5)

2:37 clojurebot: false

2:37 phobbs: oh

2:37 I'm flipping it again

2:37 haskell habits

2:37 jjido: tomoj: natural numbers

2:38 phobbs: yeah

2:38 and you have to test that it is an integer

2:38 tomoj: that's what I was worried about, didn't even realize that (>= 0 0.5)

2:38 jjido: phobbs: mmh I don't need to test that :) I just want pos? with zero included

2:38 phobbs: oh

2:39 well then you just do (partial <= 0)

2:39 or #(<= 0 %)

2:39 which is a little too perl-ish for my tastes

2:39 syntax soup

2:44 lancepantz_: anyone else get an insatiable desire to code when the get home from work?

2:44 i got at work

2:44 but usually those are huge projects

2:44 but then i come home, nothing to do

2:44 and want to do something simple

2:45 jjido: how do you read command-line arguments? Then convert to int with a default value

2:47 ,(doc *command-line-args*)

2:47 clojurebot: "; A sequence of the supplied command line arguments, or nil if none were supplied"

2:48 jjido: ,(first nil)

2:48 clojurebot: nil

2:50 jjido: ,(or nil 4)

2:50 clojurebot: 4

2:53 phobbs: ,(doc read-line)

2:53 clojurebot: "([]); Reads the next line from stream that is the current value of *in* ."

2:54 jjido: ,(.parseInt "4")

2:54 clojurebot: java.lang.IllegalArgumentException: No matching field found: parseInt for class java.lang.String

2:56 zmila: lancepantz_, i do sometimes at-home programming. these are little hobby projects (like personal dvd and books library) or solving project-euler problems

2:56 lancepantz_: its a nice break

2:56 all day i was fighting dragons in solr and jetty

2:56 just just to come home to an empy repl feels nice

2:56 better than tv :)

3:10 jjido: if you do (+ @(future (f1)) @(future (f2))), does Clojure wait for (f1) to start (f2)?

3:11 Chousuke: I don't know if the order is defined but AFAIK yes.

3:12 jjido: beginner's programming error :-/

3:19 LauJensen: Good morning all

3:20 jjido: ,(time (doseq @(future (Thread/sleep 1000)) @(future (Thread/sleep 1000))))

3:20 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: doseq requires a vector for its binding

3:21 jjido: ,(time (and @(future (Thread/sleep 1000)) @(future (Thread/sleep 1000))))

3:21 clojurebot: java.lang.Exception: No such namespace: Thread

3:22 _na_ka_na_: hey guys, how do a distinguish a list, vector from a map, coll? returns false for a []

3:23 ,(coll? [])

3:23 clojurebot: true

3:23 LauJensen: ,(vector? '(1 2 3))

3:23 clojurebot: false

3:23 LauJensen: ,(map? [1 2 3])

3:23 _na_ka_na_: ,(coll? {})

3:23 clojurebot: false

3:23 true

3:25 _na_ka_na_: LauJensen: I want to distinguish between a collection and an object (not necessarily a map)

3:25 so map? doesn't quite do it

3:26 seq? and coll? are also don't

3:26 LauJensen: Example?

3:26 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

3:27 jjido: Chousuke: it does the Right Thing, ie. it runs both at the same time

3:28 _na_ka_na_: LauJensen: something like .. (many? []) => true ... (many? '()) => true ... (many? (seq ..)) => true ... (many? anything-else) => false

3:30 I guess many? = (comp (comp not map?) coll?)

3:30 not tested

3:32 LauJensen: ,(not-any? true? ((juxt vector? map? list?) 5))

3:32 clojurebot: true

3:32 jjido: Chousuke: sorry my mistake, it doesn't.

3:33 LauJensen: That'll test for all non-clojure types

3:33 _na_ka_na_: ah my bad .. (and (comp not map?) coll?)

3:33 oh we have vector? and list? .. didnt know that

3:34 , (source coll?)

3:34 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

3:34 _na_ka_na_: , (clojure.repl/source coll?)

3:34 clojurebot: Source not found

3:36 LauJensen: ~source coll?

3:37 _na_ka_na_: ,(#(and ((comp not map?) %) (coll? %)) [])

3:37 clojurebot: true

3:37 _na_ka_na_: ,(#(and ((comp not map?) %) (coll? %)) '())

3:37 clojurebot: true

3:37 _na_ka_na_: ,(#(and ((comp not map?) %) (coll? %)) {})

3:37 clojurebot: false

3:37 _na_ka_na_: ,(#(and ((comp not map?) %) (coll? %)) 543)

3:37 clojurebot: false

3:38 _na_ka_na_: ,(#(and ((comp not map?) %) (coll? %)) "")

3:38 clojurebot: false

3:39 _na_ka_na_: LauJensen: I'm having to deal with a multimethod which returns a vector of objects sometimes and sometimes just one object .. how do I deal with it?

3:40 changing the multimethod itself is not a pretty solution .. as all but one defmethod return only one object ..

3:41 LauJensen: How the receiver should deal with it? How about just wrapping the single object in [object], that way all interfaces would still work. Thats probably the best alternative to adjusting the mm

3:42 _na_ka_na_: LauJensen: but as a receiver I first need to find out if its single or not .. that's what I want to avoid .. I think its not good to have a function return different things at different times .. . I think I'll just change all defmethods

3:43 LauJensen: Good idea

3:43 If you just let everything return a vector, you have a uniform interface

3:43 _na_ka_na_: thanks

3:43 ya

3:48 _Vi: Why when I do "(def q (ref 0)), (comment Now start incrementor of q) (def f (future (loop [] (dosync (ref-set q (+ 1 @q))) (recur)))), (comment Acquire 1000 values from q repeatably) (dosync (for [x (range 1000)] @q))" I get list with from increasing values? Isn't this in the transaction created by "dosync"?

3:49 *list of increasing values

3:50 LauJensen: _Vi: for is list-comprehension, so its taking a 1000 values and returning them as a seq

3:50 _Vi: LauJensen, Why that values are not the same?

3:51 LauJensen: hmm

3:51 _Vi: LauJensen, I clearly see that q is updated by future while transaction should prevent this.

3:51 LauJensen: I think its because you're not comitting anything, so your transaction doesn't retry. try (dosync (for [x (range 1000)] (ensure q)))

3:52 That will prevent q from being written to while you're working

3:54 _Vi: (dosync (def l (for [x (range 1000)] @q)) (ensure q) l) ; The same

3:56 BTW How to explicitly start a transaction? "(dosync (for [x (range 1000)] (ensure q)))" -> "No transaction running"

3:59 Probably understood. "for" is returning "lazy" sequence and "(ensure q)" is called not in "dosync", but while printing.

3:59 raek: _Vi: for is lazy, so it isn't realized until you try to print it, which happens outside the transaction. use 'doseq'

4:00 which is exactly like for, except that it is not lazy and returns nil (presumably, it is used for its side-effects)

4:02 you can also use doall to force a lazy sequence

4:03 (dosync (doall (for [x (range 1000)] @q))) ; will force the lazy sequence returned by for to be fully realized within the transaction

4:03 hrm, use might not be the best fit for the acquire part...

4:03 s/use/doseq/

4:03 sexpbot: <raek> hrm, doseq might not be the best fit for the acquire part...

4:03 _Vi: Yes, "doall" fixes things.

4:05 raek: also, don't do ref-set + @, use 'alter' instead

4:06 (doc alter)

4:06 clojurebot: "([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref."

4:06 raek: (alter q inc)

4:09 (dotimes [_ 1000] (Thread/sleep 10) (alter q inc))

4:09 (dotimes [_ 1000] (Thread/sleep 10) (dosync (alter q inc))) ; *ahem*

4:15 _Vi: (what I said after the last thing you said and when your connection died: http://pastebin.com/8XMzieFE )

4:16 _Vi: raek, (Yes, I'm looking at http://clojure-log.n01se.net/ now but it is not yet updated to this point)

4:20 (def f (future (recur))) (comment endless loop in background), (future-cancel f) ; Still looping

4:20 How to really terminate it (without of restarting JVM)?

4:21 raek: I'm not sure that futures can be canceled at all times

4:21 the best way is probably to make the looping code check for a condition

4:22 _Vi: raek, I mean if there is some broken code looping, and we need to get rid of it.

4:23 raek, For example, it can get stuck not in Clojure code, but in some external library.

4:24 raek: good question, but unfortunately I don't know the answer

4:24 jjido: anyone wants to test? I get no benefit from parallelism with a 1000 elements set http://pastebin.ca/1941926

4:24 Chousuke: _Vi: You can't really

4:25 _Vi: Something like Thread.interrupt() or Thread.stop().

4:25 Chousuke: _Vi: unless you get hold of the Thread instance that the future is running in and call .stop on it

4:25 but even that's deprecated

4:25 .interrupt doesn't help with broken code.

4:25 _Vi: How to get the Thread instance of a future?

4:25 Chousuke: No idea :/ I think they run in an executor so hm.

4:26 _Vi: E.g. how to more-or-less safely call to some binary blob that can arbitrarily do "for(;;);" just for fun?

4:28 Chousuke: _Vi: use Threads explicitly and .stop them. or use clj-sandbox

6:04 kjeldahl: Any gurus want a question? I have a list with integers indicating capacity. I have a known need (for capacity). I want to iterate through the list, taking the available capacity from each entry until capacity has been reached.

6:04 And here I am wrapping my head around for/recur/while etc. not quite figuring it out.

6:05 ,'(range 10)

6:05 clojurebot: (range 10)

6:05 kjeldahl: ,'[(range 10)]

6:05 clojurebot: [(range 10)]

6:05 kjeldahl: ,(range 10)

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

6:06 kjeldahl: Let that be the list. Say I want to read from the top, until total capacity reaches 8. 0+1+2+3+ (half of four)

6:12 LauJensen: kjeldahl: like this?

6:12 ,(reduce #(if (< (reduce + %1) 10) (conj %1 %2) %1) [] (range 20))

6:12 clojurebot: [0 1 2 3 4]

6:12 LauJensen: Walks through (range 20), stops when the sum is > 10

6:13 or.. stops is the wrong word. But it doesn't accumulate above that point

6:13 kjeldahl: Let me chew on that.

6:14 Where's my 8?

6:14 (the capacity I want filled)

6:14 LauJensen: ,(reduce #(if (< (reduce + %1) 8) (conj %1 %2) %1) [] (range 20))

6:14 clojurebot: [0 1 2 3 4]

6:15 LauJensen: ,(let [capacity 8] (reduce #(if (< (reduce + %1) capacity) (conj %1 %2) %1) [] (range 20)))

6:15 clojurebot: [0 1 2 3 4]

6:16 kjeldahl: Excellent. I'll see if I can munge it into something usable in my baby-steps code. Thanks.

6:16 LauJensen: kjeldahl: np. Most of the time, loop/recurs can be replaced by reduce. But this is one of those cases where if this was performance critical, I would do a loop instead

6:17 kjeldahl: Yes, this is what hit me as well. Nothing critical right now, but good to know. Thanks again.

6:19 raek: maximum flow problem?

6:19 bsteuber: I think gen-class should do automatic conversion to camel case

6:20 so you can use the same code for java and clojure callers

6:21 LauJensen: kjeldahl: In case you're wondering, this is a simple loop version

6:21 (loop [x (range 20) acc []] (if (< (reduce + acc) 8) (recur (next x) (conj acc (first x))) acc))

6:21 and this is probably a little faster for larger data sets

6:21 (loop [x (range 20) acc [] sum 0] (if (< sum 8) (recur (next x) (conj acc (first x)) (+ sum (first x))) acc))

6:21 (because its not calling reduce on each loop)

6:21 im done :)

6:22 * kjeldahl bows

6:25 pomyk: hello

6:25 bsteuber: does anyone else have problems with lein not returning after it's done?

6:25 raek: kjeldahl: you don't happen to be practicing for Nordic Collegiate Programming Contest?

6:25 pomyk: does clojureql work with clojure 1.2?

6:26 LauJensen: kjeldahl: actually, sorry last one. I showed you something in poor style, calling first twice. Usually when you reference something twice with a modifier, you should bind it to a name, this is the way to go:

6:26 (loop [[x & xs] (range 20) acc [] sum 0] (if (< sum 8) (recur xs (conj acc x) (+ sum x)) acc))

6:26 pomyk: If you build the jar without AOT compilation, then yes, if you just use the source then it works as well. AOT compilation currently only works for 1.0

6:26 kjeldahl: raek: No, I'm using the planetwars google ai challenge to try to teach myself some clojure.

6:26 * kjeldahl bows to LauJensen again

6:26 * LauJensen tips his hat

6:27 kjeldahl: raek: Obviously, clojure being my first function language... :-)

6:28 *functionAL

6:32 ,(doc negate)

6:32 clojurebot: Excuse me?

6:33 LauJensen: ,(doc complement)

6:33 clojurebot: "([f]); Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value."

6:33 kjeldahl: ,(* -5 -1)

6:33 clojurebot: 5

6:33 kjeldahl: That's what I want. Cheat sheet says negate, but doesn't seem to exist.

6:34 LauJensen: ,(doc unchecked-negate)

6:34 clojurebot: "([x]); Returns the negation of x, an int or long. Note - uses a primitive operator subject to overflow."

6:34 kjeldahl: Thanks again.

6:34 LauJensen: np

6:35 kjeldahl: Ah, didn't read the cheat sheet close enough...

6:36 fbru02: is it true what i read here that 1.3 will be getting a sort of maybe monad??

6:38 raek: link?

6:38 clojurebot: your link is dead

6:41 raek: this might be of intereset: I think that contrib's -?> and -?>> have maybe-monad-like behaviour (if I have understood the maybe monad correctly; I'm a total noob in that area)

6:41 ,-?>

6:41 clojurebot: java.lang.Exception: Unable to resolve symbol: -?> in this context

6:42 raek: ,(use '[clojure.contrib.core :only [-?> -?>>]])

6:42 fbru02: raek cool i will check them out

6:42 clojurebot: java.io.FileNotFoundException: Could not locate clojure/contrib/core__init.class or clojure/contrib/core.clj on classpath:

6:43 raek: they work like ordinary -> and ->>, but stops and returns nil if any form in the chain returns nil

6:45 -> -?>

6:45 sexpbot: java.lang.Exception: Unable to resolve symbol: -?> in this context

6:45 LauJensen: Im glad I started so early with Clojure, coming in now and seeing functions like "$" "->" "->>" "-?>>" "#(fn %&)" etc will likely freak some people out

6:48 * raek got struck by the cond indentation problem again

6:49 LauJensen: which one?

6:50 raek: when the condition of a cond clause is large enought to occupy a whole line, how do you indent?

6:50 LauJensen: I've suggested wrapping each line in a ()

6:50 raek: didn't know that you could do that in clojure

6:51 LauJensen: You cant, it was a suggested change to cond/condp/deftemplates/defsnippet et al

6:52 pomyk: with clojure 1.2 I get this warning in repl: WARNING: group-by already refers to: #'clojure.core/group-by in namespace: clojureql, being replaced by: #'clojureql/group-by

6:52 raek: maybe I could resort to use two nested ifs this time...

6:54 pomyk: there's a function called group-by in clojure.core nowadays. it can be replaced by another function when using use, so that older code will not break

6:58 LauJensen: Ive written a quite simple factorial for beginners to model their code after:

6:58 ,(letfn [(!-?> [&$ &!] (if (> &! 1)(!-?> (->> &$ (* &!))(-> &! dec))&$))](!-?> 1 5))

6:58 clojurebot: 120

7:00 raek: you could replace 'dec' with #(- % (*))

7:01 LauJensen: even better

7:03 raek: ,(letfn [(!-?> [&$ &!] (if (> &! (*))(!-?> (->> &$ (* &!))(-> &! #(- % (*))))&$))](!-?> (*) (- (* (+ (*) (*)) (+ (*) (*) (*))) (*))))

7:03 clojurebot: java.lang.ClassCastException: sandbox$eval6608$_BANG___QMARK__GT___6609$_AMPERSAND__BANG___6610 cannot be cast to java.lang.Number

7:09 raek: I guess you have hanged out in #clojure too long when you feel the urge to have show-paren-mode in irssi...

7:10 LauJensen: raek: or not long enough. I have parens matching in all channels, thanks to ERC

7:10 I think this is the most elegant version

7:10 ,(letfn [(!-?>[&$ &!](if(>,&!,1)(!-?>@(->>,&$,(*,&!)ref)(->,&!,dec))&$))](!-?>,1,5))

7:10 clojurebot: 120

7:10 raek: ERC is very high on my to-learn list

7:25 tomoj: LauJensen: how? not paredit right?

7:25 LauJensen: tomoj: What? I never use paredit, what are you talking about? :)

7:26 tomoj: you use emacs but not paredit? O_o

7:27 LauJensen: http://twitter.com/LauJensen/status/18062045007

7:28 tomoj: you really think so?

7:28 or is that just agitprop?

7:29 LauJensen: Whats 'agitprop' ?

7:29 tomoj: s/agitprop/flamebait

7:29 LauJensen: ah, well its both

7:29 tomoj: you really think so and it's flamebait?

7:29 LauJensen: Yes sir

7:30 tomoj: I'd love to hear a more detailed explanation someday

7:30 LauJensen: I think Paredit has its virtues when you're writing code, but I think its a ball 'n' chain as soon as you have to edit loads of code. I've had several tries with it and its always made me slower

7:31 tomoj: I see

7:32 what is it that you do while editing loads of code which is easier without paredit?

7:32 LauJensen: just standard refactoring

7:32 I think. Didn't really stop and think about it :)

7:32 tomoj: and, I don't mean to imply anything by asking this, but did you know all the bindings well?

7:32 LauJensen: hehe

7:33 No I think I knew like 10%

7:33 tomoj: ok

7:33 counterflame: paredit is like training wheels that turn into jet engines once you figure out how to use them

7:34 LauJensen: I'll tell you what I've told every individual who has made statements to that effect: Screencast or it didn't happen

7:34 tomoj: I really want to

7:34 I always get frustrated with the tools

7:34 AWizzArd: tomoj: how do you cut the expression your cursor is on?

7:35 (a b |(c d e) x y) ==> Keys ==> (a b x y) and (c d e) can be pasted somewhere else

7:35 tomoj: kill-sexp, C-M-k by default

7:35 AWizzArd: C-k at alone this position would result in (a b)

7:36 tomoj: right

7:36 LauJensen: tomoj: C-M-k isn't specific to paredit

7:36 tomoj: indeed

7:36 wasn't my example :)

7:36 LauJensen: I know, Im just keeping it real :)

7:36 tomoj: LauJensen: have you made screencasts before?

7:37 AWizzArd: C-M-k doesn't work for me like this. It is doing the same as C-k

7:37 tomoj: would be interested in recommendations for free tools

7:37 LauJensen: tomoj: many

7:37 tomoj: Which OS are you on ?

7:37 zmila: after using paredit from CCW i feel its lack in my java programming

7:37 tomoj: AWizzArd: check what it's bound to

7:37 LauJensen: ubuntu, have os x available too

7:38 LauJensen: tomoj: On OSX I dont know of any free tools, but I would purchase Screenflow. Its cheap and powerful. Cemerick uses it. On linux I use gnome-soundrecord and gtk-recordMyDesktop. Once Im done shooting I mix the video/audio in Audacity, and merge them with mkvmerge and upload to Vimeo

7:38 tomoj: what resolution do you record?

7:38 LauJensen: Post processing takes about 5 minutes

7:38 tomoj: I couldn't seem to find any good answers for resolutions for vimeo

7:38 LauJensen: I usually aim for 800x600 - No good reason

7:39 tomoj: You can see my latest screencast, which was shot with Camtasia and was the correct resolution for HD - Forgot the numbers though

7:39 raek: can audacity do edit video too?

7:39 tomoj: thanks for the tips

7:39 LauJensen: raek: No. But there are actually good video editors of linux as well

7:39 tomoj: I had a camtasia demo

7:40 also snapz pro

7:40 I'll try gtk-recordMyDesktop

7:41 LauJensen: tomoj: it supposedly can both record audio and video at the same time. But Ive never had a good result with it

7:42 So what I do is, I start the sound recorder first, then the video record. Then open the sound afterwards and select the starting point as when I say "Hi" and then the end point as the duration of the video + starting point. Cut that out, save as mp3, merge

7:42 At first I used an insanly long mencoder formula to merge, but then I found out that mkvmerge could do the process in 1 sec with no args :)

7:47 tomoj: Do you have a blog where you will publish?

7:48 tomoj: no, only a snowman http://tomojack.com/

7:48 I had a blog there but took it down because there'd only been one post for months

7:49 LauJensen: Was your name Tomas or Jack ?

7:49 s/Was/Is/

7:49 sexpbot: <LauJensen> Is your name Tomas or Jack ?

7:49 tomoj: thomas

7:49 'tomo' a nickname from esperanto

7:50 LauJensen: Yea I remember you told me

7:50 Ok well, you'll have to announce it here then, once you're done :)

7:50 tomoj: will do

7:50 don't hold your breath

7:50 * LauJensen holds his breath

7:50 LauJensen: O_O

8:04 tomoj: LauJensen: got any ideas for what would be a good way to demo?

8:04 I was thinking a very simple project might be nice

8:05 LauJensen: tomoj: You're looking to code a project live ?

8:05 tomoj: well, maybe

8:05 I don't want to just mess with contrived examples

8:05 I want to show using paredit to write/refactor real code

8:05 LauJensen: tomoj: Would be great if you had some code lying around, that needing converting to protocols/records

8:36 bobo_: i got supprised by the choice of rails for diaspora, but cant decide what i would have used. Could clojure handle a site potentialy that heavy used? with that much dynamic content? i doubt rails will

8:37 LauJensen: bobo_: Jetty is very touted for its scalability, but personally I have my doubts

8:40 bobo_: im not sure how i would do at all. i almost wanna say php, but i refuse

8:42 nlogax: isn't it rails that can only handle 1 request at a time?

8:42 maybe that's fixed now :)

8:45 solussd: I' trying to use swank-clojure with leiningen, I type "lein swank" in my project directory and I get an error: "That's not a task. Use "lein help" to list all tasks." I've added [swank-clojure "1.2.1"] to my project's :dependencies list and then ran "lein deps". anyideas?

8:46 r0man: solussd: i think you must add it to the :dev-dependencies list

8:46 bobo_: solussd: dev-dependencies

8:46 or add it to ~/.lein/plugins

8:46 wher "it" is the jar

8:46 ~/.lein/plugins$ ls

8:46 swank-clojure-1.2.1.jar

8:46 clojurebot: http://www.assembla.com/wiki/show/clojure/Protocols http://clojure-log.n01se.net/date/2009-10-13.html#12:02

8:47 solussd: thanks, that did it.

9:02 LauJensen: bobo_: Ive just seen a report wherein Jetty handled 10.000 concurrent users with 250 threads and a latency of about 2.5s per request

9:02 bobo_: 2.5s is ages on internet, but i assume that goes down pretty fast

9:04 LauJensen: bobo_: Yes, but it tells you something about when to shard your application, which will happen eventually anyway, so that point may come 10% sooner for Jetty than for Rails, but if it has speed up your development process by 400% not using rails, it still could make sense

9:04 bobo_: indeed

9:05 would be intresting to benchmark some clojure web code

9:05 maybe i should try something with some rest and curl

9:07 LauJensen: Yea, you should need to a host and a server both on massive connections for it to have any real value

9:07 fbru02: how would be a good way of doing juxt over a vector ??

9:07 LauJensen: I mean, server and client

9:08 fbru02: What are you looking to do ?

9:08 bobo_: yes, massive connections i have some. i live in sweden afterall :-)

9:08 LauJensen: bobo_: oh right, I always forget that Denmark is Scandinavias little Africa when it comes to IT

9:08 fbru02: LauJensen: I have a vector of [fn(x), fn1(x)] and i want to juxt fn fn1(x)

9:08 bobo_: LauJensen: lol

9:09 LauJensen: bobo_: Its so terrible here, that its not even funny

9:09 mrBliss: fbru02: apply?

9:09 LauJensen: ,(apply juxt [(print "one ") (print "two")])

9:09 clojurebot: #<core$juxt$fn__3657 clojure.core$juxt$fn__3657@95f865>

9:09 one two

9:09 fbru02: mrBliss: LauJensen thanks a lot i sometimes forget about that magic thing :)

9:11 grignaak: is there something that is the reverse of apply?

9:11 something like (defn select [f] (fn [& xs] (f xs)))

9:12 LauJensen: grignaak: What are you looking to do with it?

9:13 grignaak: ((#(fn [& xs] (% xs)) second) 1 2 3)

9:13 ,((#(fn [& xs] (% xs)) second) 1 2 3)

9:13 clojurebot: 2

9:13 grignaak: where the lambda is replaced by the defn above

9:42 fliebel: Is it defined behavior(ie, something that can be relied on) that load-file returns the result of the last expression?

9:43 LauJensen: fliebel: judging from the doc string I would say yes

9:44 jjido: ,(defn troll [opinion object dissing] (println (pick opinion) " " (pick object) ". " (pick dissing))) (troll ["I love" "I hate"] ["Java" "Clojure" "functional"] ["I don't get you.""You don't read what I wrote." "There are idiots everywhere."])

9:44 clojurebot: DENIED

9:44 LauJensen: Also, Rich is usually pretty strict about sticking with signatures

9:45 _fogus_: ,(#(second %&) 1 2 3)

9:45 clojurebot: 2

9:45 fliebel: LauJensen: Okay :) None of the other load/require/use functions seems to do this. It's nice to avoid things like in Twisted, where you have to define an application variable.

9:46 grignaak: _fogus_: what? you can put an & after the % ?

9:47 * grignaak slaps forehead

9:47 fliebel: _fogus_: Awesome! *slaps forehead as well*

9:47 _fogus_: grignaak: Yes. That is the #() way to say "var args"

9:47 jjido: /msg nickserv

9:47 LauJensen: _fogus_: Did you get my contribution to @learnclojure ?

9:47 _fogus_: Ooooo. That gives me an idea for a @learnclojure tweet

9:48 bobo_: i didnt know about @learnclojure!

9:48 _fogus_: LauJensen: I have not checked yet. I still haven't gotten the hang of managing multiple twitter accounts

9:48 fliebel: *follows learnclojure*

9:49 jjido: test: idiot

9:49 LauJensen: _fogus_: It was just an attempt to make people coming from Perl a little more comfortable: http://twitter.com/LauJensen/status/24654495072

9:50 _fogus_: LauJensen: Love the use of commas

9:50 LauJensen: _fogus_: yea, its artistic :)

9:50 jjido: can you make it more obfuscated

9:51 LauJensen: not without sacrificing elegance

9:52 jsanda: hey everyone, can someone tell me how can i check to see if a var has a root binding? when i call bound? an exception is thrown

9:52 jjido: I don't even know what !- is

9:52 chouser: !-?> is defined right there

9:52 fliebel: jjido: I think that is just a normal variable

9:52 chouser: LauJensen: that's really horrible. Shame on you. And ... congrats, I think.

9:52 LauJensen: chouser: hehe :()

9:53 chouser: letfn, so !-?> is a normal local function

9:53 LauJensen: !-?> is factorial

9:54 jsanda: and if done, (declare myvar), how can i set the root binding? i just noticed the docs mention that set! cannot be used to set the root binding

9:57 vu3rdd: LauJensen: Obfuscated Clojure contest?

9:58 LauJensen: vu3rdd: Dont know if its a contenst. Just wanted to attract a few more Perl developers to Clojure, I dont think we dont enough advertising for that group

9:58 s/contenst/contest

9:58 vu3rdd: :-)

9:58 LauJensen: s/dont/do

9:58 I should get a new keyboard

10:02 bobo_: would a twitter clone be a good webapp to use for benchmarking?

10:03 fliebel: bobo_: What do you want to benchmark?

10:03 bobo_: performance of clojure web stack, or something like that. Havent set a real goal

10:03 LauJensen: _fogus_: haha, #eyeshurt :)

10:04 bobo_: Why not just serve a single static page which pulls some data from a fast db and then hammer it with ab or some other stresstest util

10:05 fliebel: bobo_: Yea, I think any real-life app would do. Nice thing for the Twitter clone is that you can compare to StatusNet and Twitter.

10:05 bobo_: i think i already have a twitter clone aswell, thats why i thought about that

10:05 LauJensen: s/static/dynamic/

10:05 sexpbot: <LauJensen> bobo_: Why not just serve a single dynamic page which pulls some data from a fast db and then hammer it with ab or some other stresstest util

10:05 bobo_: with redis as backend

10:06 but static page can be intresting aswell

10:06 then it is easier to try other languages aswell

10:14 jjido: ,(let [n 4] (-> n dec))

10:14 clojurebot: 3

10:15 jjido: ,(-> 3 dec)

10:15 clojurebot: 2

10:15 chouser: ,(-> 3 inc inc inc)

10:15 clojurebot: 6

10:16 jjido: how about ->>?

10:16 LauJensen: isnt it -?>> ?

10:17 its something lpetit cooked up IIRC

10:17 jjido: you used ->> in the twitter post

10:18 LauJensen: ooh :) I thought you were asking about -?>>

10:19 ->> threads as last argument, -> as first

10:19 sexpbot: => #<core$_GT_ clojure.core$_GT_@36f7a0>

10:19 LauJensen: (-> 5 (/ 2))

10:19 ,(-> 5 (/ 2))

10:19 clojurebot: 5/2

10:19 LauJensen: ,(->> 5 (/ 2))

10:19 clojurebot: 2/5

10:22 jjido: ,(->> 5 (/ 2) (+ 1))

10:22 clojurebot: 7/5

10:24 LauJensen: ,(->> 5 (/ 2) inc str reverse (apply str))

10:24 clojurebot: "5/7"

10:26 jjido: lol. I was able to undo your post now.

10:40 LauJensen: ? :)

10:41 oh, you de-scrambled it you mean ?

10:43 bobo_: how do i enlive (select a link with class "class"? tried everything i could think off

10:43 LauJensen: bobo_: [:a.class]

10:45 bobo_: ah, its ajax that fools me

10:58 chouser: breaking changes to the contrib build have cost me at least as much time as breaking changes to the clojure language itself.

10:59 Raynes: Same with me and Dominos' new pizza recipe.

11:00 chouser: hehe, er, what?

11:01 Raynes: It was a bad joke. Forgive me, I just woke up.

11:01 :>

11:02 chouser: :-)

11:03 kjeldahl: ,(doc doseq)

11:04 Raynes: sdeobald: I shot you a message on github about running tryc.

11:04 AWizzArd: chouser: Contribs breaks were much worse for me, probably because they occur very regularily.

11:04 kjeldahl: From the doseq docs: Repeatedly executes body (presumably for side-effects) with

11:04 bindings and filtering as provided by "for". Does not retain

11:04 the head of the sequence. Returns nil.

11:05 Can anybody tell me what the "Does not retain the head of the sequence" means here?

11:05 bhenry: any of the rubylearning clojure for beginners class instructors on here ?

11:05 AWizzArd: duck-streams is suddenly renamed, then renamed again with some functions removed, http-agent disappeared completely, now Contrib is split up into a million pieces, etc.

11:05 Raynes: Doesn't keep the sequence in memory.

11:05 bhenry: Whatcha need?

11:06 kjeldahl: Eh?

11:06 chouser: AWizzArd: hm, good point. I wasn't even thinking of half of those. I was referring mostly to the ant->maven switch and then the recent splitting

11:06 sdeobald: Raynes: Just woke up and saw that -- thanks.

11:07 bhenry: kjeldahl i think it means for every time body is executed the previous results of body are ignored/unavailable/garbage collected.

11:07 Raynes: kjeldahl: If you hold onto the head of a sequence, it keeps it from being garbage collected.

11:07 chouser: kjeldahl: if any part of the code keeps a reference to the head of a seq while something else walks it, all of the values of the seq from the head to the current walk position will be kept in memory

11:08 bhenry: rubylearning.org isn't working for me. i had just made a double post, and i'm wondering if my "Hour to edit" timeframe will expire before the site comes back up

11:08 Raynes: bhenry: It appears to be working for me.

11:08 $ping rubylearning.org

11:08 chouser: kjeldahl: the docs for doseq are simply saying it will not kee a reference to the head, in contrast with for example doall.

11:08 sexpbot: Raynes: Ping completed in 0 seconds.

11:10 Raynes: bhenry: I'm not sure if I can delete your second post or not, but I'll check if you want.

11:11 apgwoz: does anyone know when an agenda for clojure conj is likely to be released?

11:12 bhenry: i can ping it, but it just hangs. it might be my computer now that i see hwo wacky my chat client is.

11:12 Raynes: the first one needs to be deleted

11:12 i'm going to restart, it may be my computer

11:12 Raynes: bhenry: Is that the shorter or the longer one?

11:12 bhenry: i didn't think the first one went through and added things. so the shorter one should be deleted

11:13 Raynes: Ah, yes.

11:13 Deleted.

11:13 chouser: apgwoz: I've heard rumors the topics are picked. I don't know if timing or order has been. All that suggests "pretty soon" to me, but ... *shrug*

11:13 bhenry: thanks!

11:13 jfields: I need to send a snapshot request for data. If anyone requests that data before the snapshot returns I want to wait for 30 seconds and then throw an exception. I know how to do this with latches, but what's the clojure way you'd go about this?

11:14 (I only throw the exception if the response isn't returned within the 30 seconds)

11:16 chouser: jfields: clojure's reference types aren't really for workflow tasks. what you want to do may be best handled (currently, anyway) with java.utils.concurrent stuff

11:17 kjeldahl: bhenry/chouser: Thanks. I'm struggling with a NPE in after a doseq finishes...

11:17 bhenry chouser: Thanks. I'm struggling with a NPE in after a doseq finishes...

11:17 sdeobald: jfields: oh, hi.

11:18 jfields: chouser, cool. thanks

11:18 sdeobald, hello.

11:18 chouser: kjeldahl: doseq does return nil, so be careful how you use that return value.

11:18 sdeobald: jfields: I hope you're having a beautiful day at work! Say hello to the good people there for me. And give Nate a kiss.

11:19 kjeldahl: chouser: Thanks. I don't use it though. It's inside a normal sequence of forms.

11:20 jfields: sdeobald, will do.

11:20 kjeldahl: chouser: Runs one time through (there's one item in the sequence I'm processing) - all the way through, and crashes with NPE when done.

11:20 apgwoz: chouser: awesome! i look forward to it regardless, but in a discussion now with someone who doesn't wanna go without having some idea what's happening

11:20 chouser: kjeldahl: stack traces are usually quite helpful in tracking down NPEs

11:21 apgwoz: sure, I understand.

11:21 kjeldahl: chouser: Points to the innermost form (a logging statement). Replacing the logging statement with nil gives the same error though.

11:21 Raynes: I'm going just to meet chouser. <3

11:21 chouser: apgwoz: of course, I would be at least as happy to go to a two-day event with all these people if there were no talks at all.

11:22 apgwoz: well, Raynes, I'm going to meet you

11:22 Raynes: Aw. <3

11:22 chouser: heck, I'd go if we were all going to be working in a box factory for two days.

11:22 I'm going to meet _fogus_

11:23 apgwoz: chouser: my thoughts exactly. i know for sure i'll obtain enough useful information just from talking to people to make it worth my companies dime :)

11:23 Raynes: I have never seen his face before. My motivation is slightly fueled by my curiosity.

11:23 chouser: Raynes: whose face?

11:23 Raynes: _fogus_:

11:24 apgwoz: chouser: fogus i'd guess

11:24 Raynes: Minus the colon.

11:24 apgwoz: the picture on his website is of him in a mask

11:24 chouser: ah. he's got pictures up if you look around.

11:24 apgwoz: who *is* michael fogus

11:24 chouser: of course that would ruin the surprise.

11:24 apgwoz: exactly

11:24 Raynes: Indeed.

11:24 chouser: well, you've seen the cover of the book, right?

11:24 apgwoz: is that fogus?

11:25 i didn't think he wore a top hat--just a mask

11:26 dpritchett: Did we ever find out who wrote the mystery foreword to JoC?

11:27 _fogus_: I am wearing a top hat right now

11:27 Raynes: I'm wearing a fedora. And a _fogus_ mask.

11:27 * apgwoz is jealous. all i have is this beard.

11:27 chouser: dpritchett: I heard today he's got writer's block, so we may never know...

11:28 kjeldahl: Is there an implicit "do" in the true part of an if statement?

11:28 chouser: kjeldahl: no

11:28 apgwoz: no

11:28 qbg: I have a CMath protocol, and I want the methods be hinted with the Complex deftype, but I want to inline implement CMath in the definition of Complex. Is there any way to do this?

11:28 apgwoz: kjeldahl: if you don't require an else, use `when`

11:28 that *does* have an implicit `do`

11:28 qbg: I can only get it to work by defining the protocol after the type, and then use extend-type

11:30 chouser: Complex implements CMath?

11:30 qbg: Yes

11:30 chouser: then dpm you should probably hint CMath instead?

11:31 then don't you want to hint CMath instead?

11:31 qbg: I'm hinting the methods in the CMath protocol definition

11:34 Hmm... Now that I think about it, I don't think I need a protocol here, as I don't see any other type/record implementing CMath

11:34 chouser: but you can't defined new methods in a deftype, can you?

11:34 only implement existing ones from some interface

11:35 qbg: I could use ordinary fns instead

11:35 kjeldahl: apgwoz: Thanks for the when hint. Code worked fine with it. Now I need to retrace my steps to figure out why an if with a do only worked once before NPE.

11:35 chouser: oh. well, prefer that any time it makes sense.

11:35 qbg: I wonder how much slower that would be though

11:36 apgwoz: kjeldahl: no problem.

11:36 chouser: qbg: probably not at all.

11:36 qbg: I could also use ^:static in 1.3

11:36 kjeldahl: As suspected; got confused with the parens again. A if - do works fine as long as I save on the parenthesis... :-)

11:37 chouser: qbg: if you use interop syntax to get at your deftype fields with no reflection and, right, :static fns

11:37 qbg: Naturally

11:38 Raynes: apgwoz: You have a severely intimidating last name.

11:38 apgwoz: Raynes: hahahaha. yes.

11:38 Guh-shev-itz, is how we pronounce it (gwozdziewycz for those that haven't bothered to look)

11:39 Raynes: Even Google said 'wut'.

11:39 apgwoz: (not that i expected *anyone* to look mind you)

11:39 Raynes: the great thing is that i'm the only Andrew Gwozdziewycz in the world. but *not* the only Andrew GwozdziewIcz

11:39 Raynes: Interesting. :o

11:40 apgwoz: but, that pronunciation is completely americanized, and Polish speakers always get upset with me

11:49 Raynes: apgwoz: At least you don't have a boring name.

11:49 apgwoz: Raynes: it does spark interesting (although also boring) conversation

11:49 chouser: so ... str-utils/partition is just completely gone now?

11:50 no string lib in contrib anymore and clojure.string doesn't have it.

12:01 hiredman: clojurebot: ping?

12:01 clojurebot: PONG!

12:06 ivey: Is there anything in contrib to turn an XML doc into a nested hash, without all the XML attr bits?

12:07 IE: taking an XML response from REST API and getting a hash that represents same data structure

12:07 * Raynes was curious about that a couple of days ago.

12:08 chouser: tag names become map keys?

12:09 ivey: Yes

12:10 I have a first pass in my private utils repo but realized I may have duplicated effort

12:10 And have no idea

12:10 What to do with attrs vs text contents

12:11 Raynes: {:tag :attrs ... :contents ...}?

12:14 chouser: ivey: I'm not aware of such a thing

12:14 ivey: Cool. I'll clean mine up and add better tests.

12:14 chouser: ivey: you recursively convert the return value of xml/parse?

12:15 grignaak: ivey: attrs as meta-data ?

12:15 ivey: chouser: Correct, just pulling out the elements.

12:15 grignaak: Excellent. That's perfect.

12:15 chouser: grignaak: you're bound to lose data regardless if the input repeats tag names or such.

12:16 grignaak: true dat

12:16 :(

12:16 ivey: repeated tag names turn into an array

12:16 chouser: vector I hope. :-)

12:17 ivey: Heh. My Ruby bias is showing. Indeed a vector.

12:17 amalloy: chouser: are repeated tag names allowed? i thought they weren't

12:17 er, repeated attr names

12:17 chouser: amalloy: ah, no. But I was talking about tag names.

12:31 ivey: What's the best way to distribute a little util like that? Put it in my utils lib on GitHub/clojars

12:32 chouser: good question. interested in giving it to contrib?

12:33 ohpauleez: ... and the crowd chanted to give it to contrib

12:33 :)

12:33 * Raynes does a barbaric 'YAWP'

12:34 chouser: friction 1: in your own separate lib, who will find it? Will they want to depend on your whole lib? Which verision -- will you do releases? Can they copy and paste into their own code -- but what about license?

12:35 friction 2: in contrib as a non committer, you still need a CA. And now you need to get time from a contrib committer to do anything -- submit the original, fix a bug, add a feature, etc.

12:35 Raynes: Oops.

12:36 I meant to kill the local -dev instance. >.>

12:36 ohpauleez: Mr Houser is raising all the best points... The crowd goes wild and cheers for more

12:36 ivey: contrib sounds perfect

12:36 ohpauleez: I'm turning #clojure into an adventure game

12:36 chouser: friction 3: being a contrib committer is the least friction ...except I don't know what the process is to become one, so that itself is friction.

12:37 Raynes: java.lang.IllegalArgumentException: No matching method found: clojure.core/nanoTime

12:37 wut

12:37 ohpauleez: Contrib has won, the day is saved

12:38 chouser: of course regardless of how your code gets into contrib, it's at the mercy of all other contrib committers and may disappear or grow a new bug at any moment. :-)

12:38 ivey: That's what makes it fun

12:38 Raynes: What is clojure.core/nanoTime?

12:38 It doesn't appear to exist.

12:39 chouser: Raynes: what's trying to use it?

12:39 Raynes: time

12:39 chouser: It's System/nanoTime

12:40 clojure.core/time is still using the old interop syntax.

12:40 scottj: Added arg list highlighting (ala slime w/ common lisp or eldoc) to swank-clojure last night: http://github.com/scottjad/swank-clojure/commit/2b8f6052552c062b7b42b655c46713d963374340

12:40 Raynes: I just looked at the macro expansion.

12:40 chouser: System/nanoTime === (. System (nanoTime))

12:40 Raynes: (. java.lang.System (clojure.core/nanoTime))

12:40 chouser: heh, yeah -- the compiler ignores the namespace (if any) of the method name

12:41 Raynes: How odd...

12:41 Must be a clj-sandbox bug.

12:41 :\

12:42 I'm starting to consider just stealing clojurebot's sandbox.

12:42 At least for now.

12:44 * Raynes thinks he can fix this bug.

12:53 amalloy: scottj: what are the chances of getting slime to recognize (apply inc |) and supply the parameters for inc instead of apply?

12:55 scottj: amalloy: hmm, I think it would be pretty easy

12:55 amalloy: cause it seems like that would be super-useful and nobody ever forgets the arguments to apply :)

12:56 scottj: well I'd have it still show args to apply when cursor is on apply

12:59 amalloy: sure of course

13:07 scottj: hmm, eldoc doesn't do that. does CL?

13:13 amalloy: yes

13:14 M-x slime

13:14 (apply 1+ |

13:14 (1+ arg0)

13:16 Raynes: -> (time (range 1 10000))

13:16 sexpbot: => "Elapsed time: 0.934 msecs" (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 ... http://gist.github.com/

13:17 Raynes: Yes, yes. LauJensen will be pleased.

13:17 Also, failgist...

13:17 It shouldn't even try to gist something that large.

13:17 * Raynes fixes.

13:18 scottj: interesting, arglists and C-c C-d C-d appears broken for functions with =. not= actually shows for not, >= for >

13:18 amalloy: Raynes: very cool

13:19 Raynes: Actually, it doesn't seem to do that every time.

13:19 -> (time (range 1 10000))

13:19 sexpbot: => "Elapsed time: 0.858 msecs" (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 ...

13:19 Raynes: Weird!

13:19 Only did it that one time.

13:19 Moving on.

13:29 amalloy: anyone know how to get emacs to interact with the x copy/paste buffer?

13:30 it's kinda a pain to mark with the keyboard and have to use the menubar to copy

13:30 scottj: maybe (setq x-select-enable-clipboard t)

13:32 chouser: "*p in vim :-)

13:34 amalloy: aha

13:35 lovely. thanks scottj

13:35 i wonder how it interacts with multiple entries in the kill buffer/ring/whatever it is

13:40 LauJensen: Raynes: Well done old friend :)

13:41 Raynes: LauJensen: Had to fix a bug in clj-sandbox to get there. :p

13:42 bhenry: any solid emacs configs for clojure code folding?

13:43 LauJensen: Hmmm, I had that a one point, forgot how though

13:43 And, didn't use it enough to keep it

13:46 bhenry: ideally the clickable area would be on the first line in the top level form. theoretically every line within the form after that should be indented. i'd like my emacs to have a bunch of lines like this: [+] (defn some-func …). then i can click on the plus to expand or collapse the forms i want to see or hide respectively.

13:52 jjido: ,(doc deliver)

13:52 clojurebot: "([promise val]); Alpha - subject to change. Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a promise will throw an exception."

13:54 amalloy: is clojure-bot clever enough to give up on @(promise)?

13:54 Raynes: Yes.

13:55 amalloy: woo go clojurebot. i always want to try breaking him, without the risk of actually breaking him. how can i get a local copy going?

13:56 Raynes: Uh, very, very carefully. It's a little tricky.

13:56 jjido: amalloy: you like to torture little animals?

13:56 ;)

13:57 Raynes: -> @(promise)

13:57 sexpbot: Execution Timed Out!

13:57 Raynes: amalloy: You'd never break either of the bots with any sort of time thing. They both timeout.

13:58 I doubt you'll break anyone's heart if you actually do manage to break it.

13:59 At least, nobody has given sexpbot the courtesy of not breaking the running copy. ;)

14:00 Especially _ato. He's *destroyed* sexpbot's security measures on a few occasions. <3

14:00 jjido: is it bad to use (future) even if I don't care about the return value? (doing deliver)

14:01 Raynes: The only time using future instead of starting a thread has ever bit me is when an exception was thrown and I never got to see it because I never tried to get it's return value.

14:02 LauJensen: jjido: future is fine if you dont care about the return

14:02 Raynes: Except if an exception is thrown.

14:02 jjido: I will resolve the promise anyway, and deliver is the last peration

14:03 operation in the task

14:05 dpritchett: I just noticed that node.js surpassed clojure on Google Trends for the first time at the end of August thanks to Node Knockout. I wonder if Clojure could have its own similar competition?

14:05 http://www.google.com/trends?q=node.js,+clojure&ctab=0&geo=all&date=mtd&sort=0

14:05 ohpauleez: How do you type hint a ref? I'm going to guess ^IRef

14:06 LauJensen: dpritchett: Good idea

14:06 ohpauleez: I also like that idea

14:06 dpritchett: Node Knockout seems to have been partially sponsored by Joyent, the employer of Node's creator Ryan Dahl.

14:07 ivey: Ry is such a cool dude

14:07 Worked with him on merb. He used to have a blog that was all little comics he drew about his day

14:08 LauJensen: Feb10 was good, http://www.statsaholic.com/scala-lang.org+bestinclass.dk+clojure.org :)

14:09 jjido: how do I get the promise value

14:10 I forgot

14:10 dpritchett: What was your biggest article in February, the Reddit clone or the language roundup?

14:10 LauJensen: Hmm, dont recall

14:11 amalloy: jjido: @promise-ref

14:11 dpritchett: What would we need infrastructure wise to put on a No.de -style competition? Heroku-style Clojure hosting seems like it would be a huge step forward for rapid prototyping and for adoption.

14:12 jjido: amalloy: clojure.core$promise cannot be cast to clojure.lang.IDeref

14:12 amalloy: works for me

14:13 ,(let [x (promise)] (deliver x 10) x)

14:13 clojurebot: #<core$promise$reify__5534@15e909c: 10>

14:13 chouser: dpritchett: I was pondering yesterday if it would be possible to build something like that on top of google app engine.

14:13 amalloy: ,(let [x (promise)] (deliver x 10) @x)

14:13 clojurebot: 10

14:14 chouser: ohpauleez: what Java method of a ref are you calling directly?

14:14 amalloy: jjido: you seem to have typed @promise

14:14 that derefs the *function* promise, not the specific promise instance you created

14:14 ohpauleez: I'm passing in a ref that is alter'd

14:15 intended to be done in a dosync, obv

14:15 chouser: ^

14:15 chouser: but if you don't call a java method of it directly, you shouldn't need to hint

14:15 dpritchett: VMForce claims to be a Java cloud. I don't know that it actually exists or if it would be as flexible as Heroku though.

14:16 chouser: @x is no faster if x is hinted than if it is not

14:16 ohpauleez: ah, ok

14:16 if x is a ref to a PersistentQueue... ?

14:17 chouser: (pop @x) still has no reflection

14:17 ohpauleez: ahh, ok, thanks

14:17 I've just been getting in the habit of typing for clarity sake

14:18 amalloy: ohpauleez: tried turning on warn-on-reflection and running your function? seems silly to type-hint before you find out what the reflection issues are

14:18 chouser: hints only help avoid reflection, and reflection is only used on a direct interop call (Foo. bar) or (.foo bar) or (Foo/foo bar) where the types of the args involved are in sufficient doubt at compile time.

14:18 ohpauleez: right

14:19 amalloy: chouser: really? the compiler can always figure out what's going on in the absence of interop?

14:19 chouser: well, yes.

14:20 until :static fns it never had to.

14:20 because fns are not overloaded on arg type

14:21 amalloy: i see. that makes sense

14:22 chouser: and now with :static fns it does have to know the types of the formal args when compiling a fn call, but there's still no type-based overloading so it can figure out what it needs to easily with no type hints.

14:24 and prototype fns are special and achieve nearly raw method call speeds with runtime call-site caching rather than type knowledge at compile time.

14:24 LauJensen: Does anyone here have a snippet of a simple override of TableCellRenderer for JTable ?

14:24 chouser: LauJensen: I think so, hang on

14:24 LauJensen: chouser: prototype fns?

14:25 chouser: LauJensen: sorry, protocol fns. the fns generated by defprotocol

14:25 LauJensen: Thought so, just wondering if you had sneaked some new feature in

14:25 chouser: btw, did you blog about call-site caching yet?

14:27 chouser: LauJensen: http://gist.github.com/582903 TableCellRenderer]

14:27 nope, haven't blogged about anything in a while.

14:27 should I blog about call-site caching?

14:27 LauJensen: chouser: thanks alot, exactly what I was looking for

14:28 chouser: Yea, we talked about it a month or so ago, perhaps 2. We both thought it was a good idea

14:28 chouser: heh. oh!

14:30 jjido: my Internet time finished. I will catch up later.

14:31 edbond: why (read-line) immediately return nil?

14:35 scottj: cause it doesn't work in slime

14:57 edbond: scottj: is it possible to make it works?

15:00 LauJensen: edbond: just eval your code in the *inferior-lisp* buffer

15:13 scottj: FYI *inferior-lisp* will only be there with slime project M-x thing not lein

15:14 LauJensen: yea, I typically start my coding with M-x swank-clojure-project

15:15 scottj: is swank-clojure-project deprecated?

15:15 Raynes: swank-clojure.el is deprecated. I'm not sure where swank-clojure-project went.

15:16 LauJensen: Raynes: It just moved to a new maintainer. Its not deprecated

15:16 Raynes: deprecated or just optional. Not sure.

15:16 Shouldn't put the cart before the horse.

15:16 LauJensen: Its always been optional

15:17 Raynes: I remember talk on the swank-clojure mailing list where it was said that swank-clojure.el was no longer needed and such, so my first reaction was "deprecated".

15:18 LauJensen: well, if you want you can run lein swank && slime-connect instead, but you miss out on the inferior lisp buffer, which truely sucks

15:18 Besides, its a small patch to make swank-clojure.el work with the new lib/dev/* structure

15:20 Raynes: I've always did the former.

15:20 Not sure why I would want the inferior lisp buffer.

15:20 LauJensen: So you go check a console everytime you need to see output/traces from a thread?

15:21 Raynes: Uh... huh?

15:22 LauJensen: In case you haven't noticed, output to *out* and stacktraces etc from threads will only appear in inferior-lisp, not slime-repl. So when you need that info, I would think that it sucks to go out to a shell to see it

15:23 I usually have left buffer: code, right top: inferior lisp, right bottom: slime-repl

15:23 Raynes: Could you show me an example?

15:23 LauJensen: At least when Im doing threaded stuff

15:23 ,(future (println "hi"))

15:23 clojurebot: #<core$future_call$reify__5492@1f16561: :pending>

15:23 LauJensen: That will print in inferior-lisp

15:24 And besides. Its great whenever you start hacking, just to open project.clj, hit M-x swank-clojure-project and off you go

15:24 Raynes: Fair enough. I've never noticed that before.

15:24 I don't guess I've ever wanted output from threads before.

15:25 shoover: LauJensen: you know about slime-redirect-inferior-output?

15:25 scottj: the problem isn't seeing output, it's easy enough to have a term where you would otherwise have a buffer, the problem is with lein afaik if started with swank you can't give it input at the terminal, whereas you can type in *inferior-lisp*. this is needed in the case of read-line, swing stuff occassionally I think, and maybe other cases

15:25 LauJensen: shoover: nope

15:25 shoover: run it, and you won't need to look in inferior-lisp

15:25 Raynes: Oh cool.

15:25 LauJensen: scottj: good point about input

15:26 shoover: but I can't figure out how to get the same behavior with lein swank, it only works with inferior-lisp

15:26 LauJensen: shoover: cool

15:26 shoover: so it still supports swank-clojure-project :)

15:27 apgwoz: anyone using ant for builds and using emacs?

15:27 Raynes: The latter.

15:27 LauJensen: apgwoz: of course not, we're all rational people here :)

15:27 Raynes: (:

15:28 apgwoz: LauJensen: my company uses ant and java (no clojure -- yet).

15:28 LauJensen: ant and maven are invented by dentists

15:28 apgwoz: anyway, point being, i wrote some wrappers for ant around compilation mode that might be helpful to folks

15:28 shoover: LauJensen: however, I recently saw some interesting elisp to launch lein swank within emacs, which would retain the ability to just switch buffers and see the output

15:28 clojurebot: emacs is best configured for Clojure with instructions at http://technomancy.us/126

15:29 LauJensen: shoover: whats the point when we have swank-clojure-project?

15:29 except having less stuff to maintain

15:29 apgwoz: shoover: i saw that as well, but haven't yet integrated it

15:29 LauJensen: but elisp just sits there

15:29 shoover: LauJensen: right

15:37 LauJensen: I can think of one advantage, and that's if you hook up the lein run plugin to launch the swank server and run some initialization code (start a jetty server, etc). This lein elisp code I saw could easily run that, whereas I'm not sure how you would inject all that behavior with swank-clojure-project

15:46 Whenever I lose my connection I end up getting a different nick, and then I can't change my nick without leaving the channel. What am I doing wrong?!

15:52 hiredman: #clojure has some dumb mode set on the channel so you cannnot change nicks while in it

15:53 Raynes: I know.

15:53 It's horrible.

15:53 technomancy: shoover: you can register your fallback nick. I agree it's very annoying.

15:53 Raynes: :(

15:53 #concatenative has the same thing set, so if I accidentally join without identifying, I have to leave both channels.

15:58 Chousuke: you don't need to actually register two nicknames, you can link an alt to the existing registration

15:59 sthuebner: Chousuke: how would you do that?

15:59 Chousuke: /msg nickserv help :)

15:59 chouser: hiredman: can we turn off that mode?

15:59 I don't remember having any real problems with spam or anything before it was changed for us

16:00 sthuebner: Chousuke: ah, nickserver! never mind

16:01 hiredman: chouser: no idea

16:03 technomancy: what's the status on ticket #315?

16:03 would really love to see that applied so everyone could reduce AOT usage

16:03 considering it's a patch to clojure.main submitted by the author of clojure.main it seems like a no-brainer.

16:05 lpetit: ticket 322 is important too, regarding AOT compilation

16:06 cemerick: lpetit: I saw you're now a speaker at the conj, congrats! :-)

16:07 * technomancy wonders when the abstracts will be chosen

16:08 lpetit: cemerick: yeah, thanks, it's so impressive that I kind of haven't totally realized yet the chance I have !

16:08 cemerick: technomancy: I'm mostly hoping all of them will be :-)

16:09 technomancy: well... I only have time to prepare one talk. =)

16:09 but I'd love to hear three apiece from everyone else

16:09 lpetit: indedd ticket 315 seems both interesting and low hanging fruit

16:09 so do I !

16:10 chouser: technomancy: heh

16:11 I'm already doing a different one for Strange Loop.

16:12 lpetit: Soo many different "command line/project management" tools for clojure : maven, ant, cake, cljr, lein, gradle, polyglot maven ! What a hell for a poor IDE dev !

16:13 cemerick: lpetit: some very wise bets will have to be made

16:13 lpetit: cemerick: :-/

16:13 cemerick: talking about IDE features ... :-)

16:14 cemerick: PING !

16:14 cemerick: hah

16:14 Patience, patience :-)

16:14 It's been a busy couple of weeks

16:14 * lpetit is made of patience :)

16:14 _fogus_: technomancy: 3!?!

16:16 technomancy: _fogus_: oh right; only 2 abstracts were required. I had a third, so I threw it in there.

16:17 cemerick: _fogus_: I'd happily do 3. Hoping to, actually.

16:17 The fourth I'm not so excited about, but it's a common pain/interest point.

16:17 Raynes: technomancy: Is 315 the one about adding a way for clojure.main to execute a -main function in a provided namespace to avoid AOT compilation just for executable jars?

16:17 I was highly disappointed that that one didn't make it into 1.2

16:17 technomancy: Raynes: yeah

16:18 _fogus_: I could talk about the 2 that I submitted, but for the 3rd I'd have to pull out contracts or something more exciting, like my cats

16:19 Chouser1: Hello?

16:19 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline Chouser1

16:19 Raynes: o.o

16:19 Chouser1: I'm not a girl!

16:20 nakkaya22223333: testing

16:20 jjido: Hello?

16:20 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline jjido

16:20 jjido: lol

16:20 chouser: ok, we'll try that for a while.

16:21 shoover: chouser: on behalf of users of finicky ISPs and freenode servers everywhere, thank you

16:21 chouser: shoover: :-)

16:22 shoover: sorry about the twitter search brokenness, too. Afraid I don't know how to proceed on that one.

16:22 shoover: chouser: not your problem. I've filed multiple bug reports to no avail

16:22 chouser: why should they care, after all. You're only a user, not a customer.

16:22 jjido: ,(let [x promise] (future (apply (partial deliver x) 3)) @x)

16:22 clojurebot: java.lang.ClassCastException: clojure.core$promise cannot be cast to clojure.lang.IDeref

16:22 jjido: why?

16:22 clojurebot: why not?

16:23 chouser: (promise) not promise

16:23 jjido: aaah

16:24 shoover: chouser: according to al3x, they have ample resources now, so I'll expect a fix any day now

16:24 jjido: ,(let [x (promise)] (future (apply (partial deliver x) 3)) @x)

16:24 chouser: heh

16:24 clojurebot: Execution Timed Out

16:24 chouser: [3] not 3

16:24 jjido: ,(let [x (promise)] (future (apply (partial deliver x) [3])) @x)

16:24 clojurebot: 3

16:25 Raynes: -> (let [x (promise)] (future (apply (partial deliver x) [3])) @x)

16:25 sexpbot: java.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/future-call)

16:25 Raynes: Doh

16:26 -> (let [x (promise)] (future (apply (partial deliver x) [3])) @x)

16:26 sexpbot: => 3

16:26 Raynes: That's more like it.

16:27 jjido: what did you do?

16:27 LauJensen: shoover: Pretty simple to make swank-clojure-project eval your core.clj or something like that, if you want to boot a jetty

16:27 dnolen: ,(let [x (promise) y (promise)] (future (doall (map deliver [x y] [3 4]))) (+ @x @y))

16:27 clojurebot: 7

16:27 Raynes: I committed a fix and then used various bot commands to pull the git repo on my VPS and reload the plugins so that the commit would take effect.

16:28 Well, two bot commands.

16:28 jjido: Raynes: funny you can do that in so less time

16:28 nakkaya22223333: testing

16:28 jjido: memo: when you do CPS, don't forget trampoline in the parallel threads.

16:28 Raynes: It's a pretty fast process. I already had the relevant file open in Emacs, and with magit, committing and pushing was a breeze.

16:29 jjdkdk: hello

16:29 jjido: jjdkdk: are we related?

16:29 nakkaya22223333: still

16:30 jjdkdk: jjido: nah, just random

16:30 Raynes: ~max

16:30 clojurebot: max people is 313

16:30 Raynes: Whoa.

16:31 jjido: not far

16:31 Raynes: is that the upper limit?

16:31 Raynes: Yes.

16:31 nakkaya22223333: still testing

16:32 Raynes: nakkaya22223333: What exactly are you testing?

16:32 My patience? :p

16:32 nakkaya22223333: http://nakkaya.com/2010/02/10/a-simple-clojure-irc-client/

16:32 Raynes: I should really do something like that with Irclj as an example.

16:33 nakkaya22223333: from slime repl, sorry Raynes

16:33 jjido: ,(Integer/parseInt nil)

16:33 clojurebot: java.lang.NumberFormatException: null

16:33 Raynes: nakkaya22223333: It's cool. <3

16:33 jjido: is there apply-if-not-nil?

16:35 nakkaya22223333: works good once I figured out that sending a message is actually a privmsg to #clojure with a : in front of the text

16:35 and that my message doesn't show in swank

16:35 jjido: ,(Integer/parseInt (or nil "5"))

16:35 clojurebot: 5

16:37 nakkaya22223333: later, thanks

16:39 Raynes: jjido: Also, see clojure.contrib.core/-?>>

16:39 jjido: ,(-?>> Integer/parseInt (nil))

16:39 clojurebot: java.lang.Exception: Unable to resolve symbol: -?>> in this context

16:41 Raynes: -> (clojure.contrib.core/-?>> nil Integer/parseInt)

16:41 sexpbot: => nil

16:44 lancepantz: we've got our first los angeles clojure meetup tonight if anyone is in the area http://bit.ly/9F9DJp

16:45 Raynes: lancepantz: Sure, I'm only like on the other side of the country. ;)

16:53 jjido: Could someone try that code on a big vector of unsorted numbers? http://pastebin.ca/1942389

16:53 if you have several cores

16:54 it takes a number, 0, 1, 2... default 5

16:59 dnolen: for $0.68 an hour you can also try it yrself on an 8-core box on Amazon EC2 ;)

16:59 jjido: ^

17:00 jjido: dnolen: ok ;)

17:01 LauJensen: Good night Clojure, whereever you are

17:02 grignaak: dnolen: you can get boxes that are $0.02/per hour new

17:02 lancepantz: an 8 core one?

17:03 or are you talking about the micro instances

17:05 jjido: the built-in sort function is almost 10x faster on my computer, and using 2 threads does not help :(

17:07 tomoj: jjido: the built-in uses java.util.Arrays/sort

17:07 so don't feel bad

17:15 jjido: tomoj: I threw in more iteration and I look better (2.5 times slower)

17:18 is there a built-in (fn [_] nil)?

17:19 tomoj: well.. (constantly nil)

17:19 lpetit: ,(clojure-version)

17:19 clojurebot: "1.2.0-master-SNAPSHOT"

17:19 lpetit: clojurebot still SNAPSHOT 1.2 ?

17:19 Raynes: -> (clojure-version)

17:19 sexpbot: => "1.2.0"

17:20 jjido: thanks tomoj

17:20 lpetit: Raynes: thx

17:21 jjido: it is not faster than identity, I wondered

17:26 alpheus: I just registered for the clojure-conj

17:32 jjido: I am on a Core2 Duo Mac. When I run the linear version I see both cores taken up

17:32 is that magic?

17:48 ohpauleez: is it poor style to use ^{} to tag your return value with metadata?

17:49 should (with-meta) be preferred?

17:49 jjido: The JVM will consume both cores (I believe)

17:50 jjido: ohpauleez: I see, the JIT does that?

17:50 ohpauleez: I believe so, but don't quote me on that

17:52 hiredman: ^{} tags the form read in with metadata

17:53 if the return value is not the result of the reader reading, but the result of a function call you must use with-meta

17:56 jjido: ohpauleez: yep, with -Xint the parallel version is 2x faster than the linear one

17:57 ohpauleez: hiredman: thanks man

18:10 arkh: When I run (println ((clojure.java.shell/sh "ls") :out)) from a clj file calling clojure.main, the program hangs. Any idea what's blocking? The same works fine from a repl.

18:14 peepz: hello everyone

18:14 I am new to clojure and I have a few problems when I try to use PI: java.lang.Exception: Unable to resolve symbol: pi in this context (NO_SOURCE_FILE:1)

18:14 anyone know what I am doing wrong?

18:14 dnolen: ,Math/PI

18:14 clojurebot: 3.141592653589793

18:15 dnolen: ,(+ 1 Math/PI)

18:15 clojurebot: 4.141592653589793

18:15 peepz: dnolen: looks good my friend, now how do I do it on my machine ?

18:15 dnolen: peepz: copy and paste? :)

18:15 peepz: well, what I am trying to run is: (time (doall (map pi '(200000 200000))))

18:16 ohpauleez: peepz: that 'pi' needs to be 'Math/PI'

18:16 tomoj: uhh.. no

18:16 ohpauleez: but also, you can't do that

18:16 dnolen: peepz: PI isn't a function, it's a constant, what are you trying todo there.

18:16 ?

18:17 peepz: I found that code online and it works on other machines.

18:17 Raynes: No it doesn't. Not unless pi is defined as a function.

18:17 peepz: ok ..sorry

18:17 how do I make sure I have contrib loaded correcly?

18:17 dnolen: peepz: perhaps because the code you found defines pi as a function of some sort.

18:17 jjido: arkh: maybe you need (shutdown-agents)?

18:18 peepz: dnolen: : ok

18:18 dnolen: peepz: try (require '[clojure.contrib.repl-utils :as repl-utils]) or something similar.

18:18 arkh: jjido: thanks - checking

18:18 ohpauleez: jjido: arkh does the shell stuff use agents?

18:18 peepz: dnolen: output: nil

18:18 dnolen: peepz: that's what you want to see.

18:18 arkh: (shutdown-agents) is what I needed. Weird.

18:18 peepz: so im good?

18:19 dnolen: peepz: yes, you'll get an exception if something went wrong.

18:19 ohpauleez: peepz: you should look at and play with http://github.com/relevance/labrepl

18:19 peepz: dnolen: ok thanks for all the help and thanks for a great channel.. I might hang out here for a while while I learn this:)

18:19 ohpauleez: arkh: weird, that means the shell stuff is using an agent

18:19 sthuebner: it seems, I cannot redefine a dispatch-fn on a multimethod. whatever I try, the original one sticks to the method. my fault?

18:19 dnolen: peepz: try this, (repl-utils/source map)

18:20 peepz: dnolen: I am planning to to this tutorial: http://java.ociweb.com/mark/clojure/article.html .... do you have anything you would recommend to a beginner that wants to learn clojure?

18:20 dnolen: it returned a lazy sequence of some sort.

18:21 arkh: the source here just shows it using futures, no other threading: http://bit.ly/aXsmzV

18:21 jjido: ohpauleez: if I was to write the shell stuff I would use an agent too (though Clojure should not require shutdown-agents by default IMHO)

18:21 ohpauleez: jjido: totally, I agree with that. I also think it shouldn't require the shutdown

18:22 raek: sthuebner: you need to unmap the old var manually. since 1.2, defmulti has defonce semantics

18:22 since when you used to redefine a multi method, all the previous implementations are gone

18:22 arkh: ahhh ... (future) uses clojure.lang.Agent

18:23 jjido: arkh: yes

18:23 raek: ...which used to be a bigger pain that having to manually unmap the old multimethod

18:23 sthuebner: (ns-unmap 'foo.bar.my.namespace 'my-multimethod)

18:24 ohpauleez: jjido: I might also use futures, and deref them

18:24 sthuebner: raek: OK I see. this unmaps the whole multimethod

18:24 ?

18:24 raek: yes

18:24 you need to re-evaluate all the defmethod forms

18:24 sthuebner: sure

18:24 ohpauleez: arkh: Are you using agents somewhere else in your code?

18:25 arkh: I'm not - only thing in the .clj file is (println ((clojure.java.shell/sh "ls") :out))

18:26 ohpauleez: so weird, you shouldn't have to do that call

18:27 arkh: it makes me wonder if threads are going to hang out there, e.g. if I call (sh) 5000 times, is it going to leak memory etc.?

18:27 ohpauleez: instead of printing right away, putting it in a let and printing that

18:27 arkh: well ... I guess it would leak after the first time if that were the case ...

18:27 ohpauleez: and see if it hangs

18:27 arkh: k

18:28 peepz: for the people that code in bash, what editor do you use for clojure?

18:28 jjido: peepz: I like that tutorial

18:29 peepz: jjido: ya? i will go with it then..thanks!

18:29 arkh: this still hangs (let [s (clojure.java.shell/sh "ls")] (prn s))

18:29 peepz: is clojure used in android applications?

18:30 arkh: peepz: there's some runtime problems when running clojure against dalvik (what android uses as a virtual machine)

18:30 dnolen: peepz: there's also some good books out now - Programming Clojure, Joy of Clojure, Clojure in Action. If you're a bash user, people seem to like VimClojure

18:30 ohpauleez: arkh: hmm, let me play around

18:30 peepz: ok thanks ill get that.

18:32 arkh: I have to go - have a good night/morning/afternoon all

18:33 peepz: u too thanks

18:35 ohpauleez: peepz: most editors have good support, so use whatever you're most comfortable with. A few of us use VimClojure. I think more of the community uses Emacs

18:35 but someone in here or in the Google Group will be able to help out with editor configuration issues

18:37 peepz: ohpauleez: : thanks!!!

18:37 ohpauleez: I will hold of with setting up vimclojure until I have my first script coded and working

18:39 jjido: if I have two promises p and q, can I tell Clojure to hold on realising either until both are informed?

18:40 raek: don't think so... maybe some other construct is a better fit

18:40 like BlockingQueue

18:40 peepz: I currently run clojure using this command: I want to load both jar files at launch: java -cp /usr/share/java/clojure.jar:clojure-contrib.jar clojure.main $1

18:41 how do I run that command and also execute a script with parameters? assume the function takes 1 parameter and is called namer

18:41 jjido: peepz: Windows?

18:41 peepz: ubuntu bash

18:42 raek: peepz: I guess you have alread heard this, but it tends to be easier to use a build tool (leiningen, cljr, cake) to start clojure with the correct classpath

18:42 peepz: raek: is that for ubuntu?

18:42 raek: all those work for ubuntu

18:42 peepz: hmm... ok..which one should I install/start of with?

18:43 raek: leiningen and cake are project based (essential if your program is larger than one file), and cljr is a simple way to just start a repl

18:43 peepz: cljr it is!

18:43 raek: cljr makes clojure work much like python and ruby

18:44 dnolen: jjido: ? Clojure doesn't try to realize the value of promises, it just blocks until the values are delivered. You might want to try delay, dereferencing a delay will force the computation.

18:44 raek: you can install libraries in the system and start a repl that can use all those

18:44 peepz: but I think I got the classpaths right already? how canI check in repl?

18:44 raek: in the poject based approach, all projects can have their own set of dependencies (and versions of them!) independently

18:45 peepz: are the clojure and contrib jars in the same directory?

18:45 peepz: yes

18:45 raek: peepz: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))

18:45 peepz: nil

18:46 raek: then it should be "java -cp '/usr/share/java/clojure.jar:/usr/share/java/clojure-contrib.jar' clojure.main"

18:46 peepz: so the output nil means its not working?

18:47 raek: ah, are you using slime and emacs, or some other editor-repl thingy=

18:47 try just (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))

18:47 jjido: dnolen: but if p is delivered, it is dereferenced in the waiting thread right? Then q blocks until it is delivered

18:47 raek: your *out* might be connected to the wrong terminal

18:48 println always return nil

18:49 peepz: {:cljr "http://github.com/liebke/cljr", :leiningen "http://github.com/technomancy/leiningen", :cake "http://github.com/ninjudd/cake"}

18:49 kjeldahl: Ready for a clojure quiz? ;-) How to make ([1 9] [1 8] [2 7] [1 6] [2 6) => ([1 9] [2 7]) . Basically, extract only the first vector in a sorted list based on the first number in the vector.

18:50 jjido: dnolen: mmh I suppose a promise is ever delivered only once.

18:52 peepz: raek: i got this output: (#<URL file:/usr/share/java/clojure-1.0.0.jar> #<URL file:/usr/share/java/clojure-contrib.jar>)

18:53 raek: jjido: you could try to invert the situation and use *one* BlockingQueue that the two threads put objects into. a thread that tries to take an object from it will block until someone puts an object into it

18:54 peepz: looks like clojure and clojure.contrib are good to go (assuming the filenames are correct)

18:54 peepz: ok great thanks!

18:54 clojurebot: () invokes the form inside, but there is an implied str call. The semantics are different inside the interpolated string, necessarily so.

18:54 grignaak: ,(seq (reduce (fn [m [a b]] (if (contains? m a) m (assoc m a b))) (sorted-map) [[1 2] [1 3] [2 4] [2 6]]))

18:54 clojurebot: ([1 2] [2 4])

18:54 peepz: raek: now how do I run a clojure script?

18:55 * kjeldahl highfives grignaak!

18:55 kjeldahl: Thanks.

18:55 raek: peepz: it is described here: http://clojure.org/repl_and_main

18:55 peepz: got it thanks!

18:56 raek: looks like you only need to pass the script file after the "clojure.main" argument to java

18:56 kjeldahl: grignaak: Hm. You're changing the order aren't you. I need the items in the same order as in the original sequence.

18:56 raek: I dunno if that requires the script file in question to be on the class path too...

18:57 kjeldahl: ,(seq (reduce (fn [m [a b]] (if (contains? m a) m (assoc m a b))) (sorted-map) [[2 4] [1 3] [1 2] [2 6]]))

18:57 clojurebot: ([1 3] [2 4])

18:57 raek: (the build tools simplify the classpath management very much)

18:57 grignaak: kjeldahl: hmm. I saw the "sorted list" and I *assumed*

18:58 kjeldahl: grignaak: Hey, I'm in no position to demand anything. I meant the original list was sorted.

18:58 grignaak: how is that sorted?

18:59 kjeldahl: Well, there is a score in the vector which is not shown or used in my example. Including it would actually make your solution work, assuming it would be sorted by the score.

18:59 Thanks, I think I can piece it together from here.

19:05 ,(doc nth)

19:05 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

19:14 grignaak: kjeldahl: this one is not as elegant, but it meets the requirements : http://gist.github.com/583347

19:17 kjeldahl: grignaak: Excellent, thanks. Still struggling at my end. Figure sorted-map-by would work, but it does not of course as I want to sort on something be pointed to and not the key (if I get it right).

19:18 grignaak: yep, didn't see an arg for a custom comparator

19:18 kjeldahl: Although not as elegant, your latest solution seems more adaptable to what I'm looking for right now. I'll give it a go. Thanks again.

19:22 peepz: http://pastebin.com/m1EnaPT3

19:22 shouldnt that give me an output??

19:22 kjeldahl: grignaak: Worked perfectly. Thanks!

19:23 raek: peepz: no, since hello is never called

19:23 peepz: wow ok

19:23 so the arguments is the actual procedure call and its paramters

19:23 raek: you'd have to add a (hello (first *command-line-args*))

19:24 no, the arguments just end up in the var *command-line-args*

19:24 peepz: ... (hello(first jesus))

19:24 didnt work

19:25 jjido: type error? ["jesus"]

19:25 peepz: hhehe

19:25 raek: there is no main function as in C

19:26 it simply runs all the code in the script

19:26 the defn form is just a function definition

19:26 you need to add an actual call to the function

19:26 peepz: so then how do I execute that peiece of code

19:26 clojurebot: peepcode is a commercial screencast series; see the Clojure one at http://peepcode.com/products/functional-programming-with-clojure by technomancy

19:26 peepz: ok

19:26 raek: you add it after the defn

19:27 http://pastebin.com/ZQYYFS8m

19:27 (doc *command-line-args*)

19:27 clojurebot: "; A sequence of the supplied command line arguments, or nil if none were supplied"

19:28 peepz: ohh thanks!

19:28 raek: hrm, make that (apply str (interpose \space *command-line-args*))

19:29 note: clojure programming is most often done interactively at the repl, rather than making a script file and then executing it

19:29 now I need to sleep. good night.

19:36 peepz: then how would I sent a parameter to my short script in repl?

19:37 raek: java -cp <*snip*> clojure.main script.clj arg1 arg2 arg3

19:38 in the script, *command-line-args* is bound to ("arg1" "arg2" "arg3")

19:39 peepz: yes but u are saying most coding is done right in the REPL without executing scripts from command line

19:39 raek: aha

19:39 peepz: so how do I run that piece of code in repl and pass an argument?

19:40 raek: you first evaluate your definitions by writing the into the repl

19:40 and then just call the function: (hello "world")

19:40 you can also load definitions from files

19:40 peepz: worked like a charm

19:41 last question promise :) why isnt my keyup work in repl?

19:41 it gives me : [[A

19:41 raek: yes, that's the control codes for "up"

19:42 you need to use one of the build tools to get line-editing and command history

19:42 it's not a part of clojure the language

19:42 peepz: give me an example of a build tool

19:42 raek: cljr is a good way to start

19:42 and leiningen

19:43 if you run "cljr repl" or "cljr swingrepl" you get a repl with line-editing

19:43 (after instaling cljr, of course)

19:43 peepz: it seems there is no cljr for ubuntu, i did apt-get install cljr

19:43 raek: I also recommend looking into editor integration

19:43 peepz: also googling it didnt give any info

19:43 what about vimclojure?

19:43 raek: I gave you some links before

19:44 peepz: ok ill look there.

19:44 anonymouse89: I'm trying to modify an element of an a 2d vector and and return the 2d vector. I was thinking something like (let [m [[0 0][0 0]]] (assoc m 0 (assoc (nth m 0) 0 1)))

19:44 raek: cljr http://github.com/liebke/cljr

19:44 leiningen http://github.com/technomancy/leiningen

19:44 cake http://github.com/ninjudd/cake

19:44 anonymouse89: works. But I would like something less clunky.

19:45 raek: peepz: http://www.assembla.com/wiki/show/clojure/Getting_Started

19:45 anonymouse89: assoc-in? :-)

19:46 ,(let [m [[0 0][0 0]]] (assoc-in [0 0] 1))

19:46 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$assoc-in

19:46 raek: ,(let [m [[0 0][0 0]]] (assoc-in m [0 0] 1))

19:46 clojurebot: [[1 0] [0 0]]

19:46 anonymouse89: ah, thought there might be something like that. i know of update-in

19:46 raek: a neat family of functions...

19:47 anonymouse89: but to update only 1 element I'll still have to nest them

19:47 peepz: thanks!!

19:48 raek: assoc-in only updates one value

19:48 anonymouse89: oh, duh [0 0] is the address

19:48 raek: ,(assoc-in {:a {:b 1}} [:a :b] 2)

19:48 clojurebot: {:a {:b 2}}

19:49 anonymouse89: raek: thanks, that's perfect

19:49 raek: yes, in my vectors and numbers example, the indices and values was easy to mix up

19:54 peepz: im trying to install vimclojure and I am stuck..I downloaded and unziped the package.. what do I do now? I am following: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Vim

19:59 raek: I'm not a vim user, so I cannot help you with that, I'm afraid.... In the beginning when you learn Clojure, just playing around with the repl (using, for example, cljr or the clojure jar manually) could be sufficient. I recommend getting that to work first.

19:59 you can alway copy-and-paste code from an editor into the repl...

19:59 not a very elegant way, but a simple one

20:00 good luck and happy hacking!

20:00 good night.

20:01 anonymouse89: is there a more idiomatic wasy to do this?

20:01 , (vec (take 3 (repeat (vec (take 3 (repeat 0))))))

20:01 clojurebot: [[0 0 0] [0 0 0] [0 0 0]]

20:03 hiredman: ,(repeat 3 (repeat 3 (repeat 3 0)))

20:03 clojurebot: (((0 0 0) (0 0 0) (0 0 0)) ((0 0 0) (0 0 0) (0 0 0)) ((0 0 0) (0 0 0) (0 0 0)))

20:04 anonymouse89: ,(vec (repeat 3 (vec (repeat 3 0))))

20:04 clojurebot: [[0 0 0] [0 0 0] [0 0 0]]

20:05 anonymouse89: seems good

20:06 jamesnvc: Hello; does anyone here use Vim/vimclojure?

20:06 I'm having a bit of trouble getting it set up under OS X, was wondering if anyone here could help or point to a better place to ask...

20:07 Currently, when I try to build the vimclojure jar, it errors out with "java.lang.Exception: Unmatched delimiter: ) (backend.clj:171)"

20:07 I've seen other people with that error, but no solutions...

20:08 Raynes: jamesnvc: If you don't get an answer here, there is a mailing list you can try here: http://groups.google.com/group/vimclojure

20:08 anonymouse89: I know this may not be the most helpful but, I had a bunch of problems compiling too. I ended up just downloading a prebuilt jar from a link on the mailing list.

20:08 Raynes: kotarak is the vimclojure guy

20:09 jamesnvc: Raynes: Cool, thanks

20:09 anonymouse89: Alright, I guess I'll try that if I can't get this working

20:53 hiredman: ,(doc ns-alias)

20:53 clojurebot: Pardon?

20:53 hiredman: clojurebot: jerk

20:53 clojurebot: No entiendo

20:54 hiredman: ,(doc alias)

20:54 clojurebot: "([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."

20:55 hiredman: ,(doc ns-resolve)

20:55 clojurebot: "([ns sym]); Returns the var or Class to which a symbol will be resolved in the namespace, else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."

23:36 hiredman: clojurebot: ping

23:36 clojurebot: PONG!

23:40 Raynes: clojurebot: pong

23:40 clojurebot: Qinfengxiang!

23:50 old_sound: clojurebot: 青峰乡

23:50 clojurebot: I don't understand.

23:51 hiredman: clojurebot: tranlsate from zh 青峰乡

23:51 clojurebot: I don't understand.

23:54 old_sound: clojurebot: just a village in china

23:54 clojurebot: Pardon?

23:54 old_sound: AKA QingFengXiang

Logging service provided by n01se.net