#clojure logs

2010-09-16

00:16bhenrypractical use for binding outside of testing?
00:20wwmorganbhennry: (binding [*out* *err*] (println "something")) ;print to standard error
00:40sproustHi; I have a quick question about an install problem.
00:40sproustI'm trying to get penumbra (OpenGL bindings) working.
00:41sproustlein native-deps provides this error message: Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
00:41sproustat clojure.contrib.java_utils$file__565.<init>(java_utils.clj:83
00:41sproustI looked in the source, couldn't find references to init.
00:42sproustAny hints where to dig next?
00:42sproustIt seems to be leiningen issue. I upgraded to latest stable leiningen (1.3.1) and re-ran self-install.
00:43hiredmanmeans 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
00:44sprousthiredman: thx!
00:45sproustIt must be one of the project's dependencies.
00:46sprousthiredman: 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.)
00:46hiredmanno
00:47hiredmanyou can look through your dependencies for class files
00:47sproustThere's a *bunch*.
00:48sproustI 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)
00:49hiredmancan you pastebin the stacktrace?
00:49sprousthttp://pastebin.com/y41gze5z
00:51hiredmando you have maven installed?
00:52hiredmanyou can have lein generate a pom.xml and then maven can generate a dependency graph
00:52sproustyep, maven2 (I don't know anything about it, I'm coming into Clojure from the LISP / dyn.lang angle)
00:52sproustHa, nice.
00:52sproustThx hiredman.
00:54sproustWell that'll just list the libraries.
00:54sproustWould 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?
01:12sproustre. penumbra: something's hokey with leiningen; I went the lazy route and rm'ed its repository (~/.m2), reinstalled it, and now it works!
01:33sproustMust 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).
02:32jjido,(pos? 0)
02:32clojurebotfalse
02:33jjido,(nat? 0)
02:33clojurebotjava.lang.Exception: Unable to resolve symbol: nat? in this context
02:35phobbs,(let [nat? (partial >= 0)] (nat? 0))
02:35clojurebottrue
02:36jjidophobbs: hey, you can put the operator between the operands?
02:36jjidoah I get it
02:36jjido"partial"
02:36phobbsyes
02:36phobbsI wish clojure would automatically partial functions like haskell
02:36tomoj,(let [nat? (partial >= 0)] (nat? 0.5))
02:36clojurebotfalse
02:36tomojmaybe I don't know what 'nat' stands for
02:36phobbserm
02:37phobbs,(>= 0 0.5)
02:37clojurebotfalse
02:37phobbsoh
02:37phobbsI'm flipping it again
02:37phobbshaskell habits
02:37jjidotomoj: natural numbers
02:38phobbsyeah
02:38phobbsand you have to test that it is an integer
02:38tomojthat's what I was worried about, didn't even realize that (>= 0 0.5)
02:38jjidophobbs: mmh I don't need to test that :) I just want pos? with zero included
02:38phobbsoh
02:39phobbswell then you just do (partial <= 0)
02:39phobbsor #(<= 0 %)
02:39phobbswhich is a little too perl-ish for my tastes
02:39phobbssyntax soup
02:44lancepantz_anyone else get an insatiable desire to code when the get home from work?
02:44lancepantz_i got at work
02:44lancepantz_but usually those are huge projects
02:44lancepantz_but then i come home, nothing to do
02:44lancepantz_and want to do something simple
02:45jjidohow do you read command-line arguments? Then convert to int with a default value
02:47jjido,(doc *command-line-args*)
02:47clojurebot"; A sequence of the supplied command line arguments, or nil if none were supplied"
02:48jjido,(first nil)
02:48clojurebotnil
02:50jjido,(or nil 4)
02:50clojurebot4
02:53phobbs,(doc read-line)
02:53clojurebot"([]); Reads the next line from stream that is the current value of *in* ."
02:54jjido,(.parseInt "4")
02:54clojurebotjava.lang.IllegalArgumentException: No matching field found: parseInt for class java.lang.String
02:56zmilalancepantz_, i do sometimes at-home programming. these are little hobby projects (like personal dvd and books library) or solving project-euler problems
02:56lancepantz_its a nice break
02:56lancepantz_all day i was fighting dragons in solr and jetty
02:56lancepantz_just just to come home to an empy repl feels nice
02:56lancepantz_better than tv :)
03:10jjidoif you do (+ @(future (f1)) @(future (f2))), does Clojure wait for (f1) to start (f2)?
03:11ChousukeI don't know if the order is defined but AFAIK yes.
03:12jjidobeginner's programming error :-/
03:19LauJensenGood morning all
03:20jjido,(time (doseq @(future (Thread/sleep 1000)) @(future (Thread/sleep 1000))))
03:20clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: doseq requires a vector for its binding
03:21jjido,(time (and @(future (Thread/sleep 1000)) @(future (Thread/sleep 1000))))
03:21clojurebotjava.lang.Exception: No such namespace: Thread
03:22_na_ka_na_hey guys, how do a distinguish a list, vector from a map, coll? returns false for a []
03:23_na_ka_na_,(coll? [])
03:23clojurebottrue
03:23LauJensen,(vector? '(1 2 3))
03:23clojurebotfalse
03:23LauJensen,(map? [1 2 3])
03:23_na_ka_na_,(coll? {})
03:23clojurebotfalse
03:23clojurebottrue
03:25_na_ka_na_LauJensen: I want to distinguish between a collection and an object (not necessarily a map)
03:25_na_ka_na_so map? doesn't quite do it
03:26_na_ka_na_seq? and coll? are also don't
03:26LauJensenExample?
03:26clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
03:27jjidoChousuke: it does the Right Thing, ie. it runs both at the same time
03:28_na_ka_na_LauJensen: something like .. (many? []) => true ... (many? '()) => true ... (many? (seq ..)) => true ... (many? anything-else) => false
03:30_na_ka_na_I guess many? = (comp (comp not map?) coll?)
03:30_na_ka_na_not tested
03:32LauJensen,(not-any? true? ((juxt vector? map? list?) 5))
03:32clojurebottrue
03:32jjidoChousuke: sorry my mistake, it doesn't.
03:33LauJensenThat'll test for all non-clojure types
03:33_na_ka_na_ah my bad .. (and (comp not map?) coll?)
03:33_na_ka_na_oh we have vector? and list? .. didnt know that
03:34_na_ka_na_, (source coll?)
03:34clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
03:34_na_ka_na_, (clojure.repl/source coll?)
03:34clojurebotSource not found
03:36LauJensen~source coll?
03:37_na_ka_na_,(#(and ((comp not map?) %) (coll? %)) [])
03:37clojurebottrue
03:37_na_ka_na_,(#(and ((comp not map?) %) (coll? %)) '())
03:37clojurebottrue
03:37_na_ka_na_,(#(and ((comp not map?) %) (coll? %)) {})
03:37clojurebotfalse
03:37_na_ka_na_,(#(and ((comp not map?) %) (coll? %)) 543)
03:37clojurebotfalse
03:38_na_ka_na_,(#(and ((comp not map?) %) (coll? %)) "")
03:38clojurebotfalse
03: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?
03:40_na_ka_na_changing the multimethod itself is not a pretty solution .. as all but one defmethod return only one object ..
03:41LauJensenHow 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
03: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
03:43LauJensenGood idea
03:43LauJensenIf you just let everything return a vector, you have a uniform interface
03:43_na_ka_na_thanks
03:43_na_ka_na_ya
03:48_ViWhy 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"?
03:49_Vi*list of increasing values
03:50LauJensen_Vi: for is list-comprehension, so its taking a 1000 values and returning them as a seq
03:50_ViLauJensen, Why that values are not the same?
03:51LauJensenhmm
03:51_ViLauJensen, I clearly see that q is updated by future while transaction should prevent this.
03:51LauJensenI think its because you're not comitting anything, so your transaction doesn't retry. try (dosync (for [x (range 1000)] (ensure q)))
03:52LauJensenThat will prevent q from being written to while you're working
03:54_Vi(dosync (def l (for [x (range 1000)] @q)) (ensure q) l) ; The same
03:56_ViBTW How to explicitly start a transaction? "(dosync (for [x (range 1000)] (ensure q)))" -> "No transaction running"
03:59_ViProbably understood. "for" is returning "lazy" sequence and "(ensure q)" is called not in "dosync", but while printing.
03:59raek_Vi: for is lazy, so it isn't realized until you try to print it, which happens outside the transaction. use 'doseq'
04:00raekwhich is exactly like for, except that it is not lazy and returns nil (presumably, it is used for its side-effects)
04:02raekyou can also use doall to force a lazy sequence
04:03raek(dosync (doall (for [x (range 1000)] @q))) ; will force the lazy sequence returned by for to be fully realized within the transaction
04:03raekhrm, use might not be the best fit for the acquire part...
04:03raeks/use/doseq/
04:03sexpbot<raek> hrm, doseq might not be the best fit for the acquire part...
04:03_ViYes, "doall" fixes things.
04:05raekalso, don't do ref-set + @, use 'alter' instead
04:06raek(doc alter)
04:06clojurebot"([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."
04:06raek(alter q inc)
04:09raek(dotimes [_ 1000] (Thread/sleep 10) (alter q inc))
04:09raek(dotimes [_ 1000] (Thread/sleep 10) (dosync (alter q inc))) ; *ahem*
04:15raek_Vi: (what I said after the last thing you said and when your connection died: http://pastebin.com/8XMzieFE )
04:16_Viraek, (Yes, I'm looking at http://clojure-log.n01se.net/ now but it is not yet updated to this point)
04:20_Vi(def f (future (recur))) (comment endless loop in background), (future-cancel f) ; Still looping
04:20_ViHow to really terminate it (without of restarting JVM)?
04:21raekI'm not sure that futures can be canceled at all times
04:21raekthe best way is probably to make the looping code check for a condition
04:22_Viraek, I mean if there is some broken code looping, and we need to get rid of it.
04:23_Viraek, For example, it can get stuck not in Clojure code, but in some external library.
04:24raekgood question, but unfortunately I don't know the answer
04:24jjidoanyone wants to test? I get no benefit from parallelism with a 1000 elements set http://pastebin.ca/1941926
04:24Chousuke_Vi: You can't really
04:25_ViSomething like Thread.interrupt() or Thread.stop().
04:25Chousuke_Vi: unless you get hold of the Thread instance that the future is running in and call .stop on it
04:25Chousukebut even that's deprecated
04:25Chousuke.interrupt doesn't help with broken code.
04:25_ViHow to get the Thread instance of a future?
04:25ChousukeNo idea :/ I think they run in an executor so hm.
04:26_ViE.g. how to more-or-less safely call to some binary blob that can arbitrarily do "for(;;);" just for fun?
04:28Chousuke_Vi: use Threads explicitly and .stop them. or use clj-sandbox
06:04kjeldahlAny 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.
06:04kjeldahlAnd here I am wrapping my head around for/recur/while etc. not quite figuring it out.
06:05kjeldahl,'(range 10)
06:05clojurebot(range 10)
06:05kjeldahl,'[(range 10)]
06:05clojurebot[(range 10)]
06:05kjeldahl,(range 10)
06:05clojurebot(0 1 2 3 4 5 6 7 8 9)
06:06kjeldahlLet that be the list. Say I want to read from the top, until total capacity reaches 8. 0+1+2+3+ (half of four)
06:12LauJensenkjeldahl: like this?
06:12LauJensen,(reduce #(if (< (reduce + %1) 10) (conj %1 %2) %1) [] (range 20))
06:12clojurebot[0 1 2 3 4]
06:12LauJensenWalks through (range 20), stops when the sum is > 10
06:13LauJensenor.. stops is the wrong word. But it doesn't accumulate above that point
06:13kjeldahlLet me chew on that.
06:14kjeldahlWhere's my 8?
06:14kjeldahl(the capacity I want filled)
06:14LauJensen,(reduce #(if (< (reduce + %1) 8) (conj %1 %2) %1) [] (range 20))
06:14clojurebot[0 1 2 3 4]
06:15LauJensen,(let [capacity 8] (reduce #(if (< (reduce + %1) capacity) (conj %1 %2) %1) [] (range 20)))
06:15clojurebot[0 1 2 3 4]
06:16kjeldahlExcellent. I'll see if I can munge it into something usable in my baby-steps code. Thanks.
06:16LauJensenkjeldahl: 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
06:17kjeldahlYes, this is what hit me as well. Nothing critical right now, but good to know. Thanks again.
06:19raekmaximum flow problem?
06:19bsteuberI think gen-class should do automatic conversion to camel case
06:20bsteuberso you can use the same code for java and clojure callers
06:21LauJensenkjeldahl: In case you're wondering, this is a simple loop version
06:21LauJensen(loop [x (range 20) acc []] (if (< (reduce + acc) 8) (recur (next x) (conj acc (first x))) acc))
06:21LauJensenand this is probably a little faster for larger data sets
06:21LauJensen(loop [x (range 20) acc [] sum 0] (if (< sum 8) (recur (next x) (conj acc (first x)) (+ sum (first x))) acc))
06:21LauJensen(because its not calling reduce on each loop)
06:21LauJensenim done :)
06:25pomykhello
06:25bsteuberdoes anyone else have problems with lein not returning after it's done?
06:25raekkjeldahl: you don't happen to be practicing for Nordic Collegiate Programming Contest?
06:25pomykdoes clojureql work with clojure 1.2?
06:26LauJensenkjeldahl: 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:
06:26LauJensen(loop [[x & xs] (range 20) acc [] sum 0] (if (< sum 8) (recur xs (conj acc x) (+ sum x)) acc))
06:26LauJensenpomyk: 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
06:26kjeldahlraek: No, I'm using the planetwars google ai challenge to try to teach myself some clojure.
06:27kjeldahlraek: Obviously, clojure being my first function language... :-)
06:28kjeldahl*functionAL
06:32kjeldahl,(doc negate)
06:32clojurebotExcuse me?
06:33LauJensen,(doc complement)
06:33clojurebot"([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."
06:33kjeldahl,(* -5 -1)
06:33clojurebot5
06:33kjeldahlThat's what I want. Cheat sheet says negate, but doesn't seem to exist.
06:34LauJensen,(doc unchecked-negate)
06:34clojurebot"([x]); Returns the negation of x, an int or long. Note - uses a primitive operator subject to overflow."
06:34kjeldahlThanks again.
06:34LauJensennp
06:35kjeldahlAh, didn't read the cheat sheet close enough...
06:36fbru02is it true what i read here that 1.3 will be getting a sort of maybe monad??
06:38raeklink?
06:38clojurebotyour link is dead
06:41raekthis 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)
06:41raek,-?>
06:41clojurebotjava.lang.Exception: Unable to resolve symbol: -?> in this context
06:42raek,(use '[clojure.contrib.core :only [-?> -?>>]])
06:42fbru02raek cool i will check them out
06:42clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/core__init.class or clojure/contrib/core.clj on classpath:
06:43raekthey work like ordinary -> and ->>, but stops and returns nil if any form in the chain returns nil
06:45raek-> -?>
06:45sexpbotjava.lang.Exception: Unable to resolve symbol: -?> in this context
06:45LauJensenIm glad I started so early with Clojure, coming in now and seeing functions like "$" "->" "->>" "-?>>" "#(fn %&)" etc will likely freak some people out
06:49LauJensenwhich one?
06:50raekwhen the condition of a cond clause is large enought to occupy a whole line, how do you indent?
06:50LauJensenI've suggested wrapping each line in a ()
06:50raekdidn't know that you could do that in clojure
06:51LauJensenYou cant, it was a suggested change to cond/condp/deftemplates/defsnippet et al
06:52pomykwith 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
06:52raekmaybe I could resort to use two nested ifs this time...
06:54raekpomyk: 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
06:58LauJensenIve written a quite simple factorial for beginners to model their code after:
06:58LauJensen,(letfn [(!-?> [&$ &!] (if (> &! 1)(!-?> (->> &$ (* &!))(-> &! dec))&$))](!-?> 1 5))
06:58clojurebot120
07:00raekyou could replace 'dec' with #(- % (*))
07:01LauJenseneven better
07:03raek,(letfn [(!-?> [&$ &!] (if (> &! (*))(!-?> (->> &$ (* &!))(-> &! #(- % (*))))&$))](!-?> (*) (- (* (+ (*) (*)) (+ (*) (*) (*))) (*))))
07:03clojurebotjava.lang.ClassCastException: sandbox$eval6608$_BANG___QMARK__GT___6609$_AMPERSAND__BANG___6610 cannot be cast to java.lang.Number
07:09raekI guess you have hanged out in #clojure too long when you feel the urge to have show-paren-mode in irssi...
07:10LauJensenraek: or not long enough. I have parens matching in all channels, thanks to ERC
07:10LauJensenI think this is the most elegant version
07:10LauJensen,(letfn [(!-?>[&$ &!](if(>,&!,1)(!-?>@(->>,&$,(*,&!)ref)(->,&!,dec))&$))](!-?>,1,5))
07:10clojurebot120
07:10raekERC is very high on my to-learn list
07:25tomojLauJensen: how? not paredit right?
07:25LauJensentomoj: What? I never use paredit, what are you talking about? :)
07:26tomojyou use emacs but not paredit? O_o
07:27LauJensenhttp://twitter.com/LauJensen/status/18062045007
07:28tomojyou really think so?
07:28tomojor is that just agitprop?
07:29LauJensenWhats 'agitprop' ?
07:29tomojs/agitprop/flamebait
07:29LauJensenah, well its both
07:29tomojyou really think so and it's flamebait?
07:29LauJensenYes sir
07:30tomojI'd love to hear a more detailed explanation someday
07:30LauJensenI 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
07:31tomojI see
07:32tomojwhat is it that you do while editing loads of code which is easier without paredit?
07:32LauJensenjust standard refactoring
07:32LauJensenI think. Didn't really stop and think about it :)
07:32tomojand, I don't mean to imply anything by asking this, but did you know all the bindings well?
07:32LauJensenhehe
07:33LauJensenNo I think I knew like 10%
07:33tomojok
07:33tomojcounterflame: paredit is like training wheels that turn into jet engines once you figure out how to use them
07:34LauJensenI'll tell you what I've told every individual who has made statements to that effect: Screencast or it didn't happen
07:34tomojI really want to
07:34tomojI always get frustrated with the tools
07:34AWizzArdtomoj: how do you cut the expression your cursor is on?
07:35AWizzArd(a b |(c d e) x y) ==> Keys ==> (a b x y) and (c d e) can be pasted somewhere else
07:35tomojkill-sexp, C-M-k by default
07:35AWizzArdC-k at alone this position would result in (a b)
07:36tomojright
07:36LauJensentomoj: C-M-k isn't specific to paredit
07:36tomojindeed
07:36tomojwasn't my example :)
07:36LauJensenI know, Im just keeping it real :)
07:36tomojLauJensen: have you made screencasts before?
07:37AWizzArdC-M-k doesn't work for me like this. It is doing the same as C-k
07:37tomojwould be interested in recommendations for free tools
07:37LauJensentomoj: many
07:37LauJensentomoj: Which OS are you on ?
07:37zmilaafter using paredit from CCW i feel its lack in my java programming
07:37tomojAWizzArd: check what it's bound to
07:37tomojLauJensen: ubuntu, have os x available too
07:38LauJensentomoj: 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
07:38tomojwhat resolution do you record?
07:38LauJensenPost processing takes about 5 minutes
07:38tomojI couldn't seem to find any good answers for resolutions for vimeo
07:38LauJensenI usually aim for 800x600 - No good reason
07:39LauJensentomoj: You can see my latest screencast, which was shot with Camtasia and was the correct resolution for HD - Forgot the numbers though
07:39raekcan audacity do edit video too?
07:39tomojthanks for the tips
07:39LauJensenraek: No. But there are actually good video editors of linux as well
07:39tomojI had a camtasia demo
07:40tomojalso snapz pro
07:40tomojI'll try gtk-recordMyDesktop
07:41LauJensentomoj: it supposedly can both record audio and video at the same time. But Ive never had a good result with it
07:42LauJensenSo 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
07:42LauJensenAt 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 :)
07:47LauJensentomoj: Do you have a blog where you will publish?
07:48tomojno, only a snowman http://tomojack.com/
07:48tomojI had a blog there but took it down because there'd only been one post for months
07:49LauJensenWas your name Tomas or Jack ?
07:49LauJensens/Was/Is/
07:49sexpbot<LauJensen> Is your name Tomas or Jack ?
07:49tomojthomas
07:49tomoj'tomo' a nickname from esperanto
07:50LauJensenYea I remember you told me
07:50LauJensenOk well, you'll have to announce it here then, once you're done :)
07:50tomojwill do
07:50tomojdon't hold your breath
07:50LauJensenO_O
08:04tomojLauJensen: got any ideas for what would be a good way to demo?
08:04tomojI was thinking a very simple project might be nice
08:05LauJensentomoj: You're looking to code a project live ?
08:05tomojwell, maybe
08:05tomojI don't want to just mess with contrived examples
08:05tomojI want to show using paredit to write/refactor real code
08:05LauJensentomoj: Would be great if you had some code lying around, that needing converting to protocols/records
08:36bobo_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
08:37LauJensenbobo_: Jetty is very touted for its scalability, but personally I have my doubts
08:40bobo_im not sure how i would do at all. i almost wanna say php, but i refuse
08:42nlogaxisn't it rails that can only handle 1 request at a time?
08:42nlogaxmaybe that's fixed now :)
08:45solussdI' 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?
08:46r0mansolussd: i think you must add it to the :dev-dependencies list
08:46bobo_solussd: dev-dependencies
08:46bobo_or add it to ~/.lein/plugins
08:46bobo_wher "it" is the jar
08:46bobo_~/.lein/plugins$ ls
08:46bobo_swank-clojure-1.2.1.jar
08:46clojurebothttp://www.assembla.com/wiki/show/clojure/Protocols http://clojure-log.n01se.net/date/2009-10-13.html#12:02
08:47solussdthanks, that did it.
09:02LauJensenbobo_: Ive just seen a report wherein Jetty handled 10.000 concurrent users with 250 threads and a latency of about 2.5s per request
09:02bobo_2.5s is ages on internet, but i assume that goes down pretty fast
09:04LauJensenbobo_: 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
09:04bobo_indeed
09:05bobo_would be intresting to benchmark some clojure web code
09:05bobo_maybe i should try something with some rest and curl
09:07LauJensenYea, you should need to a host and a server both on massive connections for it to have any real value
09:07fbru02how would be a good way of doing juxt over a vector ??
09:07LauJensenI mean, server and client
09:08LauJensenfbru02: What are you looking to do ?
09:08bobo_yes, massive connections i have some. i live in sweden afterall :-)
09:08LauJensenbobo_: oh right, I always forget that Denmark is Scandinavias little Africa when it comes to IT
09:08fbru02LauJensen: I have a vector of [fn(x), fn1(x)] and i want to juxt fn fn1(x)
09:08bobo_LauJensen: lol
09:09LauJensenbobo_: Its so terrible here, that its not even funny
09:09mrBlissfbru02: apply?
09:09LauJensen,(apply juxt [(print "one ") (print "two")])
09:09clojurebot#<core$juxt$fn__3657 clojure.core$juxt$fn__3657@95f865>
09:09clojurebotone two
09:09fbru02mrBliss: LauJensen thanks a lot i sometimes forget about that magic thing :)
09:11grignaakis there something that is the reverse of apply?
09:11grignaaksomething like (defn select [f] (fn [& xs] (f xs)))
09:12LauJensengrignaak: What are you looking to do with it?
09:13grignaak((#(fn [& xs] (% xs)) second) 1 2 3)
09:13grignaak,((#(fn [& xs] (% xs)) second) 1 2 3)
09:13clojurebot2
09:13grignaakwhere the lambda is replaced by the defn above
09:42fliebelIs it defined behavior(ie, something that can be relied on) that load-file returns the result of the last expression?
09:43LauJensenfliebel: judging from the doc string I would say yes
09:44jjido,(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."])
09:44clojurebotDENIED
09:44LauJensenAlso, Rich is usually pretty strict about sticking with signatures
09:45_fogus_,(#(second %&) 1 2 3)
09:45clojurebot2
09:45fliebelLauJensen: 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.
09:46grignaak_fogus_: what? you can put an & after the % ?
09:47fliebel_fogus_: Awesome! *slaps forehead as well*
09:47_fogus_grignaak: Yes. That is the #() way to say "var args"
09:47jjido/msg nickserv
09:47LauJensen_fogus_: Did you get my contribution to @learnclojure ?
09:47_fogus_Ooooo. That gives me an idea for a @learnclojure tweet
09:48bobo_i didnt know about @learnclojure!
09:48_fogus_LauJensen: I have not checked yet. I still haven't gotten the hang of managing multiple twitter accounts
09:48fliebel*follows learnclojure*
09:49jjidotest: idiot
09:49LauJensen_fogus_: It was just an attempt to make people coming from Perl a little more comfortable: http://twitter.com/LauJensen/status/24654495072
09:50_fogus_LauJensen: Love the use of commas
09:50LauJensen_fogus_: yea, its artistic :)
09:50jjidocan you make it more obfuscated
09:51LauJensennot without sacrificing elegance
09:52jsandahey 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
09:52jjidoI don't even know what !- is
09:52chouser!-?> is defined right there
09:52fliebeljjido: I think that is just a normal variable
09:52chouserLauJensen: that's really horrible. Shame on you. And ... congrats, I think.
09:52LauJensenchouser: hehe :()
09:53chouserletfn, so !-?> is a normal local function
09:53LauJensen!-?> is factorial
09:54jsandaand 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
09:57vu3rddLauJensen: Obfuscated Clojure contest?
09:58LauJensenvu3rdd: 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
09:58LauJensens/contenst/contest
09:58vu3rdd:-)
09:58LauJensens/dont/do
09:58LauJensenI should get a new keyboard
10:02bobo_would a twitter clone be a good webapp to use for benchmarking?
10:03fliebelbobo_: What do you want to benchmark?
10:03bobo_performance of clojure web stack, or something like that. Havent set a real goal
10:03LauJensen_fogus_: haha, #eyeshurt :)
10:04LauJensenbobo_: 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:05fliebelbobo_: 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:05bobo_i think i already have a twitter clone aswell, thats why i thought about that
10:05LauJensens/static/dynamic/
10:05sexpbot<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:05bobo_with redis as backend
10:06bobo_but static page can be intresting aswell
10:06bobo_then it is easier to try other languages aswell
10:14jjido,(let [n 4] (-> n dec))
10:14clojurebot3
10:15jjido,(-> 3 dec)
10:15clojurebot2
10:15chouser,(-> 3 inc inc inc)
10:15clojurebot6
10:16jjidohow about ->>?
10:16LauJensenisnt it -?>> ?
10:17LauJensenits something lpetit cooked up IIRC
10:17jjidoyou used ->> in the twitter post
10:18LauJensenooh :) I thought you were asking about -?>>
10:19LauJensen->> threads as last argument, -> as first
10:19sexpbot=> #<core$_GT_ clojure.core$_GT_@36f7a0>
10:19LauJensen(-> 5 (/ 2))
10:19LauJensen,(-> 5 (/ 2))
10:19clojurebot5/2
10:19LauJensen,(->> 5 (/ 2))
10:19clojurebot2/5
10:22jjido,(->> 5 (/ 2) (+ 1))
10:22clojurebot7/5
10:24LauJensen,(->> 5 (/ 2) inc str reverse (apply str))
10:24clojurebot"5/7"
10:26jjidolol. I was able to undo your post now.
10:40LauJensen? :)
10:41LauJensenoh, you de-scrambled it you mean ?
10:43bobo_how do i enlive (select a link with class "class"? tried everything i could think off
10:43LauJensenbobo_: [:a.class]
10:45bobo_ah, its ajax that fools me
10:58chouserbreaking changes to the contrib build have cost me at least as much time as breaking changes to the clojure language itself.
10:59RaynesSame with me and Dominos' new pizza recipe.
11:00chouserhehe, er, what?
11:01RaynesIt was a bad joke. Forgive me, I just woke up.
11:01Raynes:>
11:02chouser:-)
11:03kjeldahl,(doc doseq)
11:04Raynessdeobald: I shot you a message on github about running tryc.
11:04AWizzArdchouser: Contribs breaks were much worse for me, probably because they occur very regularily.
11:04kjeldahlFrom the doseq docs: Repeatedly executes body (presumably for side-effects) with
11:04kjeldahlbindings and filtering as provided by "for". Does not retain
11:04kjeldahlthe head of the sequence. Returns nil.
11:05kjeldahlCan anybody tell me what the "Does not retain the head of the sequence" means here?
11:05bhenryany of the rubylearning clojure for beginners class instructors on here ?
11:05AWizzArdduck-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:05RaynesDoesn't keep the sequence in memory.
11:05Raynesbhenry: Whatcha need?
11:06kjeldahlEh?
11:06chouserAWizzArd: 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:06sdeobaldRaynes: Just woke up and saw that -- thanks.
11:07bhenrykjeldahl i think it means for every time body is executed the previous results of body are ignored/unavailable/garbage collected.
11:07Rayneskjeldahl: If you hold onto the head of a sequence, it keeps it from being garbage collected.
11:07chouserkjeldahl: 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:08bhenryrubylearning.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:08Raynesbhenry: It appears to be working for me.
11:08Raynes$ping rubylearning.org
11:08chouserkjeldahl: the docs for doseq are simply saying it will not kee a reference to the head, in contrast with for example doall.
11:08sexpbotRaynes: Ping completed in 0 seconds.
11:10Raynesbhenry: I'm not sure if I can delete your second post or not, but I'll check if you want.
11:11apgwozdoes anyone know when an agenda for clojure conj is likely to be released?
11:12bhenryi can ping it, but it just hangs. it might be my computer now that i see hwo wacky my chat client is.
11:12bhenryRaynes: the first one needs to be deleted
11:12bhenryi'm going to restart, it may be my computer
11:12Raynesbhenry: Is that the shorter or the longer one?
11:12bhenryi didn't think the first one went through and added things. so the shorter one should be deleted
11:13RaynesAh, yes.
11:13RaynesDeleted.
11:13chouserapgwoz: 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:13bhenrythanks!
11:13jfieldsI 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:14jfields(I only throw the exception if the response isn't returned within the 30 seconds)
11:16chouserjfields: 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:17kjeldahlbhenry/chouser: Thanks. I'm struggling with a NPE in after a doseq finishes...
11:17kjeldahlbhenry chouser: Thanks. I'm struggling with a NPE in after a doseq finishes...
11:17sdeobaldjfields: oh, hi.
11:18jfieldschouser, cool. thanks
11:18jfieldssdeobald, hello.
11:18chouserkjeldahl: doseq does return nil, so be careful how you use that return value.
11:18sdeobaldjfields: 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:19kjeldahlchouser: Thanks. I don't use it though. It's inside a normal sequence of forms.
11:20jfieldssdeobald, will do.
11:20kjeldahlchouser: 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:20apgwozchouser: 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:20chouserkjeldahl: stack traces are usually quite helpful in tracking down NPEs
11:21chouserapgwoz: sure, I understand.
11:21kjeldahlchouser: Points to the innermost form (a logging statement). Replacing the logging statement with nil gives the same error though.
11:21RaynesI'm going just to meet chouser. <3
11:21chouserapgwoz: 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:22apgwozwell, Raynes, I'm going to meet you
11:22RaynesAw. <3
11:22chouserheck, I'd go if we were all going to be working in a box factory for two days.
11:22chouserI'm going to meet _fogus_
11:23apgwozchouser: 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:23RaynesI have never seen his face before. My motivation is slightly fueled by my curiosity.
11:23chouserRaynes: whose face?
11:23Raynes_fogus_:
11:24apgwozchouser: fogus i'd guess
11:24RaynesMinus the colon.
11:24apgwozthe picture on his website is of him in a mask
11:24chouserah. he's got pictures up if you look around.
11:24apgwozwho *is* michael fogus
11:24chouserof course that would ruin the surprise.
11:24apgwozexactly
11:24RaynesIndeed.
11:24chouserwell, you've seen the cover of the book, right?
11:24apgwozis that fogus?
11:25apgwozi didn't think he wore a top hat--just a mask
11:26dpritchettDid we ever find out who wrote the mystery foreword to JoC?
11:27_fogus_I am wearing a top hat right now
11:27RaynesI'm wearing a fedora. And a _fogus_ mask.
11:27chouserdpritchett: I heard today he's got writer's block, so we may never know...
11:28kjeldahlIs there an implicit "do" in the true part of an if statement?
11:28chouserkjeldahl: no
11:28apgwozno
11:28qbgI 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:28apgwozkjeldahl: if you don't require an else, use `when`
11:28apgwozthat *does* have an implicit `do`
11:28qbgI can only get it to work by defining the protocol after the type, and then use extend-type
11:30chouserComplex implements CMath?
11:30qbgYes
11:30chouserthen dpm you should probably hint CMath instead?
11:31chouserthen don't you want to hint CMath instead?
11:31qbgI'm hinting the methods in the CMath protocol definition
11:34qbgHmm... 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:34chouserbut you can't defined new methods in a deftype, can you?
11:34chouseronly implement existing ones from some interface
11:35qbgI could use ordinary fns instead
11:35kjeldahlapgwoz: 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:35chouseroh. well, prefer that any time it makes sense.
11:35qbgI wonder how much slower that would be though
11:36apgwozkjeldahl: no problem.
11:36chouserqbg: probably not at all.
11:36qbgI could also use ^:static in 1.3
11:36kjeldahlAs suspected; got confused with the parens again. A if - do works fine as long as I save on the parenthesis... :-)
11:37chouserqbg: if you use interop syntax to get at your deftype fields with no reflection and, right, :static fns
11:37qbgNaturally
11:38Raynesapgwoz: You have a severely intimidating last name.
11:38apgwozRaynes: hahahaha. yes.
11:38apgwozGuh-shev-itz, is how we pronounce it (gwozdziewycz for those that haven't bothered to look)
11:39RaynesEven Google said 'wut'.
11:39apgwoz(not that i expected *anyone* to look mind you)
11:39apgwozRaynes: the great thing is that i'm the only Andrew Gwozdziewycz in the world. but *not* the only Andrew GwozdziewIcz
11:39RaynesInteresting. :o
11:40apgwozbut, that pronunciation is completely americanized, and Polish speakers always get upset with me
11:49Raynesapgwoz: At least you don't have a boring name.
11:49apgwozRaynes: it does spark interesting (although also boring) conversation
11:49chouserso ... str-utils/partition is just completely gone now?
11:50chouserno string lib in contrib anymore and clojure.string doesn't have it.
12:01hiredmanclojurebot: ping?
12:01clojurebotPONG!
12:06iveyIs there anything in contrib to turn an XML doc into a nested hash, without all the XML attr bits?
12:07iveyIE: taking an XML response from REST API and getting a hash that represents same data structure
12:08chousertag names become map keys?
12:09iveyYes
12:10iveyI have a first pass in my private utils repo but realized I may have duplicated effort
12:10iveyAnd have no idea
12:10iveyWhat to do with attrs vs text contents
12:11Raynes{:tag :attrs ... :contents ...}?
12:14chouserivey: I'm not aware of such a thing
12:14iveyCool. I'll clean mine up and add better tests.
12:14chouserivey: you recursively convert the return value of xml/parse?
12:15grignaakivey: attrs as meta-data ?
12:15iveychouser: Correct, just pulling out the elements.
12:15iveygrignaak: Excellent. That's perfect.
12:15chousergrignaak: you're bound to lose data regardless if the input repeats tag names or such.
12:16grignaaktrue dat
12:16grignaak:(
12:16iveyrepeated tag names turn into an array
12:16chouservector I hope. :-)
12:17iveyHeh. My Ruby bias is showing. Indeed a vector.
12:17amalloychouser: are repeated tag names allowed? i thought they weren't
12:17amalloyer, repeated attr names
12:17chouseramalloy: ah, no. But I was talking about tag names.
12:31iveyWhat's the best way to distribute a little util like that? Put it in my utils lib on GitHub/clojars
12:32chousergood question. interested in giving it to contrib?
12:33ohpauleez... and the crowd chanted to give it to contrib
12:33ohpauleez:)
12:34chouserfriction 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:35chouserfriction 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:35RaynesOops.
12:36RaynesI meant to kill the local -dev instance. >.>
12:36ohpauleezMr Houser is raising all the best points... The crowd goes wild and cheers for more
12:36iveycontrib sounds perfect
12:36ohpauleezI'm turning #clojure into an adventure game
12:36chouserfriction 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:37Raynesjava.lang.IllegalArgumentException: No matching method found: clojure.core/nanoTime
12:37Rayneswut
12:37ohpauleezContrib has won, the day is saved
12:38chouserof 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:38iveyThat's what makes it fun
12:38RaynesWhat is clojure.core/nanoTime?
12:38RaynesIt doesn't appear to exist.
12:39chouserRaynes: what's trying to use it?
12:39Raynestime
12:39chouserIt's System/nanoTime
12:40chouserclojure.core/time is still using the old interop syntax.
12:40scottjAdded arg list highlighting (ala slime w/ common lisp or eldoc) to swank-clojure last night: http://github.com/scottjad/swank-clojure/commit/2b8f6052552c062b7b42b655c46713d963374340
12:40RaynesI just looked at the macro expansion.
12:40chouserSystem/nanoTime === (. System (nanoTime))
12:40Raynes (. java.lang.System (clojure.core/nanoTime))
12:40chouserheh, yeah -- the compiler ignores the namespace (if any) of the method name
12:41RaynesHow odd...
12:41RaynesMust be a clj-sandbox bug.
12:41Raynes:\
12:42RaynesI'm starting to consider just stealing clojurebot's sandbox.
12:42RaynesAt least for now.
12:53amalloyscottj: what are the chances of getting slime to recognize (apply inc |) and supply the parameters for inc instead of apply?
12:55scottjamalloy: hmm, I think it would be pretty easy
12:55amalloycause it seems like that would be super-useful and nobody ever forgets the arguments to apply :)
12:56scottjwell I'd have it still show args to apply when cursor is on apply
12:59amalloysure of course
13:07scottjhmm, eldoc doesn't do that. does CL?
13:13amalloyyes
13:14amalloyM-x slime
13:14amalloy(apply 1+ |
13:14amalloy(1+ arg0)
13:16Raynes-> (time (range 1 10000))
13:16sexpbot=> "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:17RaynesYes, yes. LauJensen will be pleased.
13:17RaynesAlso, failgist...
13:17RaynesIt shouldn't even try to gist something that large.
13:18scottjinteresting, arglists and C-c C-d C-d appears broken for functions with =. not= actually shows for not, >= for >
13:18amalloyRaynes: very cool
13:19RaynesActually, it doesn't seem to do that every time.
13:19Raynes-> (time (range 1 10000))
13:19sexpbot=> "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:19RaynesWeird!
13:19RaynesOnly did it that one time.
13:19RaynesMoving on.
13:29amalloyanyone know how to get emacs to interact with the x copy/paste buffer?
13:30amalloyit's kinda a pain to mark with the keyboard and have to use the menubar to copy
13:30scottjmaybe (setq x-select-enable-clipboard t)
13:32chouser"*p in vim :-)
13:34amalloyaha
13:35amalloylovely. thanks scottj
13:35amalloyi wonder how it interacts with multiple entries in the kill buffer/ring/whatever it is
13:40LauJensenRaynes: Well done old friend :)
13:41RaynesLauJensen: Had to fix a bug in clj-sandbox to get there. :p
13:42bhenryany solid emacs configs for clojure code folding?
13:43LauJensenHmmm, I had that a one point, forgot how though
13:43LauJensenAnd, didn't use it enough to keep it
13:46bhenryideally 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:52jjido,(doc deliver)
13:52clojurebot"([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:54amalloyis clojure-bot clever enough to give up on @(promise)?
13:54RaynesYes.
13:55amalloywoo 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:56RaynesUh, very, very carefully. It's a little tricky.
13:56jjidoamalloy: you like to torture little animals?
13:56jjido;)
13:57Raynes-> @(promise)
13:57sexpbotExecution Timed Out!
13:57Raynesamalloy: You'd never break either of the bots with any sort of time thing. They both timeout.
13:58RaynesI doubt you'll break anyone's heart if you actually do manage to break it.
13:59RaynesAt least, nobody has given sexpbot the courtesy of not breaking the running copy. ;)
14:00RaynesEspecially _ato. He's *destroyed* sexpbot's security measures on a few occasions. <3
14:00jjidois it bad to use (future) even if I don't care about the return value? (doing deliver)
14:01RaynesThe 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:02LauJensenjjido: future is fine if you dont care about the return
14:02RaynesExcept if an exception is thrown.
14:02jjidoI will resolve the promise anyway, and deliver is the last peration
14:03jjidooperation in the task
14:05dpritchettI 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:05dpritchetthttp://www.google.com/trends?q=node.js,+clojure&amp;ctab=0&amp;geo=all&amp;date=mtd&amp;sort=0
14:05ohpauleezHow do you type hint a ref? I'm going to guess ^IRef
14:06LauJensendpritchett: Good idea
14:06ohpauleezI also like that idea
14:06dpritchettNode Knockout seems to have been partially sponsored by Joyent, the employer of Node's creator Ryan Dahl.
14:07iveyRy is such a cool dude
14:07iveyWorked with him on merb. He used to have a blog that was all little comics he drew about his day
14:08LauJensenFeb10 was good, http://www.statsaholic.com/scala-lang.org+bestinclass.dk+clojure.org :)
14:09jjidohow do I get the promise value
14:10jjidoI forgot
14:10dpritchettWhat was your biggest article in February, the Reddit clone or the language roundup?
14:10LauJensenHmm, dont recall
14:11amalloyjjido: @promise-ref
14:11dpritchettWhat 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:12jjidoamalloy: clojure.core$promise cannot be cast to clojure.lang.IDeref
14:12amalloyworks for me
14:13amalloy,(let [x (promise)] (deliver x 10) x)
14:13clojurebot#<core$promise$reify__5534@15e909c: 10>
14:13chouserdpritchett: I was pondering yesterday if it would be possible to build something like that on top of google app engine.
14:13amalloy,(let [x (promise)] (deliver x 10) @x)
14:13clojurebot10
14:14chouserohpauleez: what Java method of a ref are you calling directly?
14:14amalloyjjido: you seem to have typed @promise
14:14amalloythat derefs the *function* promise, not the specific promise instance you created
14:14ohpauleezI'm passing in a ref that is alter'd
14:15ohpauleezintended to be done in a dosync, obv
14:15ohpauleezchouser: ^
14:15chouserbut if you don't call a java method of it directly, you shouldn't need to hint
14:15dpritchettVMForce 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:16chouser@x is no faster if x is hinted than if it is not
14:16ohpauleezah, ok
14:16ohpauleezif x is a ref to a PersistentQueue... ?
14:17chouser(pop @x) still has no reflection
14:17ohpauleezahh, ok, thanks
14:17ohpauleezI've just been getting in the habit of typing for clarity sake
14:18amalloyohpauleez: 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:18chouserhints 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:18ohpauleezright
14:19amalloychouser: really? the compiler can always figure out what's going on in the absence of interop?
14:19chouserwell, yes.
14:20chouseruntil :static fns it never had to.
14:20chouserbecause fns are not overloaded on arg type
14:21amalloyi see. that makes sense
14:22chouserand 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:24chouserand prototype fns are special and achieve nearly raw method call speeds with runtime call-site caching rather than type knowledge at compile time.
14:24LauJensenDoes anyone here have a snippet of a simple override of TableCellRenderer for JTable ?
14:24chouserLauJensen: I think so, hang on
14:24LauJensenchouser: prototype fns?
14:25chouserLauJensen: sorry, protocol fns. the fns generated by defprotocol
14:25LauJensenThought so, just wondering if you had sneaked some new feature in
14:25LauJensenchouser: btw, did you blog about call-site caching yet?
14:27chouserLauJensen: http://gist.github.com/582903 TableCellRenderer]
14:27chousernope, haven't blogged about anything in a while.
14:27chousershould I blog about call-site caching?
14:27LauJensenchouser: thanks alot, exactly what I was looking for
14:28LauJensenchouser: Yea, we talked about it a month or so ago, perhaps 2. We both thought it was a good idea
14:28chouserheh. oh!
14:30jjidomy Internet time finished. I will catch up later.
14:31edbondwhy (read-line) immediately return nil?
14:35scottjcause it doesn't work in slime
14:57edbondscottj: is it possible to make it works?
15:00LauJensenedbond: just eval your code in the *inferior-lisp* buffer
15:13scottjFYI *inferior-lisp* will only be there with slime project M-x thing not lein
15:14LauJensenyea, I typically start my coding with M-x swank-clojure-project
15:15scottjis swank-clojure-project deprecated?
15:15Raynesswank-clojure.el is deprecated. I'm not sure where swank-clojure-project went.
15:16LauJensenRaynes: It just moved to a new maintainer. Its not deprecated
15:16Raynesdeprecated or just optional. Not sure.
15:16RaynesShouldn't put the cart before the horse.
15:16LauJensenIts always been optional
15:17RaynesI 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:18LauJensenwell, if you want you can run lein swank && slime-connect instead, but you miss out on the inferior lisp buffer, which truely sucks
15:18LauJensenBesides, its a small patch to make swank-clojure.el work with the new lib/dev/* structure
15:20RaynesI've always did the former.
15:20RaynesNot sure why I would want the inferior lisp buffer.
15:20LauJensenSo you go check a console everytime you need to see output/traces from a thread?
15:21RaynesUh... huh?
15:22LauJensenIn 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:23LauJensenI usually have left buffer: code, right top: inferior lisp, right bottom: slime-repl
15:23RaynesCould you show me an example?
15:23LauJensenAt least when Im doing threaded stuff
15:23LauJensen,(future (println "hi"))
15:23clojurebot#<core$future_call$reify__5492@1f16561: :pending>
15:23LauJensenThat will print in inferior-lisp
15:24LauJensenAnd besides. Its great whenever you start hacking, just to open project.clj, hit M-x swank-clojure-project and off you go
15:24RaynesFair enough. I've never noticed that before.
15:24RaynesI don't guess I've ever wanted output from threads before.
15:25shooverLauJensen: you know about slime-redirect-inferior-output?
15:25scottjthe 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:25LauJensenshoover: nope
15:25shooverrun it, and you won't need to look in inferior-lisp
15:25RaynesOh cool.
15:25LauJensenscottj: good point about input
15:26shooverbut I can't figure out how to get the same behavior with lein swank, it only works with inferior-lisp
15:26LauJensenshoover: cool
15:26shooverso it still supports swank-clojure-project :)
15:27apgwozanyone using ant for builds and using emacs?
15:27RaynesThe latter.
15:27LauJensenapgwoz: of course not, we're all rational people here :)
15:27Raynes(:
15:28apgwozLauJensen: my company uses ant and java (no clojure -- yet).
15:28LauJensenant and maven are invented by dentists
15:28apgwozanyway, point being, i wrote some wrappers for ant around compilation mode that might be helpful to folks
15:28shooverLauJensen: 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:28clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
15:29LauJensenshoover: whats the point when we have swank-clojure-project?
15:29LauJensenexcept having less stuff to maintain
15:29apgwozshoover: i saw that as well, but haven't yet integrated it
15:29LauJensenbut elisp just sits there
15:29shooverLauJensen: right
15:37shooverLauJensen: 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:46shooverWhenever 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:52hiredman#clojure has some dumb mode set on the channel so you cannnot change nicks while in it
15:53RaynesI know.
15:53RaynesIt's horrible.
15:53technomancyshoover: you can register your fallback nick. I agree it's very annoying.
15:53Raynes:(
15:53Raynes#concatenative has the same thing set, so if I accidentally join without identifying, I have to leave both channels.
15:58Chousukeyou don't need to actually register two nicknames, you can link an alt to the existing registration
15:59sthuebnerChousuke: how would you do that?
15:59Chousuke/msg nickserv help :)
15:59chouserhiredman: can we turn off that mode?
15:59chouserI don't remember having any real problems with spam or anything before it was changed for us
16:00sthuebnerChousuke: ah, nickserver! never mind
16:01hiredmanchouser: no idea
16:03technomancywhat's the status on ticket #315?
16:03technomancywould really love to see that applied so everyone could reduce AOT usage
16:03technomancyconsidering it's a patch to clojure.main submitted by the author of clojure.main it seems like a no-brainer.
16:05lpetitticket 322 is important too, regarding AOT compilation
16:06cemericklpetit: I saw you're now a speaker at the conj, congrats! :-)
16:08lpetitcemerick: yeah, thanks, it's so impressive that I kind of haven't totally realized yet the chance I have !
16:08cemericktechnomancy: I'm mostly hoping all of them will be :-)
16:09technomancywell... I only have time to prepare one talk. =)
16:09technomancybut I'd love to hear three apiece from everyone else
16:09lpetitindedd ticket 315 seems both interesting and low hanging fruit
16:09lpetitso do I !
16:10chousertechnomancy: heh
16:11chouserI'm already doing a different one for Strange Loop.
16:12lpetitSoo 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:13cemericklpetit: some very wise bets will have to be made
16:13lpetitcemerick: :-/
16:13lpetitcemerick: talking about IDE features ... :-)
16:14lpetitcemerick: PING !
16:14cemerickhah
16:14cemerickPatience, patience :-)
16:14cemerickIt's been a busy couple of weeks
16:14_fogus_technomancy: 3!?!
16:16technomancy_fogus_: oh right; only 2 abstracts were required. I had a third, so I threw it in there.
16:17cemerick_fogus_: I'd happily do 3. Hoping to, actually.
16:17cemerickThe fourth I'm not so excited about, but it's a common pain/interest point.
16:17Raynestechnomancy: 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:17RaynesI was highly disappointed that that one didn't make it into 1.2
16:17technomancyRaynes: 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:19Chouser1Hello?
16:19clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline Chouser1
16:19Rayneso.o
16:19Chouser1I'm not a girl!
16:20nakkaya22223333testing
16:20jjidoHello?
16:20clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline jjido
16:20jjidolol
16:20@chouserok, we'll try that for a while.
16:21shooverchouser: on behalf of users of finicky ISPs and freenode servers everywhere, thank you
16:21@chousershoover: :-)
16:22@chousershoover: sorry about the twitter search brokenness, too. Afraid I don't know how to proceed on that one.
16:22shooverchouser: not your problem. I've filed multiple bug reports to no avail
16:22chouserwhy should they care, after all. You're only a user, not a customer.
16:22jjido,(let [x promise] (future (apply (partial deliver x) 3)) @x)
16:22clojurebotjava.lang.ClassCastException: clojure.core$promise cannot be cast to clojure.lang.IDeref
16:22jjidowhy?
16:22clojurebotwhy not?
16:23chouser(promise) not promise
16:23jjidoaaah
16:24shooverchouser: according to al3x, they have ample resources now, so I'll expect a fix any day now
16:24jjido,(let [x (promise)] (future (apply (partial deliver x) 3)) @x)
16:24chouserheh
16:24clojurebotExecution Timed Out
16:24chouser[3] not 3
16:24jjido,(let [x (promise)] (future (apply (partial deliver x) [3])) @x)
16:24clojurebot3
16:25Raynes-> (let [x (promise)] (future (apply (partial deliver x) [3])) @x)
16:25sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/future-call)
16:25RaynesDoh
16:26Raynes-> (let [x (promise)] (future (apply (partial deliver x) [3])) @x)
16:26sexpbot=> 3
16:26RaynesThat's more like it.
16:27jjidowhat did you do?
16:27LauJensen shoover: Pretty simple to make swank-clojure-project eval your core.clj or something like that, if you want to boot a jetty
16:27dnolen,(let [x (promise) y (promise)] (future (doall (map deliver [x y] [3 4]))) (+ @x @y))
16:27clojurebot7
16:27RaynesI 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:28RaynesWell, two bot commands.
16:28jjidoRaynes: funny you can do that in so less time
16:28nakkaya22223333testing
16:28jjidomemo: when you do CPS, don't forget trampoline in the parallel threads.
16:28RaynesIt's a pretty fast process. I already had the relevant file open in Emacs, and with magit, committing and pushing was a breeze.
16:29jjdkdkhello
16:29jjidojjdkdk: are we related?
16:29nakkaya22223333still
16:30jjdkdkjjido: nah, just random
16:30Raynes~max
16:30clojurebotmax people is 313
16:30RaynesWhoa.
16:31jjidonot far
16:31jjidoRaynes: is that the upper limit?
16:31RaynesYes.
16:31nakkaya22223333still testing
16:32Raynesnakkaya22223333: What exactly are you testing?
16:32RaynesMy patience? :p
16:32nakkaya22223333http://nakkaya.com/2010/02/10/a-simple-clojure-irc-client/
16:32RaynesI should really do something like that with Irclj as an example.
16:33nakkaya22223333from slime repl, sorry Raynes
16:33jjido,(Integer/parseInt nil)
16:33clojurebotjava.lang.NumberFormatException: null
16:33Raynesnakkaya22223333: It's cool. <3
16:33jjidois there apply-if-not-nil?
16:35nakkaya22223333works good once I figured out that sending a message is actually a privmsg to #clojure with a : in front of the text
16:35nakkaya22223333and that my message doesn't show in swank
16:35jjido,(Integer/parseInt (or nil "5"))
16:35clojurebot5
16:37nakkaya22223333later, thanks
16:39Raynesjjido: Also, see clojure.contrib.core/-?>>
16:39jjido,(-?>> Integer/parseInt (nil))
16:39clojurebotjava.lang.Exception: Unable to resolve symbol: -?>> in this context
16:41Raynes-> (clojure.contrib.core/-?>> nil Integer/parseInt)
16:41sexpbot=> nil
16:44lancepantzwe've got our first los angeles clojure meetup tonight if anyone is in the area http://bit.ly/9F9DJp
16:45Rayneslancepantz: Sure, I'm only like on the other side of the country. ;)
16:53jjidoCould someone try that code on a big vector of unsorted numbers? http://pastebin.ca/1942389
16:53jjidoif you have several cores
16:54jjidoit takes a number, 0, 1, 2... default 5
16:59dnolenfor $0.68 an hour you can also try it yrself on an 8-core box on Amazon EC2 ;)
16:59dnolenjjido: ^
17:00jjidodnolen: ok ;)
17:01LauJensenGood night Clojure, whereever you are
17:02grignaakdnolen: you can get boxes that are $0.02/per hour new
17:02lancepantzan 8 core one?
17:03lancepantzor are you talking about the micro instances
17:05jjidothe built-in sort function is almost 10x faster on my computer, and using 2 threads does not help :(
17:07tomojjjido: the built-in uses java.util.Arrays/sort
17:07tomojso don't feel bad
17:15jjidotomoj: I threw in more iteration and I look better (2.5 times slower)
17:18jjidois there a built-in (fn [_] nil)?
17:19tomojwell.. (constantly nil)
17:19lpetit,(clojure-version)
17:19clojurebot"1.2.0-master-SNAPSHOT"
17:19lpetitclojurebot still SNAPSHOT 1.2 ?
17:19Raynes-> (clojure-version)
17:19sexpbot=> "1.2.0"
17:20jjidothanks tomoj
17:20lpetitRaynes: thx
17:21jjidoit is not faster than identity, I wondered
17:26alpheusI just registered for the clojure-conj
17:32jjidoI am on a Core2 Duo Mac. When I run the linear version I see both cores taken up
17:32jjidois that magic?
17:48ohpauleezis it poor style to use ^{} to tag your return value with metadata?
17:49ohpauleezshould (with-meta) be preferred?
17:49ohpauleezjjido: The JVM will consume both cores (I believe)
17:50jjidoohpauleez: I see, the JIT does that?
17:50ohpauleezI believe so, but don't quote me on that
17:52hiredman^{} tags the form read in with metadata
17:53hiredmanif the return value is not the result of the reader reading, but the result of a function call you must use with-meta
17:56jjidoohpauleez: yep, with -Xint the parallel version is 2x faster than the linear one
17:57ohpauleezhiredman: thanks man
18:10arkhWhen 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:14peepzhello everyone
18:14peepzI 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:14peepzanyone know what I am doing wrong?
18:14dnolen,Math/PI
18:14clojurebot3.141592653589793
18:15dnolen,(+ 1 Math/PI)
18:15clojurebot4.141592653589793
18:15peepzdnolen: looks good my friend, now how do I do it on my machine ?
18:15dnolenpeepz: copy and paste? :)
18:15peepzwell, what I am trying to run is: (time (doall (map pi '(200000 200000))))
18:16ohpauleezpeepz: that 'pi' needs to be 'Math/PI'
18:16tomojuhh.. no
18:16ohpauleezbut also, you can't do that
18:16dnolenpeepz: PI isn't a function, it's a constant, what are you trying todo there.
18:16dnolen?
18:17peepzI found that code online and it works on other machines.
18:17RaynesNo it doesn't. Not unless pi is defined as a function.
18:17peepzok ..sorry
18:17peepzhow do I make sure I have contrib loaded correcly?
18:17dnolenpeepz: perhaps because the code you found defines pi as a function of some sort.
18:17jjidoarkh: maybe you need (shutdown-agents)?
18:18peepzdnolen: : ok
18:18dnolenpeepz: try (require '[clojure.contrib.repl-utils :as repl-utils]) or something similar.
18:18arkhjjido: thanks - checking
18:18ohpauleezjjido: arkh does the shell stuff use agents?
18:18peepzdnolen: output: nil
18:18dnolenpeepz: that's what you want to see.
18:18arkh(shutdown-agents) is what I needed. Weird.
18:18peepzso im good?
18:19dnolenpeepz: yes, you'll get an exception if something went wrong.
18:19ohpauleezpeepz: you should look at and play with http://github.com/relevance/labrepl
18:19peepzdnolen: 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:19ohpauleezarkh: weird, that means the shell stuff is using an agent
18:19sthuebnerit seems, I cannot redefine a dispatch-fn on a multimethod. whatever I try, the original one sticks to the method. my fault?
18:19dnolenpeepz: try this, (repl-utils/source map)
18:20peepzdnolen: 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:20peepzdnolen: it returned a lazy sequence of some sort.
18:21arkhthe source here just shows it using futures, no other threading: http://bit.ly/aXsmzV
18:21jjidoohpauleez: 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:21ohpauleezjjido: totally, I agree with that. I also think it shouldn't require the shutdown
18:22raeksthuebner: you need to unmap the old var manually. since 1.2, defmulti has defonce semantics
18:22raeksince when you used to redefine a multi method, all the previous implementations are gone
18:22arkhahhh ... (future) uses clojure.lang.Agent
18:23jjidoarkh: yes
18:23raek...which used to be a bigger pain that having to manually unmap the old multimethod
18:23raeksthuebner: (ns-unmap 'foo.bar.my.namespace 'my-multimethod)
18:24ohpauleezjjido: I might also use futures, and deref them
18:24sthuebnerraek: OK I see. this unmaps the whole multimethod
18:24sthuebner?
18:24raekyes
18:24raekyou need to re-evaluate all the defmethod forms
18:24sthuebnersure
18:24ohpauleezarkh: Are you using agents somewhere else in your code?
18:25arkhI'm not - only thing in the .clj file is (println ((clojure.java.shell/sh "ls") :out))
18:26ohpauleezso weird, you shouldn't have to do that call
18:27arkhit 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:27ohpauleezinstead of printing right away, putting it in a let and printing that
18:27arkhwell ... I guess it would leak after the first time if that were the case ...
18:27ohpauleezand see if it hangs
18:27arkhk
18:28peepzfor the people that code in bash, what editor do you use for clojure?
18:28jjidopeepz: I like that tutorial
18:29peepzjjido: ya? i will go with it then..thanks!
18:29arkhthis still hangs (let [s (clojure.java.shell/sh "ls")] (prn s))
18:29peepzis clojure used in android applications?
18:30arkhpeepz: there's some runtime problems when running clojure against dalvik (what android uses as a virtual machine)
18:30dnolenpeepz: 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:30ohpauleezarkh: hmm, let me play around
18:30peepzok thanks ill get that.
18:32arkhI have to go - have a good night/morning/afternoon all
18:33peepzu too thanks
18:35ohpauleezpeepz: 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:35ohpauleezbut someone in here or in the Google Group will be able to help out with editor configuration issues
18:37peepzohpauleez: : thanks!!!
18:37peepzohpauleez: I will hold of with setting up vimclojure until I have my first script coded and working
18:39jjidoif I have two promises p and q, can I tell Clojure to hold on realising either until both are informed?
18:40raekdon't think so... maybe some other construct is a better fit
18:40raeklike BlockingQueue
18:40peepzI 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:41peepzhow do I run that command and also execute a script with parameters? assume the function takes 1 parameter and is called namer
18:41jjidopeepz: Windows?
18:41peepzubuntu bash
18:42raekpeepz: 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:42peepzraek: is that for ubuntu?
18:42raekall those work for ubuntu
18:42peepzhmm... ok..which one should I install/start of with?
18:43raekleiningen 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:43peepzcljr it is!
18:43raekcljr makes clojure work much like python and ruby
18:44dnolenjjido: ? 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:44raekyou can install libraries in the system and start a repl that can use all those
18:44peepzbut I think I got the classpaths right already? how canI check in repl?
18:44raekin the poject based approach, all projects can have their own set of dependencies (and versions of them!) independently
18:45raekpeepz: are the clojure and contrib jars in the same directory?
18:45peepzyes
18:45raekpeepz: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
18:45peepznil
18:46raekthen it should be "java -cp '/usr/share/java/clojure.jar:/usr/share/java/clojure-contrib.jar' clojure.main"
18:46peepzso the output nil means its not working?
18:47raekah, are you using slime and emacs, or some other editor-repl thingy=
18:47raektry just (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))
18:47jjidodnolen: but if p is delivered, it is dereferenced in the waiting thread right? Then q blocks until it is delivered
18:47raekyour *out* might be connected to the wrong terminal
18:48raekprintln always return nil
18:49raekpeepz: {:cljr "http://github.com/liebke/cljr&quot;, :leiningen "http://github.com/technomancy/leiningen&quot;, :cake "http://github.com/ninjudd/cake&quot;}
18:49kjeldahlReady 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:50jjidodnolen: mmh I suppose a promise is ever delivered only once.
18:52peepzraek: i got this output: (#<URL file:/usr/share/java/clojure-1.0.0.jar> #<URL file:/usr/share/java/clojure-contrib.jar>)
18:53raekjjido: 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:54raekpeepz: looks like clojure and clojure.contrib are good to go (assuming the filenames are correct)
18:54peepzok great thanks!
18:54clojurebot() invokes the form inside, but there is an implied str call. The semantics are different inside the interpolated string, necessarily so.
18:54grignaak,(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:54clojurebot([1 2] [2 4])
18:54peepzraek: now how do I run a clojure script?
18:55kjeldahlThanks.
18:55raekpeepz: it is described here: http://clojure.org/repl_and_main
18:55peepzgot it thanks!
18:56raeklooks like you only need to pass the script file after the "clojure.main" argument to java
18:56kjeldahlgrignaak: Hm. You're changing the order aren't you. I need the items in the same order as in the original sequence.
18:56raekI dunno if that requires the script file in question to be on the class path too...
18:57kjeldahl,(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:57clojurebot([1 3] [2 4])
18:57raek(the build tools simplify the classpath management very much)
18:57grignaakkjeldahl: hmm. I saw the "sorted list" and I *assumed*
18:58kjeldahlgrignaak: Hey, I'm in no position to demand anything. I meant the original list was sorted.
18:58grignaakhow is that sorted?
18:59kjeldahlWell, 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:59kjeldahlThanks, I think I can piece it together from here.
19:05kjeldahl,(doc nth)
19:05clojurebot"([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:14grignaakkjeldahl: this one is not as elegant, but it meets the requirements : http://gist.github.com/583347
19:17kjeldahlgrignaak: 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:18grignaakyep, didn't see an arg for a custom comparator
19:18kjeldahlAlthough 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:22peepzhttp://pastebin.com/m1EnaPT3
19:22peepzshouldnt that give me an output??
19:22kjeldahlgrignaak: Worked perfectly. Thanks!
19:23raekpeepz: no, since hello is never called
19:23peepzwow ok
19:23peepzso the arguments is the actual procedure call and its paramters
19:23raekyou'd have to add a (hello (first *command-line-args*))
19:24raekno, the arguments just end up in the var *command-line-args*
19:24peepz... (hello(first jesus))
19:24peepzdidnt work
19:25jjidotype error? ["jesus"]
19:25peepzhhehe
19:25raekthere is no main function as in C
19:26raekit simply runs all the code in the script
19:26raekthe defn form is just a function definition
19:26raekyou need to add an actual call to the function
19:26peepzso then how do I execute that peiece of code
19:26clojurebotpeepcode is a commercial screencast series; see the Clojure one at http://peepcode.com/products/functional-programming-with-clojure by technomancy
19:26peepzok
19:26raekyou add it after the defn
19:27raekhttp://pastebin.com/ZQYYFS8m
19:27raek(doc *command-line-args*)
19:27clojurebot"; A sequence of the supplied command line arguments, or nil if none were supplied"
19:28peepzohh thanks!
19:28raekhrm, make that (apply str (interpose \space *command-line-args*))
19:29raeknote: clojure programming is most often done interactively at the repl, rather than making a script file and then executing it
19:29raeknow I need to sleep. good night.
19:36peepzthen how would I sent a parameter to my short script in repl?
19:37raekjava -cp <*snip*> clojure.main script.clj arg1 arg2 arg3
19:38raekin the script, *command-line-args* is bound to ("arg1" "arg2" "arg3")
19:39peepzyes but u are saying most coding is done right in the REPL without executing scripts from command line
19:39raekaha
19:39peepzso how do I run that piece of code in repl and pass an argument?
19:40raekyou first evaluate your definitions by writing the into the repl
19:40raekand then just call the function: (hello "world")
19:40raekyou can also load definitions from files
19:40peepzworked like a charm
19:41peepzlast question promise :) why isnt my keyup work in repl?
19:41peepzit gives me : [[A
19:41raekyes, that's the control codes for "up"
19:42raekyou need to use one of the build tools to get line-editing and command history
19:42raekit's not a part of clojure the language
19:42peepzgive me an example of a build tool
19:42raekcljr is a good way to start
19:42raekand leiningen
19:43raekif you run "cljr repl" or "cljr swingrepl" you get a repl with line-editing
19:43raek(after instaling cljr, of course)
19:43peepzit seems there is no cljr for ubuntu, i did apt-get install cljr
19:43raekI also recommend looking into editor integration
19:43peepzalso googling it didnt give any info
19:43peepzwhat about vimclojure?
19:43raekI gave you some links before
19:44peepzok ill look there.
19:44anonymouse89I'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:44raekcljr http://github.com/liebke/cljr
19:44raekleiningen http://github.com/technomancy/leiningen
19:44raekcake http://github.com/ninjudd/cake
19:44anonymouse89works. But I would like something less clunky.
19:45raekpeepz: http://www.assembla.com/wiki/show/clojure/Getting_Started
19:45raekanonymouse89: assoc-in? :-)
19:46raek,(let [m [[0 0][0 0]]] (assoc-in [0 0] 1))
19:46clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$assoc-in
19:46raek,(let [m [[0 0][0 0]]] (assoc-in m [0 0] 1))
19:46clojurebot[[1 0] [0 0]]
19:46anonymouse89ah, thought there might be something like that. i know of update-in
19:46raeka neat family of functions...
19:47anonymouse89but to update only 1 element I'll still have to nest them
19:47peepzthanks!!
19:48raekassoc-in only updates one value
19:48anonymouse89oh, duh [0 0] is the address
19:48raek,(assoc-in {:a {:b 1}} [:a :b] 2)
19:48clojurebot{:a {:b 2}}
19:49anonymouse89raek: thanks, that's perfect
19:49raekyes, in my vectors and numbers example, the indices and values was easy to mix up
19:54peepzim 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:59raekI'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:59raekyou can alway copy-and-paste code from an editor into the repl...
19:59raeknot a very elegant way, but a simple one
20:00raekgood luck and happy hacking!
20:00raekgood night.
20:01anonymouse89is there a more idiomatic wasy to do this?
20:01anonymouse89, (vec (take 3 (repeat (vec (take 3 (repeat 0))))))
20:01clojurebot[[0 0 0] [0 0 0] [0 0 0]]
20:03hiredman,(repeat 3 (repeat 3 (repeat 3 0)))
20:03clojurebot(((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:04anonymouse89,(vec (repeat 3 (vec (repeat 3 0))))
20:04clojurebot[[0 0 0] [0 0 0] [0 0 0]]
20:05anonymouse89seems good
20:06jamesnvcHello; does anyone here use Vim/vimclojure?
20:06jamesnvcI'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:07jamesnvcCurrently, when I try to build the vimclojure jar, it errors out with "java.lang.Exception: Unmatched delimiter: ) (backend.clj:171)"
20:07jamesnvcI've seen other people with that error, but no solutions...
20:08Raynesjamesnvc: If you don't get an answer here, there is a mailing list you can try here: http://groups.google.com/group/vimclojure
20:08anonymouse89I 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:08Rayneskotarak is the vimclojure guy
20:09jamesnvcRaynes: Cool, thanks
20:09jamesnvcanonymouse89: Alright, I guess I'll try that if I can't get this working
20:53hiredman,(doc ns-alias)
20:53clojurebotPardon?
20:53hiredmanclojurebot: jerk
20:53clojurebotNo entiendo
20:54hiredman,(doc alias)
20:54clojurebot"([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:55hiredman,(doc ns-resolve)
20:55clojurebot"([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:36hiredmanclojurebot: ping
23:36clojurebotPONG!
23:40Raynesclojurebot: pong
23:40clojurebotQinfengxiang!
23:50old_soundclojurebot: 青峰乡
23:50clojurebotI don't understand.
23:51hiredmanclojurebot: tranlsate from zh 青峰乡
23:51clojurebotI don't understand.
23:54old_soundclojurebot: just a village in china
23:54clojurebotPardon?
23:54old_soundAKA QingFengXiang