#clojure logs

2011-01-03

00:18anthony_I know this is question has a very obvious answer, but I'm stuck. I'm trying to use Compojure for the first time (so it might not even belong here). How can I use a javax.servlet.Servet? It looks like there used to be a run-server function that would accept a servlet, but that's gone.
00:56amalloyi'm still using 1.2.0 but i'd like to be future-friendly for a var i'd like to be dynamic-bindable. how do i do that? (def ^{:dynamic true} foo bar) feels right, but i'm not sure if i actually read that anywhere
01:35auserwhat is the '->>' operator called/do?
01:36qbgIt is a thrush operator
01:36qbg(->> 1 (* 2) (+ 3)) == (+ (* 1 2) 3)
01:37qbgI mean (+ (* 2 1) 3)
01:37qbgUrg
01:37ausercan't find it in the docs... hmmm
01:37qbg(+ 3 (* 2 1))
01:37qbg,(clojure.walk/macroexpand-all '(->> 1 (* 2) (+ 3)))
01:37clojurebot(+ 3 (* 2 1))
01:38ausernot sure I understand...
01:38auserhm
01:38_na_ka_na_amalloy: good point about being future friendly, I'm also in the same bucket, I would like to ask a broader question - if something runs with 1.3, will it also run with 1.2, w/o any code changes (except classpath changes ofc)
01:38qbgIt makes the previous form be the last element of the next list
01:38auserahh
01:39qbgUseful for making functional operations look sequential
01:39tomojhttp://clojuredocs.org/clojure_core/clojure.core/-%3E%3E#example_191
01:39_na_ka_na_auser, http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
01:39tomojhmm, should've unfolded the iterate
01:39auserawesome! thanks _na_ka_na_
01:40amalloy&(macroexpand-all '(->> (range) (filter even?) (take 10) (map #(* 5 %)) (reduce +)))
01:40sexpbot⟹ (reduce + (map (fn* [p1__8789#] (* 5 p1__8789#)) (take 10 (filter even? (range)))))
01:41tomojthere :)
01:41tomojooh, adding a sum on the end would be good too
01:41amalloyauser: that's sorta a typical use: you're performing a long sequence of operations on a single value, and it's more legible as a sequence of steps than as a nested operation
01:41amalloytomoj: i did
01:41auserI see... that could definitely clean up some of my code
01:41tomojI meant in the example on clojuredocs
01:41amalloyah
01:42tomojoh, and (iterate inc 0) is outdated now..
01:43amalloytomoj: i assumed we'd had (range) forever; is it new as of 1.2.0 or something?
01:43tomojit's recent
01:44tomojnot sure when
01:44amalloy&(-> range var meta :since)
01:44sexpbot⟹ nil
01:44amalloy&(-> range var meta)
01:44sexpbot⟹ {:ns #<Namespace clojure.core>, :name range, :file "clojure/core.clj", :line 2246, :arglists ([] [end] [start end] [start end step]), :added "1.0", :doc "Returns a lazy seq of nums from start (inclusive) to end\n (exclusive), by step, where start defaults to 0, step to 1, and end\n to infinity."}
01:44amalloyhm. it claims 1.0, but i don't think that's really trustworthy
01:46tomoja55df92f
01:46tomojapril
01:47_na_ka_na_hey guys how is this example of ->> ... (->> (read) (eval) (println) (while true)) !
01:47_na_ka_na_make your own repl
01:47amalloycute
01:47tomojyou can shave some parens
01:48_na_ka_na_ya but they're required in general .. (->> read eval println (while true))
01:48amalloy_na_ka_na_: read still needs parens
01:48_na_ka_na_oh ya
01:49_na_ka_na_that's why I prefer to use () always
01:49_na_ka_na_can I add this to clojuredocs ?
01:49amalloyi think it's a great example; to be more repl-like i'd like to use loop instead of while
01:49_na_ka_na_hmm
01:49tomojthink you just need an account
01:49amalloybut it's a little tricky to manage
01:54_na_ka_na_(->> (read) (eval) (println) (#(loop [] % (recur))))
01:55_na_ka_na_not so pretty
01:56_na_ka_na_how about with this.. (defmacro loop-forever [& body] `(loop [] ~@body (recur)))
01:58amalloy_na_ka_na_: if you're going to define a loop-forever macro, it might as well use the more legible while true
01:59_na_ka_na_amalloy: I was just going with the theme of the L in REPL
02:00amalloy_na_ka_na_: sure, i was just saying that if the final form will look like (->> ... (loop-forever)) it doesn't matter much whether loop-forever's implementation starts with an L; but of course it's fine if it does :)
02:00_na_ka_na_amalloy: is its probably a better example for -> .. coz ->> are generally used for sequences
02:01amalloy_na_ka_na_: true
03:10auserinteresting
03:11ausersorry, wrong window
03:12Licenser,prmomg everypmne
03:12clojurebotjava.lang.Exception: Unable to resolve symbol: prmomg in this context
03:12Licenserorning I mean
03:16amalloyLicenser: i moved the keys on your keyboard while you were sleeping
03:42ddudeyi'm trying to create a clojars jar with native-deps but they're not extracting correctly. Has anyone got any experience?
04:12LauJensenI think all the bits are in for ClojureQL 1.0 now, so after a few reviews of the code I expected to release within the next 24 hours or so
04:13ejacksonnice on LauJensen
04:23ossarehLauJensen: clojureql being some sql interface?
04:23LauJensenossareh: http://bestinclass.dk/index.clj/2010/11/clojureql--1.0.0-now-in-beta.html
04:25ossarehlooks sweet - part of the manly CMS?
04:26LauJensenNo the manly CMS is cooking up the website for ClojureQL :)
04:27LauJensenBut I assure you, both libraries are quite manly, yet elegant!
04:33ossarehnice - definitely looking forward to seeing the CMS
04:34ossarehwhat is the secret to getting dispatch to work on multimethods being fed records?
04:34ossareh(defmulti some-fn class) (defmethod some-fn ???? :foo)
04:34ossarehwhat is ??? ?
04:36ossarehI'm consistenly getting "No method in multimethod 'rec-test' for dispatch value: class surveyengine.storage.Foo"
04:37ossarehoh, it works - sorry. I'd been slimed.
05:20Licenseramalloy_: I'm in the office I am constantly sleeping
05:53neotykMorning everyone, Happy New Year!
06:10LauJensenneotyk: Morning :)
07:27no_mindSomeone please explain me this code http://pastebin.ca/2037667 . I am confused on the map part. Map function takes two argument but here only one is passed and yet no error ?
07:28Chousukeno_mind: there are two arguments
07:28Chousukeno_mind: (map ref (take 5 (repeat 0)))
07:29Chousukeother than that, it's broken code because there is no argument vector for let :P
07:29Chousukeor binding vector
07:29no_mindChousuke, I copied it from somewhere. If I do a println instead of ch it works.
07:30Chousukeinstead of let you mean?
07:30no_mindBut I cant understand 2 arguments. Is ref considered an function arg here ?
07:30Chousukeyes
07:30no_mindChousuke, yes
07:30Chousukeit's the function
07:30Chousukeno_mind: the let doesn't work because it's missing the vector form
07:31Chousukeit's supposed to be (let [ch (zipmap ...)])
07:31no_mindok
07:31ChousukeI suppose it looks like a single argument because there's no space between ref and the second argument
07:32Chousukeso you might think it's a function call or something :P
07:34no_mindyup, I thought it is a function call :)
07:35Chousukefunction calls start with a (
07:35Chousuke:)
10:21jfieldsDoes clojure have a fn that does this:
10:21jfields (defn apply-while [f-to-apply init-val pred boundry-val]
10:21jfields (loop [v init-val]
10:21jfields (if (pred v boundry-val)
10:21jfields v
10:21jfields (recur (f-to-apply v)))))
10:22jfieldsseems like something generic that should already be there, and I don't want to reinvent the wheel. :)
10:23opqdonut_you can use iterate and take-while
10:23pdkso the idea is
10:23opqdonut_for the same effect
10:23pdkit returns the same list but applies f-to-apply on the values in the list that meet the predicate
10:23opqdonut_,(take-while (partial > 5) (iterate inc 2))
10:23clojurebot(2 3 4)
10:24jfieldsactually, I'm using it for, (apply-while dec 5 < 3), which returns 2
10:24opqdonut_add a call to last if you only want the last element
10:24jfieldsgotcha
10:24opqdonut_but of course the clojure implementation doesn't roll out those sequence operations
10:24opqdonut_so your loop version should be faster
10:25jfieldsI guess it's poorly named too, it should be apply-until... anyway. thanks for the help.
10:31leafwhas anybody noticed the bug regarding boxing/unboxing with nested loops?
10:32leafwhttp://groups.google.com/group/clojure/browse_thread/thread/1af34b3ab3779460
10:32leafwAllen wrote a nice minimal example
10:51dnolenleafw: I don't think loop can return primitives.
10:52leafwdnolen: aha, so that is the issue. I thought loop was like a let? Can't let return a primitive either?
10:53dnolenleafw: I doubt it. But not sure.
10:53dnolenleafw: only fns can return primitives as far as I know.
10:53chousererr
10:53Chousukehm. loop and let should work with primitives
10:53chouserwhich version of clojure are we talking about?
10:54leafwgit master
10:55leafwlet can, I just tested it: (let [i (let [k (int 0)] k)] (inc i))
10:55leafwdoesn't give any warning .. not sure if the test is correct though
10:55chouser(expression-info '(loop [a 1] a)) ;=> {:class long, :primitive? true}
10:55leafwright, bad test
10:56chouser(expression-info '(let [i (let [k (int 0)] k)] (inc i))) ;=> {:class long, :primitive? true}
10:57chouser(expression-info '(let [i (let [k (int 0)] k)] (+ (Integer. 5) i))) ;=> {:class java.lang.Number, :primitive? false}
10:58leafwchouser: then why: (loop [b (int 0)] (let [c (loop [a 1] a)] (if false (recur (inc c)))))
10:58leafw... igves a boxing warning?
10:58leafwAuto-boxing loop arg: b
11:04chouserleafw: hm, it may indeed be a bug.
11:05chouser(expression-info '(loop [a 1] a)) ;=> {:class long, :primitive? true}
11:05chouser(expression-info '(let [c (loop [a 1] a)] c)) ;=> nil
11:06chouser...indicating that the compiler doesn't know the type of that 'let', and so will treat it as Object
11:06leafwchouser: uf, ok, so I am not allucinating
11:06chouserno autobox warning for: (loop [b 0] (let [c (long (loop [a 1] a))] (recur (inc c))))
11:06leafwchouser: I'd appreciate if you file it.
11:07leafwyeah sure, but that cast should not be needed, as far as let and loop are supposed to work
11:07chouserright
11:16SergeyDHi, is pre and post conditions on protocols are planned? Right now I can't make it work neither in protocol declaration nor in protocol implementation in deftype. I'm using Clojure 1.2
11:17SergeyDIt is mentioned on http://www.assembla.com/wiki/show/clojure/Protocols in "Old ideas/scratchpad", that's all I have found on this topic
11:18SergeyDSorry for grammar errors :)
11:20chousergood question. I haven't heard of any concrete plans, but it does seem like something that would be useful, and I can't think of any techincal reason why it couldn't be done.
11:23SergeyDI see, thanks Chouser
11:24leafwa quicksort in java for a double[] and associated int[] array that keeps track of the indices: https://gist.github.com/763139 -- takes about 15x a java version of it (java: 0.00568 ms; clj: 0.088 ms)
11:24leafwtype hints are in, and all math is primitive. What could account for clojure being slower?
11:27SergeyDleafw, that is for 1.3, right?
11:28leafwSergeyD: yes
11:28leafwI tried making the functions static, or turning them into macros: no improvement.
11:28leafwthe wya it's written, I'd think it should run as fast as java.
11:30qbgMaybe using aset-double and aset-int would help?
11:30chouserhave you tried unchecked math? I'm not sure what Java does by default.
11:30leafwchouser: java does unchecked math
11:30leafwis there are atrigger for unchecked math, or should one use unchecked-add, aetc. ?
11:31qbg*unchecked-math*
11:31a_strange_guyyou can set! *unchecked-math* to tru i think
11:31leafwok,trying that
11:31leafwdoesn't exist ... not in git master
11:32qbgAre you up to date?
11:32leafwfrom yesterday, yes
11:33qbgYou are using https://github.com/clojure/clojure right?
11:33leafwurl = git://github.com/clojure/clojure.git
11:34qbgYou ran ant?
11:34leafwI do
11:34qbgHmm...
11:35leafwit generated clojure-1.3.0-master-SNAPSHOT.jar
11:36qbgHere is the commit that added it: https://github.com/clojure/clojure/commit/aa7d26336faff6ccc65e4405e28e471221f35fc4
11:39leafwadding unchecked-inc-int for inc and -dec- for dec reduced from 0.088 to 0.056, still ~10x slower
11:40abedracemerick: do you still need access to build.clojure.org?
11:40abedracemerick: I am locking down the machine
11:40abedracemerick: because hudson will start doing the clojure releases
11:40leafwqbg: I have that commit, strange, ... I'll do a clean again
11:41cemerickabedra: no, you can drop me
11:41abedracemerick: ok cool, if you need ssh access again just let me knows
11:41abedraknow
11:41cemericksure, thanks
11:42a_strange_guyleafw: your code compiles down to primitive calls on my clojure
11:42cemerickabedra: FYI: the gpg key should probably be backed up somewhere else
11:42abedracemerick: agreed
11:42a_strange_guychecked it with a java disassembler
11:42cemerickin addition to whatever regular backups are going on, that is
11:43abedracemerick: I have a list of things that are set for a backup strategy
11:43abedraI just have to pick or setup a service for it
11:43abedraright now contegix is doing backups of the machines
11:44abedrabut that's not quite good enough for things
11:45leafwa_strange_guy, qbg : I recompiled, speed still 10x slower than java
11:45qbgHow many times are you running the code?
11:45leafwa_strange_guy: indeed there aren't any boxing/unboxing calls
11:46leafwqbg: I am testing with 10x
11:46leafwdotimes 10
11:46qbgTry a larger number
11:46a_strange_guyof corse it will be much slower than the java version
11:46a_strange_guyyour arrays are too small
11:46a_strange_guythe JIT wont kick in
11:47leafwa_strange_guy: ok, trying with random array with 100,000 elements
11:48a_strange_guythe compiler compiles everything down to static function calls
11:49a_strange_guythose are just easy to inline, but won't be inlined automatically
11:53SergeyDleaf, use the code like: (dotimes [_ 5] (println (time (dotimes [_ 100000] (inc 3)))))
11:55chouserleafw: http://dev.clojure.org/jira/browse/CLJ-701
11:55SergeyDBTW, I wonder if JIT can find out that the result of every iteration above is not used and omit that call?
11:56SergeyDIn that case more complex timing code should be used, something like accumulating the result of every iteration
11:58leafwchouser: thanks
11:59a_strange_guySergeyD: the jit cant do that because it must call .getVarRoot on a var each call
11:59a_strange_guyand the root of a var is marked volatile
12:00chousera_strange_guy: are you sure that's still true?
12:00a_strange_guychouser: not 100% 'ly
12:01a_strange_guychouser: still volatile
12:05ejacksonchouser: is there an obvious solution for the case, when using fill-queue, when the return value of filler-func needs to be returned ? In my case filler-func returns a client that I need later to affect requests.
12:09SergeyDleafw, it's ~400ms for 100000 iterations on my computer. How did you test the java version?
12:11chouserejackson: when filler-func returns, the nothing else can be added to the queue. How can it's return value affect later requests?
12:12ejacksonchouser: its a call into a java lib (that I don't control), that starts its own thread.
12:12leafwSergeyD: I have my own implementation, but I think it has an error in it. I am looking at it at the moment.
12:14ejacksonyou call a function passing it a callback (i'm using fill), it constructs a client, starts it in another thread, and returns a reference to it. I'm using filler-func as the call to this constructor function.
12:14leafwSergeyD: the clj version runs in 24 ms here for 100000 elements :)
12:15ejacksonchouser: oh, i get you, sorry. dumb.
12:16bmhDoes clojure have a construct like scheme's boxes?
12:16ejacksonchouser: I'll be on my way... rethink. Thanks.
12:17qbgbmh: atoms perhaps?
12:17qbgBasically any of the reference types
12:18bmhwonderful
12:18bmhI'm implementing embedded planar graphs and it would be nice not to route everything through a hash table.
12:19kumarshantanuis anybody using Clojure 1.3.0 Alpha-4 as a Maven dependency yet? can you tell me me the artifactId etc?
12:20SergeyDkumarshantanu, this is working in my leiningen file: "[org.clojure/clojure "1.3.0-master-20101220.130227-7"]"
12:21leafwSergeyD: longer arrays do make the JIT kick in: 10^7 random doubles, java: 171 ms, clj 307 ms (last of 10 runs)
12:21leafwSergeyD: still a factor of 2x, but far from 15x that I saw at the beginning
12:22leafw10^6 sorry, one million
12:23leafwso unless one runs a large array first, small arrays will get sorted slowly. Strange prospect.
12:23kumarshantanuSergeyD: thanks it's working for me too
12:28SergeyDleafw: JIT will compile small arrays too if you run it 100000 times
12:28a_strange_guyyah, but creating array in clojure is more expensive than in java
12:28a_strange_guy^yeah
12:29leafwSergeyD: we hope :)
12:29leafwI wait for the day that clojure can really perform as fast as java when it comes to math. It's come a long way, and it looks like within months that may happen.
12:30SergeyDa_strange_guy: that's true
12:30SergeyDleafw: I don't hope, I have just measured :)
12:31a_strange_guyleafw: I think java will still be faster, mostly because you can use ints and not longs
12:31a_strange_guyand the overhead to fetch a fn from a var still exists
12:33leafwa_strange_guy: in a 64-bit machine, int vs long may not make much of a difference
12:34leafwa_strange_guy: there's always macros. Once the code looks nice, one can macro it to death. Never try to edit it again.
12:34leafwa_strange_guy: or define fn as static. Seems to make a big difference.
12:35a_strange_guy^:static is gone for now
12:35leafwit;s a no-op ?
12:35leafwone can still write (defn afn ^:static [] ^:void ... )
12:35leafwthe compiler does not complain.
12:36a_strange_guyyeah, but it's a no-op
12:36a_strange_guystatic is replaced by non-dynamic vars by default
12:37a_strange_guy$(fn ^:a-unneeded-annotation ^:and-another self [] nil)
12:37a_strange_guy&(fn ^:a-unneeded-annotation ^:and-another self [] nil)
12:37sexpbot⟹ #<sandbox6382$eval8816$self__8817 sandbox6382$eval8816$self__8817@1ab2399>
12:37a_strange_guythe compiler -never- complains xD
12:38a_strange_guyyeah, littering your code with macros can produce identical performance to java already
12:39a_strange_guy&(doc definline)
12:39sexpbot⟹ "Macro ([name & decl]); Experimental - like defmacro, except defines a named function whose body is the expansion, calls to which may be expanded inline as if it were a macro. Cannot be used with variadic (&) args."
12:39leafwa_strange_guy: interesting. Like a macro, but clean like a function
12:39leafwthnaks for the pointer
12:40chouserand so fun to exploit
12:40a_strange_guyis there some reason why you can't have variadic inlines?
12:43qbgWould variadic inlines be very useful?
12:43leafwhum, definline doesn't work for me: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number ... in fn that takes as arguments: (definline aswap! [^doubles vals ^ints idxs ^long x ^long y] ...)
12:44chouserno point in hinting the args
12:44chouserhm, well, maybe there is. But I'm not surprised it doesn't work.
12:49leafwchouser: without the hints, the compiler warns about reflection
12:49leafwso it doesn't work by design, and thus I dont understand how to use definline, or is it an error?
12:50chouserdefinline is old. primitive-hinted fn args are new. I'm not sure the two have been thought about together by anyone.
12:50leafwchouser: so definline is up for a revision.
12:50chouseror removal perhaps
12:50rak85hi, guys
12:51rak85is there any function that returns a boolean if a string starts with some substring?
12:51rak85like (starts-with? "aba" "abaca")
12:51chouser,(.startsWith "abaca" "aba")
12:51clojurebottrue
12:51rak85thanks!
12:51leafw,(.startsWith "abaca" "aba")
12:51clojurebottrue
12:52leafwoops :)
13:33AWizzArdA starts-with that works on all sequences would be interesting, taking a comparator.
13:37chouser(defn starts-with [c x y] (every? zero? (map c x y)))
13:37amalloyAWizzArd: (fn [a b] (every? identity (map = a b)))
13:38amalloychouser: actually neither of our solutions is right
13:38amalloyif the starts-with sequence is longer than the sequence to test against, map returns prematurely
13:39chousergood point
13:40amalloy(fn [a b] (= b (take (count b) a))) is neither pretty nor flexible, but...
13:43chouserstill has false positives in the case you described, doesn't it?
13:45amalloychouser: i don't think so. b is the sequence to test against; = is doing a strict comparison of the whole list
13:45amalloy((fn [a b] (= b (take (count b) a))) [1 2] [1 2 3])
13:45amalloy&((fn [a b] (= b (take (count b) a))) [1 2] [1 2 3])
13:45sexpbot⟹ false
13:46amalloy&((fn [a b] (= b (take (count b) a))) [1 2 3] [1 2])
13:46sexpbot⟹ true
13:46chouseroh, right. very good
14:42gfrloganybody had any trouble with clojureql recently?
14:42LauJensengfrlog: no trouble, why ?
14:43gfrlogmy project won't compile all of a sudden, and I haven't been mucking with my clojureql code
14:43gfrlogit gets a classNotFound clojureql.core.Relation
14:43LauJensenYou're using lein?
14:43gfrlogyeah
14:43gfrlogI've also seen it complain that where* is unbound
14:43gfrlogit actually does complete "lein uberjar" successfully
14:43LauJensenlein doesn't handle protocols well. technomancy has an updated prepared. Try cake in the meantime
14:44gfrlogbut on executing the jar, or running "lein repl" I see the error
14:44gfrlogokay
14:44gfrlogare protocols in clojureql new?
14:44LauJensengfrlog: Been there since day 1
14:44gfrloghmm
14:44gfrlogstrange that this popped up now then
14:44gfrlogoh well
14:44LauJensentechnomancy: Got an ETA on that release yet? This comes off a little too often :(
14:44technomancygfrlog: the latest lein should fix this; you can set :clean-non-project-classes false in project.clj in the mean time
14:44gfrlogthank you
14:44technomancyI pushed out the fix a few days ago
14:44LauJensengfrlog: could you try that please and let me know?
14:45gfrlogI will do that right now
14:45LauJensentechnomancy: great- you keep an impressive pace :)
14:45gfrlogtechnomancy: thanks
14:45gfrlogLauJensen: I will try his clean-non-project-classes arg first
14:45LauJensensure, let us know how it goes
14:45technomancyif you have any trouble on 1.4.2 with AOT and protocols plz to report on https://github.com/technomancy/leiningen/issues/issue/141
14:46danlarkinAnyone have any luck using native-deps-1.0.5, lein-1.4 and lein-swank-1.2.1? lein-swank throws an exception when I try and start it when I have native deps installed
14:46technomancyI believe it's fixed, but I don't use protocols or AOT myself, so I haven't verified it on the field.
14:46technomancydanlarkin: you're not using the "lein-swank" dependency itself, right?
14:46technomancyI mean, it should be swank-clojure
14:47danlarkintechnomancy: yeah, sorry, swank-clojure-1.2.1
14:48technomancydanlarkin: there was a thread about it few weeks ago on the lein mailing list you could check
14:49gfrlogLauJenson: after changing the project.clj, I immediatly still got the classNotFound exception; after switching to beta-2 I now get the where* is unbound errer again
14:49danlarkinI see the one re: lein-1.4, but not one involving swank
14:49ossarehis it weird to (let [some-ref (ref nil) _ (while (is-nil ref) populate-ref-fn)] @some-ref) ? I need a loop that continues until it passes and want to return the value. previously i've used loop/recur for this.
14:50gfrlogLauJenson: I'll try the new version of lein
14:51gfrlogtechnomancy: could you remind me what the native readline package that lein uses for "lein repl" is? You told me once and I've had no luck googling for that conversation
14:51LauJensengfrlog: Im not called Jenson :)
14:51technomancygfrlog: that's rlwrap
14:51gfrlogtechnomancy: thanks!
14:51chouserossareh: yeah, that's probably not right, unless you're actually doing multithreaded work.
14:51gfrlogLauJensen: By squinting at the bright yellow font my client uses for names, I can tell you're correct; pardon me
14:52ossarehchouser: no threads involved - at this point. definitely feels weird - I guess I want a let-while or something
14:52chouserossareh: loop/recur would be better, or perhaps take-while
14:52LauJensengfrlog: No worries. I find it amusing that so many americans spell my name like they would say it
14:53ossarehchouser: or when-let ?
14:53gfrlogLauJensen: yeah; my pronunciation for Jensen is about the same as Jenson
14:53ossarehchouser: actually, no. I'll stick with loop/recur. Cheers.
14:53chousersure, when-let, but you'd still need to loop
14:54gfrlogleiningen is the top google hit for its name; so much for that story about ants
14:55LauJensenThe story is epic
14:59micahmartinIs there a way to define a function "get" such that I don't get this warning? "WARNING: get already refers to: #'clojure.core/get"
15:00gfrlogI think cake will probably have a harder time achieving the same google-status
15:00cemerickmicahmartin: add a :refer-clojure slot to your ns form
15:01cemerickmicahmartin: see: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ns
15:02micahmartincemerick: that worked like a charm... Thanks!
15:03gfrlogI'm looking at the readme page for cake, and it talks about installing a gem and yet doesn't mention ruby anywhere. Is that a little weird?
15:06danlarkintechnomancy: found it -- you fixed it in leiningen master 78384ba6
15:06LauJensengfrlog: Which distro are you on?
15:08gfrlogubuntu 10.04
15:08gfrlogtest
15:09gfrlogLauJensen: I think I am doing okay now
15:09LauJensengfrlog: Okay. Otherwise just install ruby/gems, then sudo gems install cake. Its quite simple
15:09gfrlogLauJenses: Updating lein seems to have worked
15:10LauJensenEhm. Its not Jenses either :) You could try ERC, it has name completion :)
15:11bobo_dont think gems install cake works in ubuntu
15:11technomancyyeah, gem is pretty screwed up on ubuntu
15:11bobo_depends on how you installed the gem thingy
15:11LauJensenreally? I think I recall seeing it working. Also works on Windows
15:12bobo_i think the apt-get installed gem stuff did something weird. didnt work for me, and i saw more people complaining
15:12technomancyit breaks self-update and puts bin wrappers in inaccessible places
15:13LauJensenninjudd: Can you submit patch for ubuntu please? the linux noobs are hurting
15:13technomancyI've bugged them about it. they are not interested. =(
15:13technomancyapparently working gems are not FHS-compliant or something.
15:14LauJensentechnomancy: 'they' ?
15:14technomancyLauJensen: the debian ruby team
15:14LauJensenoh ok
15:14technomancyso now everyone just says "whatever you do, don't use apt-get for ruby" which just pisses them off more.
15:15bobo_yeh its not just cake that doesnt work
15:15bobo_its ehm, everything :-p
15:15LauJensenWell. I guess Ubuntu in itself is a temporary OS that you use before moving on to more manly distros, so its okay I guess
15:17rak85is there any way to write (not (= 1 2)) ?
15:17chouser(not= 1 2)
15:17rak85something like (!= 1 2)
15:17rak85chouser: thanks
15:20rak85how can I check if a string has some substring? something like (contains? "asdf" "sd")
15:21rak85i have found
15:22chouser,(<= 0 (.indexOf "asdf" "sd"))
15:22clojurebottrue
15:22rak85(.contains "asdf" "sdf")
15:22chouserah, nice!
15:22rak85chouser: thanks for your solution!
15:22chousernote also (re-find #"sd" "asdf")
15:31qbgAdding lexical scope to my syntax-rules lib was nasty
15:35cemerickqbg: glad to see you get such a positive response on the ML
15:36cemerickqbg: I might suggest that you mail the clojure-dev list and offer up syntax-rules as a contrib library, if you are so willing.
15:37qbgcemerick: dnolan suggested that I while ago
15:37qbgI mailed in my CA a week ago
15:37qbgHaven't heard anything though
15:38amalloyossareh: (loop [v nil] (or v (recur (try-again v))))?
15:39amalloyor (drop-while (complement acceptable?) (iterate try-again initial-val))
15:39cemerickqbg: I don't think there's a notification system; you just get added to a list :-)
15:40qbgI don't see my name on http://clojure.org/contributing yet
15:42cemerickqbg: In any case, starting that thread now wouldn't hurt anything, assuming it's something you're open to.
15:42qbgJust applied for the clojure dev group
15:57auserI definitely have a very esoteric question... I'll see if I can functionally address it... I have an object that I'm creating and serializing, but on deserialization, I get an error 'clojure.core$bytes cannot be cast to [B' I've pasted the functional code here: http://paste.lisp.org/display/118246
15:57auserany help would be awesoe
15:57qbgsounds like you are trying to use a function as an array
15:58amalloyauser: qpg took the words out of my mouth
15:58ohpauleezyeah
15:58qbg(with-open [bais (java.io.ByteArrayInputStream. bytes)
15:58qbgThat line
15:58auserinteresting...
15:58qbgMaybe you meant object?
15:58auserI'd like to convert it to an object
15:58auseryeah
15:59amalloyauser: you'll have to try harder to come up with an esoteric question :)
15:59qbgAlso, what is up with the docstring style?
15:59auserdamn, I thought I had a better shot at the esoteric question
16:00auserwhat do you mean qbg, just a string?
16:00qbg(defn- foo "docstring" [...] ...) works also
16:01auseryeah, i kinda like that :doc in there
16:01auserbut I can change that
16:01qbgNot very idiomatic
16:01auserfair enough
16:02paudohi
16:07abedracemerick: pushed your membership through on clojure-dev
16:09cemerickabedra: Thanks; tinkering with the thought of gmail-only for clojure communications. :-)
16:18auserhm... can you cast a class or an instance of the class to a java.io.ObjectOutputStream? more investigation is necessary it seems
16:20qbgYou shouldn't need to do casting
16:21qbg(eval (.read (read-string ois))) looks wrong
16:22qbgYou want to be calling .readObject on ois
16:24qbgdeserialize should probably take a string s, bytes should be (.getBytes s), and (eval (.read ...)) should probably be (.readObject ois)
16:25qbgAnd (str (.toByteArray ...)) in serialize should probably be (String. (.toByteArray ...))
16:33ausernm, I think I got it
16:33auseryep qbg that did it
16:35auseryou rock, thanks qbg
16:47abedracemerick: that's what I do
16:47cemerickabedra: it'll either be that or I'll bite the bullet and start running mail through cemerick.com
16:48cemerickthough I don't know if I have the chutzpah to match up with me@ the way fogus does ;-)
16:48TobiasRaederhey :0
16:49TobiasRaederAnyone using cake and not having an inferior-lisp buffer in emacs aswell? Got a little problem with that
16:49abedracemerick: NO don't go there
16:50abedracemerick: Spend your time somewhere useful
16:50abedracemerick: trust me
16:50cemerickabedra: oh, I wouldn't run a mail server myself!
16:50abedracemerick: the day google offered apps for personal domains is the day I shut it all off
16:50cemerickabedra: or do you object to vanity domains in general?
16:51abedracemerick: I don't
16:51abedracemerick: I have aaronbedra.com
16:51cemerickI'd probably use rackspace mail for it if I were to go that way.
16:51abedracemerick: I have just always used my gmail account for lists because it was my first google identity
16:51cemerickTheir web interface is *horrible*, but they've not gone down once and I'm grandfathered into a pretty sweet pricing scheme from the webmail.us days.
16:52abedracemerick: running google apps for your domain is FREE
16:52abedracemerick: except for the whole google owns your data thing
16:53cemerickI got an android phone a few months ago. I think I'm screwed in that department at this point. :-(
18:46ninjuddTobiasRaeder: i personally don't use cake inside an inferior-lisp buffer, but you may want to ask in the #cake.clj channel
18:47AWizzArdOT but interesting: http://www.kurzweilai.net/womens-study-finds-longevity-means-getting-just-enough-sleep
18:49SomelauwIs there a != operator?
18:49AWizzArdyes: not=
18:49ninjuddbobo_: what issue were you having with 'gem install cake' on Ubuntu? i just tried on karmic and it worked fine. was the issue on lucid?
18:49AWizzArd,(not= 10 20)
18:49clojurebottrue
18:51SomelauwOkay, it was hard to find that function. But thanks.
18:51raekthere's also if-not and when-not, that might be more compact sometimes
18:53companion_cubewhat is the best clojure book for a functional programmer accustomed to static typing ?
19:08pdkyou just might want to pick up any ol general lisp book if the typing system is your issue
19:12companion_cubethanks, but in fact i'm more looking for a quite exhaustive book which would preferably expect the reader to know functional programming (typing is not a big issue)
19:13pdki'm not sure if there are any clojure books yet that assume advanced knowledge of functional coding coming in
19:14pdkpractical clojure and programming clojure at least introduce the concept at the beginning so
19:14pdkif you branch out you could read graham's on lisp i guess
19:14companion_cubeok, thanks
19:14pdkalso take note that clojure's typing system is also strong
19:16pdkit's also probably best to have some advance knowledge of java and the java api as well though not everything you do will need it
19:16pdkand clojure borrows cl's system of letting you put optional type hints on things like function arguments
19:17raek,((fn [^String x] x) 1)
19:17clojurebot1
19:17raektype hints don't prevent you from passing a value of a different type
19:18raekthey are for helping the compiler to pick the right method when doing java interop
19:19pdkyeah there are some wrinkles in the picture bridging between java's static world and clojure's ideally dynamic world
19:44devnhey all
19:45joshua__hi
19:45devnam i missing something or should i not be using clojars for ring releases?
19:57joshua__devn, I don't know what other people are doing but I use [ring/ring-jetty-adapter "0.3.1"] as that was what was mentioned in the compojure guide that I used. Hopefully someone else can answer your question more fully.
20:33Derander_LauJensen: https://github.com/LauJensen/clojureql I'm trying to follow this pseudo-intro and query a users table. I'm getting an "unable to find Driver for ..." error though.
20:33Derander_Do I need to install the mysql driver for jdbc?
20:36Derander_No suitable driver found for jdbc:mysql://127.0.0.1:3307/database_name (using correct db name)
20:47amalloyDerander_: yes. but it's available in maven, so you can just add it as a dep in project.clj
20:47Derander_amalloy: alright
20:48amalloyDerander_: http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6
21:49zakwilsonhttp://functionaljobs.com/ <-- the front page here suggests Akamai is or will be using Clojure. Anyone know if there's truth to that?
21:51amalloy&(into-array [nil])
21:51sexpbotjava.lang.NullPointerException
21:51amalloyis this desired behavior?
22:00drewrzakwilson: they sponsored, and were recruiting at, the conj, so I would say yes
22:01danlarkinzakwilson: I know it to be true