#clojure logs

2010-12-22

00:00amalloybrehaut: nah, i should just do it right the first time instead of flattening the wrong version :P
00:00brehautamalloy: haha sure :P
00:00amalloy&(into [] (for [[k v] {3 1, 2 2, 0 3}] (repeat v k)))
00:00sexpbot⟹ [(3) (2 2) (0 0 0)]
00:00amalloyhaha nope, not that either
00:00dnolen&(reduce concat (for [[k v] {3 1, 2 2, 0 3}] (repeat v k))))
00:00sexpbot⟹ (3 2 2 0 0 0)
00:00amalloy&(mapcat (fn [[k v]] (repeat v k)) {3 1, 2 2, 0 3})
00:00sexpbot⟹ (3 2 2 0 0 0)
00:01brehautamalloy: nice
00:03amalloymapcat solves a lot of problems if you remember it's there
00:03amalloydougbradbury: ^^
00:04dougbradburyamalloy:, dnolen:, brehaut: et al thanks!
00:04dougbradburyI'll look at mapcat
00:04brehautamalloy: it does. i knew it was possible with seq-m but couldnt remember the sane name :P
00:04dougbradburyhaven't used it yet
00:05dnolen&(mapcat (juxt inc dec) [1 2 3])
00:05sexpbot⟹ (2 0 3 1 4 2)
00:05brehaut&((juxt inc dec) 1)
00:05sexpbot⟹ [2 0]
00:05brehauti love juxt
00:07amalloybrehaut: juxt is great. fnil is another HOF that's surprisingly useful
00:07dnolen&((juxt true? false?) true)
00:07sexpbot⟹ [true false]
00:07amalloy&((juxt :a :b :c) {:a 1 :b 4 :c 9})
00:07sexpbot⟹ [1 4 9]
00:08brehautamalloy: im quite confused about what fnil does
00:11amalloy&(let [m {:a 1}] (update-in m [:a] (fnil inc 0)))
00:11sexpbot⟹ {:a 2}
00:11amalloy&(let [m {:a 1}] (update-in m [:b] (fnil inc 0)))
00:11sexpbot⟹ {:b 1, :a 1}
00:12brehautamalloy: awesome
00:12amalloybrehaut: you can often use fnil to gloss over the base case of your recursion
00:14brehautamalloy: yeah thats really cool. definately adding it to my toolbox
00:16amalloy&(map (fnil (memfn length) "") ["foo" nil "x"])
00:16sexpbotjava.lang.IllegalStateException: Var clojail.core/tester is unbound.
00:16amalloy&(doall (map (fnil (memfn length) "") ["foo" nil "x"]))
00:16sexpbot⟹ (3 0 1)
00:17amalloythat is a really annoying bug to fix in sexpbot, btw. i've been trying to wrap my head around it for a couple days
00:19brehautim off. have a good rest of your day
01:44replacaQ: does anyone know the idiom to get clojure.walk/walk to stop recursing at some point in its walk?
01:45replacaI want to create a modified version of loop that modifies any returns inside, but doesn't modify nested loops
01:46replacas/returns/recurs/
01:46sexpbot<replaca> I want to create a modified version of loop that modifies any recurs inside, but doesn't modify nested loops
01:47amalloyreplaca: walk doesn't recur at all; it's post-walk that adds the recursive-ness
01:48amalloyyou want to call walk with an <inner> function like (fn [x] (if (some-condition x) x (some-transform x)))
01:49replacaamalloy: ahh, that makes the code make sense! Thanks for the insight - I knew I was missing something
01:55brehauti think i have succeeded in writing my scraggliest piece of clojure so far. unimpressed with myself; there must be a cleaner way.
01:55amalloybrehaut: an admirable attitude, and expressed in such a way that i can't help but laugh
01:55brehautamalloy: hah :)
01:56brehautamalloy: any ideas on 'handle-post' in https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/core.clj
01:57brehautthe nested if-let in a try are just plain nasty
02:00amalloybrehaut: hrm. there's no obvious way to improve it
02:00brehautamalloy: le sigh
02:01amalloybrehaut: it makes me think of cond-let, though. i wonder if that can help somehow
02:03brehauthmm. someone was asking about maybe-m which did stuff on failures. clearly this is my penance for not working harder on his problem
02:03brehautcond-let looks interesting though
02:03amalloybrehaut: it is interesting, but i don't think we can apply it to this problem easily
02:04brehautamalloy: agreed
02:05amalloy&(cond-let [[a b]] nil {a b} [1 2] (list a b))
02:05sexpbotjava.lang.Exception: Unable to resolve symbol: cond-let in this context
02:05amalloy(use 'clojure.contrib.cond)
02:05amalloy&(use 'clojure.contrib.cond)
02:05sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/cond__init.class or clojure/contrib/cond.clj on classpath:
02:05amalloyoh well
02:06brehaut(1 2)
02:06brehautaccording to my repl
02:07amalloybrehaut: yeah, i hoped it would be. cond-let is kinda inside-out from when-let and if-let
02:08brehautim not quite sure i understand what is going on
02:09brehauti mean, i can kind of see whats happening, but im not quite sure how it deviates from cond
02:10amalloybrehaut: it gives you bindings from the test which you can use in the expr
02:11amalloyie, it evaluates first nil, and then [1 2]; the first one that evaluates to true it binds to [[a b]], and then evaluates the corresponding expression
02:11brehautah right now i see
02:11brehautclever
02:12amalloybrehaut: yes, it looks clever but i've never found a condition where it seems to fit. so maybe not
02:12brehautamalloy: it doesnt seem to quite suit what i need
02:12amalloyno
02:13brehautamalloy: i wonder if ideally id be best suited by a form that has pairs of expressions, first of each pair is the expression to try. if it fails (ie results in nil) then the second of the pair is evaluated and that isthe result of the expression. if i succeeds it moves on to the next pair and repeats. once there is no more pairs it returns the final result
02:14brehautexcept that it gets horrible fast
02:14amalloybrehaut: so you want "and-let"
02:14replacabrehaut: isn't that just cond with a lot of "not"s
02:14brehautamalloy: that would be a good name for it
02:15brehautreplaca: i missed a detail. the result of each successful pair is passed onto the next as an argument
02:15brehautlets see if i can do a hypothetical
02:16replacabrehaut: ok, that's different
02:17replacasort of like a mash-up of cond and -?>
02:17brehaut-?> is new to me
02:18brehaut(attempt [foo ({:foo {:bar 2}} :foo)] "no foo present"
02:18brehaut [r (:bar foo)] "found foo but not bar"
02:18brehaut r) ; => 2
02:18amalloybrehaut: clojure.contrib.core/-?>
02:19brehautthis is really looking monadic to me :(
02:19brehautclearly im on the wrong track if thats the case
02:20brehautamalloy, replaca: cheers for the -?> pointer. looks handy
02:25brehautis there a function to determine the available arity(s) of a fn?
02:27amalloybrehaut: none that i know of, but you can do it with a var, sorta
02:28amalloy&(-> partition var meta :arglists)
02:28sexpbot⟹ ([n coll] [n step coll] [n step pad coll])
02:28_atobrehaut: http://stackoverflow.com/questions/1696693/clojure-how-to-find-out-the-arity-of-function-at-runtime
02:28amalloy&(->> partition var meta :arglists first (map count))
02:28sexpbotjava.lang.UnsupportedOperationException: count not supported on this type: Symbol
02:28amalloy&(->> partition var meta :arglists (map count))
02:28sexpbot⟹ (2 3 4)
02:29brehautamalloy _ato: cheers
02:30amalloybrehaut: but i'll echo the sentiments on stackoverflow: relying on this is unlikely to work well in practice
02:30brehautamalloy: i was worried about that
02:30brehautesp seeing as the comments are that its not really workable on anon funs
02:30amalloyright, like i said: only for vars
02:31brehautamalloy: yeah. oh well.
02:31amalloywell. i suppose someone could attach arglist metadata to the anonymous functions they return you, but...
02:31_atoIIRC you can do it with java reflection on anon fns
02:31brehautyeah thats unlikely to happen!
02:31_atonot sure if that breaks with primitive args in 1.3 though
02:32brehaut_ato that might be something i put off for now
02:32amalloy_ato: i don't think primitives will break it, but anon functions with multiple arities would
02:33_atohttp://groups.google.com/group/clojure/browse_thread/thread/d9953ada48068d78/1823e56ffba50dbb
02:33_atosee Achim's answer
02:34amalloyyeah, that's a good answer
02:34amalloy"here is some clever code that does what you want. but don't use it, it's really a bad idea"
02:35brehautim comfortable with just catching the exception and having really minimal autodocumentation for these handlers
02:35brehautcheers for all the pointers
03:54brehautRaynes: ping?
03:54Raynesbrehaut: Furious pong.
03:55brehautim not quite sure what to make of that!
03:55Raynes:p
03:55brehautso as to not duplicate effort on another project, did you have any partcular blog api's you were planning to start work on ?
03:56Raynesbrehaut: Wordpress mostly. I wanted to write a library for all of the major blogging engines, but I'm not sure how feasible that is given differences in APIs.
03:56RaynesI need wordpress as a prerequisite for my blog editor.
03:56brehautRaynes: so you are planning to consume their APIs rather than reimplement them?
03:57brehautRaynes: i was planning to implement both ends of pingback next just as a heads up
03:57RaynesThe former.
03:57brehautsweet as. that should mean we avoid duplicating effort
03:58RaynesI haven't started work on anything and didn't have any plans on doing so in the immediate future, so no duplicating going on here. <3
03:58RaynesI've been busy on a super secret project lately.
03:59brehautheh :)
04:04AWizzArdWill protocol fns always dispatch to the most specific type?
04:08raekAWizzArd: http://groups.google.com/group/clojure-dev/browse_thread/thread/fb3a0b03bf3ef8ca?pli=1
04:13AWizzArdraek: thx
04:20ejacksonmorning all
04:56fbru02 Hey all , don't want to bring back the thread about primitive support, but just want to check that i understand correctly According to this : http://dev.clojure.org/display/doc/Enhanced+Primitive+Support it seems that the reason for the change was to gain ability to have primitives in fns, thus being able to do high-order stuff with primitives. Am i right ?
05:02fliebelmorning
05:02fbru02fliebel: morning !
05:03_atofbru02: as arguments and return values yes. You could already use primitives within a fn, but they would be boxed when passed to another fn
05:03fbru02_ato: thanks
05:05fliebelThis morning I found a very good argument for the new pods, and why they should not do the lock managing thing. You know why? Because it'll be awesome to have Podrace conditions! :)
05:16fbru02_ato: the other day i was reading this http://tech.puredanger.com/2010/10/25/conj-parallel/ and if you look near the end it says that (after this changes) "we can leverage everything latent in the JVM" what is everything latent in the JVM?
05:16fbru02fliebel: nice :D
05:30Leonidaswhat is the name of the function to divite a seq into two, depending on a predicate?
05:30Leonidas*divide
05:30fliebelsplit-with
05:31Leonidasfliebel: thanks, exactly what I was looking for
05:42RaynesMorning cemerick.
05:43cemerickmorning :-)
05:43Raynescemerick: Been doing much book writing lately?
05:44cemerickRaynes: my usual amount. I've been on the same cadence since ~October.
05:45ejacksoncemerick: is the book going to built using Maven, like the Maven book ?
05:45cemerickejackson: no, O'Reilly has its own tooling platform. I've no idea what drives it.
05:46cemerickAll the code in the book will likely be tested via maven, though.
05:46ejacksonif you write in LaTeX, then the whole process is just like coding.... How fun :)
05:47ejacksondeployment to pdf, hahahaha
05:48cemerickThey're very anti-latex. Non-semantic markup, etc.
05:49ejacksonI guess they'd know. Still, it seems like a powerful toolchain.
05:51cemerickMy impression of their impression is that it doesn't play well with others, in various ways.
05:51cemericke.g. if you're Knuth or writing a dissertation, it seems just fine because you can do things your way
05:51cemerickIf you're trying to keep a "house style" across 100's of books, it's just a PITA. *shrug*
05:52cemerickI actually figured I'd have to learn latex for the book, but asciidoc is **way** simpler. :-D
05:52RaynesI'm using Lyx for my book. LaTeX without having to deal with LaTeX.
05:52ejacksonIn our lab we had a latex stylesheet that did exactly that. I grant that requires an in house wizard though.
05:53RaynesLyx has been a joy to write with so far.
05:53ejacksonGlad to hear it. LaTeX is marvellous.
05:54mrBlissRaynes: what's your book about?
05:54fliebelRaynes: You're writing a book? And, LaTeX is the math thing, right? You write books with that?
05:54RaynesmrBliss: Clojure
05:54RaynesLaTeX is for *
05:54ejacksoncemerick: actually, I'm suprised to hear that argument, given that all the techie journals ask for LaTeX and manage to publish in a house style.
05:54mrBlissRaynes: what's gonna be your focus?
05:55ejacksonfliebel: latex is a document layout language. Its particularly good at doing maths, hence the association.
05:55cemerickejackson: I'm not sure anyone else operates at O'Reilly's scale.
05:55fliebelokay
05:55ejacksoncemerick: this is true :D
05:55cemerickIn any case, insofar as their approach didn't force me to use latex, I'm happy for it. ;-)
05:55RaynesmrBliss: Freeness. It's licensed under a CC license and will be made freely available upon completion. It is not aimed at anybody in particular, but the book is an introductory book that expects some programming knowledge in any given language.
05:56Raynescemerick: I remember your editor from the Conj.
05:56RaynesJulie Steele.
05:56cemerickYup, that's her.
05:56RaynesOne of the few women that attended.
05:56RaynesMy own book has been keeping me away from doing tech review on your book. :(
05:57RaynesI'm paranoid that if I don't hurry with the tech review, I'll get way behind when more drafts are out.
05:57bobo_Someone should write a book about web devlopment or statistics in clojure. so i can read it =)
05:58cemerickRaynes: I think that's a fair bet. You've got to keep your own cadence. ;-)
05:58ejacksonbobo_: an interesting idea indeed....
05:58cemerickbobo_: @marick is doing a book on Ring, FWIW
05:58RaynesmrBliss: Of course, it isn't being published by anybody, so if anybody wants printed copies, they'll have to print it themselves.
06:00bobo_cemerick: oh he is? awesome
06:01mrBlissNow that we're on the topic of books: which one should I read first "On Lisp" or "ANSI Common Lisp". Or does reading one make the other redundant?
06:03bobo_a mixed book with one chapter on web development, one on statistics, and other more practical things would also be nice
06:03fbru02bobo_: clojure in action kinda does that
06:03RaynesWell, I might self-publish printed copies while making the pdf free.
06:03cemerickbobo_: That almost perfectly describes our book, actually.
06:04bobo_fbru02: it does? and i thought i have read clojure in action =)
06:04fbru02bobo_: i thought i read it too :)
06:04bobo_cemerick: yours is practical clojure?
06:04RaynesMy book is going to have a chapter devoted to creating a library and an application that uses that library. Using cake. Probably some stuff on web development and whatever else I feel like talking about.
06:04cemerickbobo_: no: http://cemerick.com/2010/09/10/clojure-programming-the-book/
06:05bobo_ah
06:05ejacksonRaynes: thought of pre-publishing on a blog ? Would be nice for rapid iteration and feedback.
06:05RaynesI enjoyed Real World Haskell's chapters walking through the creation of real things.
06:06fbru02Raynes: i was thinking that too ! I even grabbed my copy of RWH
06:07Raynesejackson: I've been giving drafts to a lot of people from different walks of life, including non-Clojure and non-Lispers. I'll probably give it to more and more as I write more. I'll probably throw the final drafts up on my blog and let people give me feedback before I totally finalize the book.
06:07ejacksongroovy
06:07clojurebotTitim gan éirí ort.
06:08ejackson$botsnack
06:08sexpbotejackson: Thanks! Om nom nom!!
06:08ejacksontake that clojurebot ! ha
06:09Raynes$huggle ejackson
06:09ejacksonoh lord
06:14RaynesIt's surprising that I've written as much as I have so quickly. Especially given that I wrote more typos than coherent sentences.
06:14Gigarobyhello guys
06:16Gigarobycan I ask a question ?
06:16fliebelGigaroby: No!
06:16fliebelWelll, yes of course
06:16Gigarobythanks
06:16GigarobyI'm new to clojure
06:16fliebelAnd to IRC...
06:16Gigarobyand I'm trying to write somethink that make sense
06:16Gigarobyyep both
06:16Gigarobynever used
06:17Gigarobyirc
06:17Gigarobywhat am I doing wrong btw ?
06:17fliebelGigaroby: "Don't aks to ask"
06:17Gigarobygood
06:17GigarobyI was looking
06:17Gigarobyfor a function
06:18Gigarobyto count how many elements are in a collection
06:18Gigarobylike
06:18fliebel(and type a whole sentence before you hit enter)
06:18Raynes&(count [1 2 3 4])
06:18sexpbot⟹ 4
06:18Gigarobyno
06:18Gigarobynot that
06:18GigarobyI meant (count 1 '( 1 2 4 5 1 5 2))
06:18fliebel$(distinct [1 2 3 1 2])
06:18Gigaroby-> 2
06:19RaynesOh. I see.
06:19mrBliss$(count (filter #{1} '( 1 2 4 5 1 5 2)))
06:19Raynes&(distinct [1 2 3 1 2])
06:19sexpbot⟹ (1 2 3)
06:19RaynesAmpersand, silly.
06:19mrBliss&(count (filter #{1} '( 1 2 4 5 1 5 2)))
06:19sexpbot⟹ 2
06:19fliebelThe PHP I did yesterday got me I think :(
06:20Gigarobyok that what I meant I just thought there was a function I didn't see
06:20Raynes&(group-by identity [1 2 3 4 5 1 5 2])
06:20sexpbot⟹ {1 [1 1], 2 [2 2], 3 [3], 4 [4], 5 [5 5]}
06:21Raynes&((group-by identity [1 2 3 4 5 1 5 2]) 1)
06:21sexpbot⟹ [1 1]
06:21RaynesFun.
06:21RaynesmrBliss's example is better, of course. Still, fun.
06:21Gigarobyyeah
06:21Gigarobygood
06:21mrBlissGigaroby: Clojure's count is CL's length, not CL's count.
06:21fliebelPoor Gigaroby, asks for one solutions, gets ten :)
06:22Gigarobybetter than 0 anyway
06:22Gigarobythanks a lot
06:24fliebel&(get 1 (frequencies [ 1 2 3 1 2 3]))
06:24sexpbot⟹ nil
06:24fliebel&(get (frequencies [ 1 2 3 1 2 3]) 1)
06:24sexpbot⟹ 2
06:25Gigarobya set used like a function just test the membership of the argument ?
06:25fliebel$huggle frequencies
06:26Raynesfliebel: Ah! I knew there was something I was forgetting.
06:26mrBlissGigaroby: correct
06:26Gigarobyok
06:26Gigarobyit's weird not having all the usual loops and stuff
06:27mrBlissGigaroby: What's your background? Common Lisp, Ruby, Python, Java, ...?
06:27GigarobyPython and Java at most
06:27Gigarobysome php
06:27Gigarobysome C
06:27fliebelGigaroby: Same as me :)
06:28mrBlissGigaroby: I thought Common Lisp, since the 'count' you suggested, does exactly what you need in Common Lisp :-)
06:28GigarobymrBliss no just get a clojure manual on the kindle sounded like fun
06:29Gigarobyinfact it was btw
06:29fliebel&(reduce #(if (= %2 1) (inc %1) %1) 0 [1 2 3 2 3 1])
06:29sexpbot⟹ 2
06:31fliebel&(keep (map #{1} [1 2 3 1 2 3]))
06:31sexpbotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep
06:31mrBlissGigaroby: besides the good books that are currently available, http://clojuredocs.org/quickref/Clojure%20Core is very helpful
06:31fliebel&(keep identity (map irc://irc.freenode.net:6667/#%7B1} [1 2 3 1 2 3]))
06:31sexpbotjava.lang.Exception: Unmatched delimiter: }
06:31GigarobymrBliss, thanks I'll have a look but when I begin a new language I like to have a manual to follow
06:32fliebelhuh?
06:33mrBlissfliebel: another one for your list: ##(count (remove (complement #{1}) '(1 2 3 1 2 3))) ; pretty similar to my previous solution though
06:34sexpbot⟹ 2
06:36GigarobymrBliss, the first is my favourite I think
06:37AWizzArd&seen AWizzArd
06:37sexpbotjava.lang.Exception: Unable to resolve symbol: seen in this context
06:37mrBlissGigaroby: it's probably the most idiomatic
06:37AWizzArdRaynes: can you add a $seen fn to the sex bot?
06:38Raynes$seen AWizzArd
06:38sexpbotAWizzArd was last seen talking on #clojure 10 seconds and 787 milliseconds ago.
06:38RaynesNormal commands are prefixed with $, while code is prefixed with & for evaluation.
06:39fliebel&(count (nth (partition-by identity (sort [ 1 2 3 1 2 3])) 0))
06:39sexpbot⟹ 2
06:43fliebel5 distinct solutions so far.
07:01fliebelhttp://pepijndevos.nl/6-ways-to-tell-how-many-xes-are-in-a-list
07:17Gigarobyhow do you do != in clojure ?
07:18Raynesnot=
07:18Raynes&(not= 3 3)
07:18sexpbot⟹ false
07:21Gigarobythanks Raynes
07:29_ato&((fn f [[x & xs :as coll]] (cond (= coll '(1)) 1, (nil? xs) 0, :else (apply + (map #(f (take-nth 2 %)) [coll xs])))) [1 2 3 4 5 1 5 2])
07:29sexpbot⟹ 2
07:30RaynesHoly God, I've just went blind.
07:38_ato&(let [s (sort [1 2 3 4 5 1 5 2])] (- (.lastIndexOf s 1) (.indexOf s 1) -1))
07:38sexpbot⟹ 2
07:40AWizzArdRaynes: ah ok
07:41AWizzArd$seen rhickey
07:41sexpbotrhickey was last seen quitting 2 weeks and 2 days ago.
07:41Raynes$seen stuarthalloway
07:41sexpbotstuarthalloway was last seen quitting 4 weeks ago.
07:42RaynesIf not for chouser, I'd feel like a chick without a hen.
07:52rseniorI've got a -main function (invoking via lein run) and I am trying to get console input from (.readLine *in*) or (read-line) via that main function and for some reason (.readLine *in*) does not prompt for input and always just returns nil
07:52rsenioris it possible that something else has grabbed System/in?
08:03rseniorprobably too early for an I/O question :-)
08:04midsrsenior: http://stackoverflow.com/questions/3790889/clojure-lein-read-line-stdin-woes
08:04LauJensenMorning all
08:06fliebel_ato: I'll add them. beautiful!
08:06fliebelLauJensen: morning
08:06ejacksonhey Lau
08:07LauJensenHey Action Jackson
08:07rseniormids: that certainly seems like my issue, thanks!
08:08ejacksonLau, no that's ajackson.
08:09RaynesLauJensen: Ohai
08:09RaynesLauJensen: You missed the public announcement of my new book. ;>
08:09LauJensenI sure did - link? :)
08:10RaynesIt isn't actually finished yet. Only been writing for just over a week. I've got a 47 page draft sitting in front of me right now.
08:10LauJensenExiciting, how did you get the idea for a book ?
08:11RaynesWell, it's a Clojure book. Not fiction.
08:11jk_silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set
08:12RaynesLauJensen: I'd like to fill the 'free' niche that no Clojure book fills yet.
08:12RaynesI'm licensing it under a CC license and making it freely available upon completion.
08:12RaynesMight self-publish it and make printed copies available.
08:12LauJensenInteresting. What would happen if you put no license on it at all ?
08:13RaynesWell, there is the unlikely event that someone would take the book and put their name on it and sell it.
08:14LauJensenIn which case you would be prepared to sue ? :)
08:14fliebelHah, I found the link to the Ring book on the Google group . "This book seems intended to be about Ring specifically, rather than the more general topic of how to write Clojure web applications."
08:15RaynesWith a fury. I'm almost ready to take the BAR.
08:16fliebelSo, no general web dev books yet?
08:16RaynesCreative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License is the license I'm licensing it under. Nice long one.
08:19RaynesSpeaking of all that: dear chouser, thank you for coauthoring The Joy of Clojure. If I didn't have that book to teach me this stuff, I wouldn't be able to write what I'm writing in the first place.
08:20RaynesI keep it open for reference as I write.
08:20cemerickThat's a good one. Lets others pass around the PDF, but doesn't allow others to sell copies.
08:20cemerickIIRC, anyway.
08:20Raynescemerick: That's about right.
08:21RaynesAnd, people can make changes to it as long as it remains under the same license.
08:22jk_silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set
08:22jk_this document says (byte) should wrap around, but it doesn't seem to: http://faustus.webatu.com/clj-quick-ref.html
08:25ejacksonjk_: that's true, now it throws an out of range exception
08:28jk_ejackson: and no function exists to return the byte equivalent?
08:29ejacksonjk_: no idea.
08:29jk_ejackson: i'm trying to pack an integer value into 3 bytes and was confronted by this when i had working java code to do the same
08:30jk_not b64 encoding... some stupid proprietary protocol
08:30TubeSteakjk_: well, if it's a constant, why don't you put the signed value?
08:31jk_TubeSteak: sure, that's what i want to do. i want to pass an arbitrary value 0x00-0xFF and have it return the signed byte value
08:31jk_TubeSteak: i just thought a byte cast would do that, or that an existing function at least existed.(java byte cast does this exact thing)
08:34jk_i could write the function but i found it hard to believe that this functionality was lost in clojure
08:34jk_that's why i'm asking here :)
08:37fliebelLauJensen: You know about this? http://en.wikipedia.org/wiki/Language_Integrated_Query
08:37LauJensenfliebel: yep
08:37LauJensenIts like a poor mans version of ClojureQL :)
08:38fliebelLauJensen: Just what I thought… Somewhat related: Is there a data structure backend for CQL?
08:39LauJensenfliebel: Yes, the RTable record is effectively an AST comprised by its fields, altered by its methods
08:40fliebelLauJensen: I'm afraid you use to many unknown words in that sentence… A what record is effective a what?
08:41LauJensenfliebel: ClojureQL contains this like (defrecord RTable [....]). That record has fields like table-name, columns, predicates etc. Together they form an Abstract Syntax Tree, a datarepresentation of the query. This AST can be easily modified by the methods of the record, ie. (select tble (where (= :x 5))) etc.
08:41Crowb4ramalloy_: Hey, how do I give a plugin to you and Raynes for sexpbot?
08:42jk_LauJensen: but can you easily convert any seq or data collection in clojure to an RTable? that's what LINQ does for you, (i think, not a .net programmer)
08:42RaynesCrowb4r: If you have forked sexpbot on Github and added the plugin, you're welcome to issue a pull request and it will be looked at as soon as possible.
08:42LauJensenjk_: essentialy its a hashmap
08:44jk_LauJensen: all i'm saying is that LINQ has functionality that isn't already built into ClojureQL in that you can apply LINQ operations to any enumerable or sequence in .NET
08:45LauJensenjk_: Im not sure I follow, can you show an example ?
08:45fliebelLauJensen: So can I do (into (RTable) {:a 1 :b 2 :c 3}) and then do the CQL equivalent of SELECT * FROM :a , or something like that?
08:45jk_LauJensen: read the wikipedia article referenced... section on LINQ providers
08:45LauJensenAha. That would be trivial to implement. Like (map rtable [{:a 5} {:b 5} {:c 5}]) etc
08:46LauJensenIm not sure that buys us anything in the composability department though
08:52Crowb4rRaynes: ok, will do. I have a couple of features my bot has that can be converted to run on sexpbot.
08:53fliebelLauJensen: What it buys you is that you can do relational stuff to your seqs, rather than (reduce (map)). Like NoSQL vs SQL.
08:57LauJensenfliebel: But you realiase that ClojureQL already lets you do relational operations right?
08:58Gigarobyhow can I load a file into the repl ?
08:58fliebelLauJensen: On relational databases. What if I parse a nice XML file, can it do relational stuff to that as well?
08:58LauJensenfliebel: no, hence the QL
08:59LauJensenFor normal relational algebra ops, you have clojure.set, for SQL backends, you have clojureql
08:59fliebelLauJensen: LINQ to XML offers this, but I'll have a closer look at clojure.set.
09:01fliebel*amazed* I had no idea clojure.set contained things like join and select!
09:15ejacksonfliebel: you didn't read Stuart Halloways book (seeing we're talking books today) !
09:16fliebelejackson: Uh, no. Which one is it?
09:16ejackson"Programming Clojure" the first clojure book
09:27Gigarobygotta problem : I was trying to execute a few lines I write and I dunno what's wrong but the compiler gives me an error on line 0. http://pastebin.com/EqBxpSEz
09:28fliebelGigaroby: What error?
09:28mrBlissGigaroby: the docstring give me an error
09:28mrBlissonly the first line should start with a " and only the last line should end with a "
09:29GigarobymrBliss, wich first line are you talking about ?
09:29GigarobymrBliss, you mean docstrings ?
09:29mrBlissGigaroby: yes remove the last char from L10 and the first from L11
09:30GigarobymrBliss, fliebel thanks a lot
09:31GigarobymrBliss, still same error
09:31mrBlissGigaroby: I'll post a fixed version in a sec
09:31GigarobymrBliss, but I did correct the docstring
09:31GigarobymrBliss, thanks
09:32agentwranglerIs it a bug or a feature that you can't send-off from within the error-handler of a failed agent?
09:32chouseragentwrangler: what version of Clojure?
09:32agentwranglerchouser: 1.2.0
09:34GigarobymrBliss, must be a lot of mess I'm sorry but that's the first I do with clojure
09:34mrBlissGigaroby: http://pastebin.com/C7WjXM88
09:35chouserI believe it was intentional, but has been changed in 1.3-alpha4: http://dev.clojure.org/jira/browse/CLJ-390
09:35mrBlissGigaroby: it's ok, I've seen much worse ;-)
09:35mrBlissGigaroby: this compiles
09:36agentwranglerchouser: thanks!
09:36GigarobymrBliss, you think the style is lispy enaugh or I'm still too in imperative programming ?
09:37mrBlissGigaroby: judging by this small amount of code, I think you're on the right path
09:38GigarobymrBliss, ok thanks I understood what was wrong
09:39GigarobymrBliss, you gotta declare the functions in the order in wich you are going to use or at least with declare
09:39mrBlissGigaroby: correct. Also notice the last expression (the or)
09:39mrBlissGigaroby: In Clojure, you seldomly return false or true explicitly
09:40GigarobymrBliss, that was just style of indentation or there was an error ?
09:40mrBlissGigaroby: in Lisps in general, everything that's not nil or false will be treated as 'true' in an 'if'
09:42GigarobymrBliss, good thanks
09:43midsGigaroby: minor nitpick; for a predicate I'd drop the is- prefix if it already has a ? at the end
09:43Gigarobymids, fair enaugh thanks
09:43midsso position-valid? instead of is-position-valid?
09:44mrBlissGigaroby: small tip: you can replace L27 with (let [{:keys [board current-queen]} queens
09:45GigarobymrBliss, any suggestion for an IDE ?
09:46mrBlissGigaroby: most Clojurians use Emacs + Slime, but I think Eclipse + counterclockwise is easier to start with
09:47GigarobymrBliss, yeah I do use eclipse for python and java as well
09:47mrBlissGigaroby: http://www.assembla.com/wiki/show/clojure/Getting_Started
09:58GigarobymrBliss, counterclockwise is really good thanks for the tips now I go offline
09:58Gigarobysee ya
09:58mrBlissGigaroby: hope to see you again on this channel
09:58GigarobymrBliss, tomorrow for sure xD
10:08drdozerhi - are there any resources to get me started with genetic programming using clojure?
10:08mrBlissdrdozer: An example: http://npcontemplation.blogspot.com/2009/01/clojure-genetic-mona-lisa-problem-in.html
10:12drdozerNow I'm remembering why I don't use lisp :)
10:13drdozerthanks mrBliss for that example
10:13drdozerI have a multi-player game coded up in scala, and need to write some bots to play it
10:15drdozerso I'm hoping to breed functions that make sensible responses when it is time for the bot to make a move
10:15companion_cubewow, anonymous classes are not garbage collected ? this is ugly
10:17chousercompanion_cube: where are you seeing that?
10:17companion_cubein the blog post mrBliss posted
10:18Raynescompanion_cube: Where did that name come from, if you don't mind me asking? I am deadly curious.
10:19companion_cubeyou mean my nickname ?
10:19RaynesYes.
10:19jolysound like Portal
10:19companion_cubeit comes from portal, yeah :D
10:19RaynesI was thinking of a few games with cubes. None of them were minecraft.
10:19jolyinteresting 1st person puzzle game that I couldn't play due to motion sickness :P
10:24chouserjoly: I can relate. Very high framerate helps, but still I often had to stop playing to recover my equilibrium.
10:24Crowb4rwhat makes sexpbot eval clojure code?
10:25chousercompanion_cube: you see the note in there that the class GC problem has been corrected?
10:25companion_cubeoh, i didn't see it, thanks
10:28fliebelCrowb4r: prefix it with an ampersand or with ##(println "this") mid-sentence.
10:28sexpbot⟹ this nil
10:28RaynesCrowb4r: There is a Clojure plugin. clojure.clj. It uses clojail to evaluate code.
10:28RaynesOh. Is that what he was asking?
10:28fliebelI don't know...
10:29Raynes;)
10:29fliebelCrowb4r: Enlighten us, what did you want to know?
10:30Crowb4rI was asking the keyword to kick it off
10:31Crowb4rbefore opening up the src code to look at the trigger
10:31Crowb4rlike ',' is clojurebot
10:31eckrothIf I defn a multiple-arity fn, I cannot :use it in another ns; why is that (or am I mistaken)?
10:31joly&(println "test")
10:31sexpbot⟹ test nil
10:31Crowb4rgot ya
10:32Crowb4rRaynes: also where are the dynamic.clj and status.clj files I had to take them out of plugins to load because it could not find the files and I don't see them on github anyplace.
10:33RaynesCrowb4r: Eh, those were deleted a few weeks ago. I forgot to remove the references to them from the default configuration.
10:34RaynesJust remove them from the plugin lists in your config. Sorry for that. I'll push a commit to remove them in a moment.
10:34Crowb4rRaynes: kk, umm another question anything specdial I have to do besides have mongo db just run in and be connectable (using ubuntu 10.10)?
10:35Crowb4ror is ther ea config I'm missing
10:35Crowb4rthis is fresh from apt in this vm
10:36RaynesRight. You should just be able to start it up and run. If the apt installation configures it to use a non-standard default port, it might not work though.
10:37Crowb4rRaynes: because I get this error when I send him a message in an irc server http://pastebin.com/yVxfNSeH
10:37RaynesRight, that means he isn't seeing mongo. Make sure that it is being run on port 27017
10:37RaynesI don't think I've made that configurable yet.
10:37Crowb4rRaynes: ok thanks
10:37Crowb4rwill look
10:38Crowb4rthanks for all the help
10:38cemerickfliebel: a couchdb "external handler"?
10:38RaynesCrowb4r: Also, we have a channel for sexpbot and related projects: #sexpbot
10:38Crowb4rRaynes: alright, I will squat in that one as well, thanks
10:38RaynesIf you don't mind, please join there for further discussion/questions.
10:38Raynes:)
10:38Crowb4rdone
11:02joly&(macroexpand-1 (binding [test 5] (println test)))
11:02sexpbot⟹ 5 nil
11:02joly&(doc binding)
11:02sexpbot⟹ "Macro ([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made i... http://gist.github.com/751681
11:02fliebel&(macroexpand-1 '(binding [test 5] (println test)))
11:02sexpbot⟹ (let* [] (clojure.core/push-thread-bindings (clojure.core/hash-map (var test) 5)) (try (println test) (finally (clojure.core/pop-thread-bindings))))
11:02jolyah, thanks
11:06jolyI'm looking at some scheme code that uses make-parameter and parameterize. Would binding be a good way to translate that in general?
11:10chouserjoly: After reading a couple paragraphs of related scheme docs, I think so.
11:11chouserthough clojure's use of lazy seqs can sometimes lead to surprising results with 'binding'
11:13chouserbecause of that, how they interact with multiple threads, and how it leads to non-pure functions, many people avoid using 'binding' as much as possible in Clojure.
11:28jolychouser: thanks, I'll keep an eye out trouble. I shouldn't be dealing with lazy seqs or multiple threads here, but I'll be on my guard
11:28jolyfor trouble*
11:32kurtharrigerwhere does one find foldr foldl do these functions not already exist?
11:33chouserreduce is one of them, though I forget which
11:34chouserfoldl I think
11:34jolyreduce should be foldl
11:34chouserfoldr is rarely needed and not provided by clojure core, afaik.
11:34kurtharrigerk
11:35kurtharrigerreduce works thanks
11:36chouserI think foldr would be something like (reduce #(f %2 %1) (reverse coll))
11:36tonylmorning
11:36Dranikfor what projects do you guys use clojure?
11:37chousereeeeevvvvrrrryyyytttthhhiiinnnngggggg
11:37chouser;-)
11:37Dranikchouser, for example?
11:38fbru02_Dranik: what's on your mind , and i will tell u if clojure is a good fit ! :)
11:38Dranikfbru02_, well, I'm trying to determin which projects clojure fits best comparing to java
11:39fbru02_comparing to java?
11:39Dranikyep
11:39fbru02_if you are thinking of doing sth in java , do it in clojure, you will be happier
11:40Dranikfbru02_, well, its a bit complex to do j2ee with pure clojure
11:40chouserthe most common good reason I run into for not using Clojure is because the JVM is unavailable or a poor fit
11:41Dranikchouser, like in Android, for instance?
11:41fbru02_i agree with chouser, and i would add web-dev is somehow easier in rails for me because i have experience with that
11:41chouserDranik: well, some people are doing even that. I meant like in the web browser, or for quick-startup at the command line.
11:41fbru02_but other than that , clojure for most of the stuff
11:42Dranikfbru02_, that's why I've said "comparing to java", bcs web-development with rails3 is really much easier :-)
11:42Dranikchouser, could you give any examples?
11:43fbru02_we are doing a web app hallf in rails and half in clojure , with zeromq and works great
11:43chouserDranik: examples of things I've used Clojure for?
11:43Dranikfbru02_, so why did you choose clojure with rails, not pure rails?
11:44Dranikchouser, yep
11:45fbru02_i was doing provisioning but wanting to do it concurrently and used pallet for that, hugod does a great job and i much prefer it over the ruby solutions
11:45chouserscraping web pages, web apps, web apis, mongo abstraction layer, protobuf library, data structure experimentation
11:45chouserI'm sure I'm forgetting things
11:46chouserfractal applets, custom RPC protocol
11:46Dranikchouser, ok, thanks :-)
11:46chouserswing gui
11:47Dranikchouser, btw, is any of your clojure code available anywhere? or maybe you coud share some?
11:47fbru02_Dranik: many people are using clojure in the bigdata niche
11:47DranikI just try to lear clojure
11:47chouserDranik: I have a bunch in contrib and on github
11:48Dranikfbru02_, yep, I see. Clojure is really good at concurrent programming
11:48replacachouser: didn't you write some kind of book filled with great examples? :)
11:48chouseroh, right, IRC log to web site converter.
11:49chouserreplaca: yeah, it's a great language to use for examples in a Clojure book!
11:49tonylbrehaut: ping
11:49Dranikchouser, could you please share some links and the book?
11:50DranikI've just searched through github and there are really many links with "chouser" strings there... so I've got lost
11:50chouserDranik: http://joyofclojure.com/ FETCH parties IS demo.parties
11:50chouser FOR party IN parties
11:50chouser HAVING party.name = \"Old Timers\"
11:51chouserdoh
11:51chousersorry
11:52chouserDranik: http://joyofclojure.com/ http://tinyurl.com/fingertree https://github.com/Chouser/textjure https://github.com/Chouser/data-munge https://github.com/Chouser/clojure-irc-log https://github.com/Chouser/clojure-jna https://github.com/Chouser/clojure-classes
11:52Dranikchouser, thanks a lot!
11:53fbru02_into-array converts a seq into an array, is there a way to make a seq from an array ?
11:53chouserDranik: contrib is full of interesting and primarily high-quality code, too
11:53replacachouser: hey, do you know when we're going to see the dead-tree version of JoC?
11:53chouserfbru02_: seq
11:53chouserreplaca: soon. Maybe January?
11:53fbru02_chouser: don't know why i didn't try that :D
11:54chouser:-)
11:54replacachouser: excellent! Can't wait to have it on my shelf. Really nice discussion of records, types, and protocols there by the way
11:54replaca(among other things)
11:55fbru02_yeah i thought it was coll -> seq , didn't know it worked with java arrays
11:55chouserreplaca: thanks!
11:55Dranikchouser, clojure-jna -- wow! that's great!
11:55replacafbru02_: seq is the (almost) universal magic function
11:55fbru02_thanks !
11:56chouserfbru02_: also strings, iterators, etc.
11:56chouserDranik: there is a much more industrial-strength lib out there if clojure-jna's features are too thin for you: clj-native
11:58Dranikchouser, yep, I'll give it a try!
12:14Rayneschouser: You're fairly performance savvy, aren't you?
12:15RaynesI'm curious as to what would be the absolute dirtiest, rawest, fastest way to write this in Clojure: https://gist.github.com/c1b5a16b6ea582ef85ba
12:15chouserRaynes: s is always a string?
12:15RaynesThe idea is to just count the number of non-space characters in a string.
12:15RaynesI want the fastest possible thing I can get without using Java.
12:16chouserand this is on 1.3-alpha-something?
12:16Raynes1.2.0, but I'd be interested in 1.3-alpha versions as well if they make an important difference.
12:17chouserit makes a difference in the code, not the potential speed, I think.
12:18RaynesI'm trying to see how close I can get to some Java algorithms I've seen.
12:21RaynesI've wrote a version using loop, but it leaves much to be desired at an average of 138168.371 to run on a 460 character string 1000 times.
12:21RaynesThe fastest Java solution I saw ran at just under 3000 nanoseconds.
12:22chouserhm, I'm not sure how to do primitive char equality
12:23amatosIn clojure.test what is the equivalent of JUnit's assertEquals(double, double, delta)? Basically comparing doubles but passing a small delta because doubles are never exact?
12:27chouserRaynes: I think the problem might be that char comparison. I can't think of a way to check the equality of chars without autoboxing them.
12:28Raynes:\
12:29chouserhmm...
12:32chouser(defn count-num-chars [^String s] (let [len (.length s), space (int 32)] (loop [i (int 0), c (int 0)] (if (< i len) (recur (inc i) (if (== (.codePointAt s i) space) c (inc c))) c))))
12:33chouserI've done no profiling of that, but it ought to produce bytecode that deals only with primitives and does no reflection
12:33Rayneschouser: Runs slower than my loop version.
12:33chousernoooo
12:33RaynesMarginally. :p
12:33chousergood thing I shrugged in the first place. :-)
12:33chouserwhat's yours?
12:34Rayneshttps://gist.github.com/51073bc37369fcda9368
12:34RaynesNothing special at all, actually.
12:35RaynesI wrote an example with reduce that runs around the same time as yours does.
12:35chouserhm, I must have missed something in mine then.
12:35RaynesMore eye watering code? :p
12:35chouseroh
12:35chouser#^String
12:36chouseryou probably caught that already?
12:36RaynesNope, did the same thing in my example as well.
12:36RaynesDoesn't seem to make a difference though.
12:37chouserhm, I guess 1.2 already supported ^ for tagging
12:37RaynesI thought so. I was already googling to make sure.
12:38chouserI suppose .codePointAt might be slow
12:39chouserperformance questions might do better on the google group
12:40RaynesI'm not sure I care enough to bother the group with it.
12:40RaynesIt's a trivial example that I was just obsessing over.
12:40chouserI bet there are people on the group who would enjoy it.
12:41RaynesYou have a point. I guess I'll go ahead and post it and see what I can get.
12:41RaynesThanks for trying. <3
12:41chouser:-) sorry I didn't help
12:42RaynesWell, you did help. It was a demonstration that "Hey, even though I'm obviously much smarter than you, even I could come up with a speedy example."
12:42Raynes(inc ego)
12:42sexpbot⟹ 1
12:43chouserRaynes: are you using a profiler?
12:44RaynesNo. Just a bit of code that checks the current nanotime, runs the code 1000 times, and then checks the nanotime again.
12:44amalloyRaynes: wouldn't it be faster to convert the string to a byte[] first?
12:45Raynesamalloy: If you think you can implement it faster, go for it. I'm interested in all sorts of fun ideas. :>
12:47gtrak(inc nil)
12:47sexpbot⟹ 1
12:48gtrak(nil)
12:50clizzin_is there a way to take a sequence of lazy sequences and make one lazy sequence that iterates through each of the elements of those lazy sequences in turn? basically, i'd like to (apply lazy-cat foo) where foo is a sequence of lazy sequences, but unfortunately i can't apply a macro.
12:51chouser(apply concat foo) should do what I you want, I believe.
12:52amalloyclizzin_: or mapcat before you get those lazy sequences: ##(mapcat range [5 6])
12:52sexpbot⟹ (0 1 2 3 4 0 1 2 3 4 5)
12:52chouserthe only what that lazy-cat is more lazy than concat is that because concat is a function, it's arguments will normally all be evaluated first.
12:52chouserbut apply itself is lazy, so you should be ok
12:53clizzin_amalloy, chouser: great info, thanks!
13:09Rayneschouser: Switching to using unchecked-inc in your version gives me an extreme speed increase.
13:09Raynesrayne@ubuntu:~$ cake run ~/challenge.clj
13:09RaynesChars outputted: 460
13:09RaynesTime (in nanoseconds): 5711.932
13:10tomoj(.start (Thread. (fn [] (loop [] (.read stream (byte-array (.available stream))) ()))))
13:10tomojthat makes no sense, right?
13:13tomojthe loop form can be removed, and the empty list at the end as well if the return value is ignored? (.start (Thread. (fn [] (.read stream (byte-array (.available stream)))))) ?
13:13Rayneschouser: I also changed .codePointAt to be (int (.charAt ..)), because .codePointAt was a huge bottleneck.
13:17clizzin_hmm so the behaviour i was attempting to achieve is to create a lazy sequence on top of a sequence of readers. so i have a function (defn datum-seq [filenames] (mapcat (comp line-seq clojure.java.io/reader) filenames)). and then i have a function foo that iterates through a sequence and updates a transient map as it goes. my hope was to have the iteration through lines in the files be such that it discards files (or even b
13:17clizzin_lines) from memory as soon as it's done with them, but i'm seeing linear growth in memory as foo iterates through the sequence that suggests that the file contents are being cached. anyone have any ideas on how i can achieve the behaviour i'm looking for? thanks in advance!
13:23amalloyclizzin_: garbage collection only runs when it's needed. if you have enough memory to keep it all cached, the gc won't bother cleaning it up even if clojure has thrown away all references to the earlier stuff
13:24technomancyclizzin_: you need to use with-open for readers; this doesn't play nicely with laziness.
13:25amalloyclizzin_: see http://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx for an interesting take on this, even if it is from a CLR perspective
13:28clizzinamalloy, technomancy: hmmm. ideally, i'd like to create a sequence abstraction over all the lines of these files so that foo can take any sequence of data as input. it sounds like this isn't possible without manually opening/closing each file as the iteration starts/finishes with that file's lines, but how can i have the resulting function be treated as a sequence? i come from a python background, so the best way i can expl
13:28clizzinwhat i'm trying to achieve is the equivalent of a python generator.
13:28clizzinalso feel free to let me know if i'm thinking about this all wrong
13:30clizzinmy main concern is that i can't hold all of the data in these files in memory at once, so i thought making a lazy sequence on top of the readers would avoid caching the contents of multiple files at once.
13:52leif-pHi, all. Is there a clojure json lib that accepts all legal json? c.c.json/read-json seems to take only a subset.
13:52Raynes$google clj-json
13:52sexpbotFirst out of 459 results is: mmcgrana/clj-json - GitHub
13:52sexpbothttps://github.com/mmcgrana/clj-json
13:52RaynesThat probably does.
13:53RaynesIt wraps a Java JSON lib though, so it isn't a pure Clojure implementation.
13:55chouserclizzin: having a lazy seq close an underlying resource (like a file) when it is fully consumed is generally considered fragile, because of how often lazy seqs in general are abandoned before being fully consumed.
13:56chouserclizzin: but in your case, it may be less objectionable since you should be able to guarantee that no more than one file is open at a time.
14:03raekleif-p: what does it not accept?
14:07technomancyapparently clj-time has not released any stable versions; what's up with that? ಠ_ಠ
14:08leif-praek: maps with numeric keys. Hmm... I'm just assuming that's legal json, let me check. And while it technically accepts maps with any string keys, the fact that it automatically converts them all to keywords means the result is hard to use if any of the keys contain clojure special characters.
14:10raekthe awesome syntax diagram of http://json.org/ suggests that it isn't allowed to have numbers as keys in json
14:11raekleif-p: you can turn off the keywordization of you like
14:12raekor you can construct keywords from strings ##(keyword "\u2603")
14:12sexpbot⟹ :☃
14:13raek(unicode snowman)
14:14raekbut yeah, keywordization is perhaps not always a good idea
14:14raek,(doc read-json)
14:14clojurebotGabh mo leithscéal?
14:14raek&(doc read-json)
14:14sexpbotjava.lang.Exception: Unable to resolve var: read-json in this context
14:15raek&(use clojure.contrib.json)
14:15sexpbotjava.lang.ClassNotFoundException: clojure.contrib.json
14:17leif-praek: You're right, I am looking at that right now. I guess I am using json wrong. Unfortunately, when almost all json libraries dump to string, they fix my mistake, and js might be doing some str->num magic. :(
14:22dnmtechnomancy: Hey there.
14:23dnmtechnomancy: Quick question. Are you still in Seattle? I happened to be perusing the careers section of the Sonian website, and it seems all the open positions are in Boston. Is there still a telecommute option available for certain roles?
14:29technomancydnm: all our engineering roles are telecommute, but I'm not sure if we are actively looking for Clojure hackers right now. I'll ask.
14:34dnmtechnomancy: Ah, I see. Thanks for asking! It happened to be an interesting conincidence, as I was just mentioning elsewhere (#dylan) that I missed Boston and would consider moving there second to moving to Seattle, but didn't know what I would do in Boston. And last I knew, you, anyway, were in Seattle with Sonian. I didn't know they were Boston-based.
14:35technomancywe hire wherever there's talent
14:36technomancyI'm in Seattle, but I work with people all over the place.
14:36technomancyare you in Seattle?
14:37dnmNo. Currently I'm in the D.C. area.
14:37dnmBut I have plans to move to Seattle.
14:37technomancyit's great; I love it
14:38technomancysee also http://seajure.technomancy.us of course
14:38dnmIs the picture of the bench that showed up on Fogus's interview of you from Green Lake?
14:38dnmOr elsewhere?
14:38fogus`dnm: Have you been out to any of the NOVA Clojure meetups?
14:39dnmfogus`: Sadly no, they're all out in Reston, and I am never out that far. I live carless in Arlington, and I work in downtown D.C. during the day.
14:39dnmfogus`: Would like to meet up with local Clojure hackers though.
14:40technomancydnm: that's a park across the street from my house, but I love working from the shores of Green Lake in the summer =)
14:40technomancydnm: http://www.flickr.com/photos/technomancy/4798518932/
14:40fogus`dnm: People are usually willing to do drop/pick at local metro stations
14:40dnmtechnomancy: Intensely envious. ;] Looking at apartments on padmapper.com, it seems I can find a place in Seattle or surrounding areas for less than I pay here, which seems like a win/win!
14:41technomancydnm: my remoteoffice flickr feed is a covert Sonian recruitment mechanism.
14:41technomancynot as effective in the Winter though =(
14:41dnmfogus`: Yeah, which is very nice of them. Usually they also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending.
14:41dnms/they/the meetups/
14:41sexpbot<dnm> fogus`: Yeah, which is very nice of them. Usually the meetups also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending.
14:42dnmfogus`: One of these days, maybe. Do you know of any Arlington or D.C. proper Clojure hackers? I'd love to do something even less formal than a capital-M meetup.
14:42fogus`dnm: Too bad. If the time is ever not a factor then ping the meetup page. I'm certain someone will volunteer as chauffeur. ;-)
14:43fogus`dnm: Surprisingly DC/VA/MD seems to be a hotbed of Lispiness
14:43chouserFort Wayne too
14:43dnmtechnomancy: Seattle's great attraction for me is to escape humid Virginia summers.
14:43chouserin my dreams
14:44dnmtechnomancy: Well, one of the great attractions anyway.
14:44fogus`The author of Land of Lisp lives in DC and he used to run the DC Fringe group. He might (hoping) restart those meetups again
14:44chouserin reality, Fort Wayne is a hotbed of military radio engineering.
14:44dnmConrad, yeah! I know Conrad. FringeDC's been kinda dormant for a while.
14:44Crowb4rFort Wayne IN?
14:45chouseryessir
14:45dnmThe last FringeDC meeting I went to was a talk on ML from a then-local company making their product in it. That was a few years back.
14:45Crowb4rchouser: heh, I'm not that far from you then
14:46Crowb4r<- Western Michigan
14:48chouserCrowb4r: cool
14:49chouserI keep meaning to go to one of the ohio clojure meetups
14:49Crowb4rfar in perspective to some I suppose..
14:49chouserCrowb4r: this is the midwest. < 4 hours drive is close
14:49Crowb4rI should drive down for that. there is a Detroit group that just started. I need to look at Chicago as well.
14:49chouserin Europe that might require a passport, but here it's just "going in to town"
14:50Crowb4ryeah
14:50chouserCrowb4r: I talked at the Chicago one once -- nice folks. But it takes too long to do regularly
14:50Crowb4rI'm in Holland, right on Lake Michigan so pretty much I can only go east or south for 4 hours to hit anything (but Grand Rapids)
14:51pjstadigdnm: i'm also in the DC area, and i work for Sonian
14:51dnmpjstadig: Hi there!
14:57dnmfogus`: Are you in the area?
14:58fogus`dnm: Indeed
14:59dnmfogus`: Ah, neat!
15:01pjstadigfogus` has presented at the clojure group several times
15:11brehautmorning
15:30AWizzArdbrehaut: good evening brehaut
15:30brehautAWizzArd: clearly i forgot my timezone again
15:30AWizzArd21:32 in Germany
15:31brehaut09:32 in new zealand
15:31AWizzArdSo, middle Earth is on the other side of the world :)
15:31brehautyup :)
15:32dnmbrehaut: Where are you in NZ?
15:33brehautdnm hamilton
15:33AWizzArdHow far away is that from Hobbingen?
15:33dnmAh. I converse regularly with a Dylan developer in Wellington.
15:33brehautAWizzArd: maybe half an hour
15:33brehautdnm: there are still dylan developers?!
15:34dnmYes. We're a rare breed, I guess ;]
15:34brehautdnm: i guess. pretty cool though
15:34dnmNot only that, there's another Dylan developer who uses Clojure regularly.
15:35brehauti guess if you are going to use one relatively unknown language, why not use 2
15:35dnmHeh.
15:41brehautfogus`: ping?
15:44fogus`pong
15:45brehautfogus`: i tried to tweet a bug report at you but twitter is doing weird nonsense. anyway, xml-> is getting rendered as xml-&gt; while -> is still ->
15:47fogus`brehaut: Thanks will look into that
15:47brehautfogus`: ive also got a curious case where marginalia is thinking that the body of a condp is code to output verbatim in the doc side of the uberdoc
15:48fogus`brehaut: Do you mind creating a case at https://github.com/fogus/marginalia/issues with a link to the code you're trying to operate on?
15:48brehautsure thing
15:48fogus`Thank you!
15:48brehautnot a problem
15:57brehautfogus`: https://github.com/fogus/marginalia/issues/#issue/4
16:04fogus`brehaut: The dangers of regex! Thanks again. Gotta run, but it should be fixed some time today
16:04brehautfogus`: not a problem. cheers
16:43brehaut(inc tonyl)
16:43sexpbot⟹ 1
17:19raekoh, java... http://www.youtube.com/watch?v=wDN_EYUvUq0
17:19raekinteresting though...
17:30raek&(= (.hashCode "polygenelubricants") (Integer/MIN_VALUE))
17:30sexpbot⟹ true
17:31brehautraek: what the?!
17:32raek(see the video...)
17:32raekalso:
17:32raek(Math/abs (Integer/MIN_VALUE))
17:32raek&(Math/abs (Integer/MIN_VALUE))
17:32sexpbot⟹ -2147483648
17:32brehauti havent, my internet connections incredibly lame today
17:32raekhrm
17:34raekah, Raynes's long decorative arrow hid the minus sign...
17:34raekso, yupp. the abs function can return a negative value
17:35brehautso strange
17:35raeksince there are one more negative Integer than positive
17:36brehautah true
17:36raekhrm, why did using that static field as a method work?
17:36raek&(Math/abs Integer/MIN_VALUE)
17:36sexpbot⟹ -2147483648
17:37raek&(Integer/MIN_VALUE)
17:37sexpbot⟹ -2147483648
18:08joshua__amalloy, the plugin is pretty much done =) XML worked wonderfully. The only thing that needs to be fixed at the moment is this really dumb bug. Basically there is a file where you specifcy what amounts to a config page and even though I changed that file it is still compiling as if I had not changed it.. anyways that is not why I came here..
18:08joshua__Trying to connect to mongodb is giving me a network exception error.
18:09joshua__Any idea where the problem might be?
18:09amalloyjoshua__: $ sudo mongod, is what usually fixes it for me
18:09amalloyISTR i fixed something in my etc/init.d or thereabouts to get this to stop happening, let me see if i can find it
18:10joshua__Wed Dec 22 15:10:50 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
18:10joshua__That doesn't look right..
18:12joshua__It is actually happening in my command line too.
18:12joshua__Not just when I start up swank
18:12amalloyjoshua__: are you root? permission-denied errors often look like not-found errors to java
18:12amalloythis is to start the server, not to connect to it
18:12joshua__amalloy, I didn't grok what you said?
18:13joshua__oh
18:13joshua__yea I rank sudo mongod
18:43zkimIs there any way to clone a java class in clojure? I'd like to muck with a static member on a class (specifically c.l.LispReader), but I don't want to interfere with the operation of other consumers.
19:19programbleum
19:20programblecake isn't working
19:20programblei run it and after a while it says it's taking long to connect to the JVM, but it never starts a JVM
19:21ninjuddprogramble: i need more information than that. which version are you using? how did you install it? etc...
19:22programble0.5.8 from gem
19:23programbleoh it works if i'm not in a project dir...
19:23programblebut fails in my clone of penumbra
19:23ninjuddprogramble: ah
19:23ninjuddyou have to upgrade to the latest cake to use penumbra
19:24ninjuddi just fixed that yesterday actually
19:24ninjudduse the "Git repository" installation method from https://github.com/ninjudd/cake
19:25ninjuddlancepantz was working on adding cake tasks for the penumbra examples actually
19:26lancepantzjees, i can't tell if it's penumbra or cake gaining in popularity :)
19:27lancepantzprogramble: but yeah, i have some commits i'm queueing up for https://github.com/lancepantz/penumbra i'll push later today
19:27ninjuddprogramble: you're the second person to ask about using penumbra with cake in the past two days. and nobody ever asked before that
19:27programblewell i'm just looking at penumbra cuz i'm bored
19:29ninjuddthat explains it!
19:29programbleand i'm using cake because it is apparently "oh so much" better than lein
19:29programbleguys
19:29programbleon every run of cake i get this:
19:29programble$ cake
19:29programblewhich: invalid option -- 's'
19:30programble/usr/bin/wget
19:30ninjudddoh
19:30ninjuddthat's from a commit i just added. i guess that is an os x only opt
19:30ninjuddfixing
19:31ninjuddprogramble: fixed
19:32programbleOH MY GOD HOW DO I CLOSE THE PONG EXAMPLE
19:32ninjuddhahah
19:32ninjudddid you start it with cake?
19:32programblei started it from a cake repl
19:32ninjuddyou exited the repl?
19:32ninjudd'cake kill' will work
19:33ninjuddon os x, clicked the 'x' on the window works too
19:33programbleit doesn't get a window border here
19:33ninjuddoh no
19:34ninjuddctrl-c in the repl
19:34ninjuddif it is still running after that, 'cake kill'
19:35programbledo not understand opengl at all
19:40clizzinif i pass a lazy sequence as an argument to a function that uses it only for the first instruction, do all the realised members of the lazy sequence stay in memory until the function exits? or is the sequence garbage collected after the last use of it?
19:41technomancyclizzin: as long as you're on 1.2 or newer, you're clear after the last use.
19:42technomancy"fine-grained locals-clearing", in the vernacular
19:43clizzintechnomancy: cool, thanks for the information. is there any way to tell the lazy seq not to bother caching realised members?
19:43clizzini've got a case where the cost of computing the sequence members is cheap but there are a whole lot of them, so i don't want them to be cached in memory
19:43technomancyclizzin: no, you have to ensure references to the head are GC'd
19:46clizzintechnomancy: hmm okay. what is the behaviour of a lazy sequence if iterated over using loop? are the members still cached?, e.g. (loop [i (lazy-seq foo)] ...)?
19:47technomancyclizzin: depends. if you recur on (rest i) you're probably clear.
19:48technomancyyou can construct a test with an infinite seq to be sure
19:51clizzintechnomancy: interesting. so my situation is that i'm doing (foo (lazy-seq...)) where foo is (defn foo [s] (bar s)) and bar is (defn bar [s] (loop [sequence s] ... (recur (rest s))). it sounds like keeping things decomposed into separate functions like this would result in all the members of the lazy sequence getting cached because the foo and bar scopes retain references to the head.
19:51clizzinso now i'm tempted to mash them all into one big function so that the lazy sequence is passed directly into the loop.
19:52clizzinor is clojure smart enough to figure out that this chain of calls ends with a loop that recurs on (rest s)?
19:53mabeshow could I tell if a certain deftype/defrecord implements a fn.. you can use satisfies? to see if it "implements" the protocol, but I've noticed that def[record|type] does not enforce a method be defined for each signature
19:53technomancyclizzin: I suspect it will be smart enough, but you will need to confirm this with Science.
19:53clizzintechnomancy: Science!
19:53technomancyclizzin: http://www.topatoco.com/merchant.mvc?Screen=PROD&amp;Store_Code=TO&amp;Product_Code=DC-BISCUIT&amp;Category_Code=DC
19:53mabesI know you can look at the protocol and that the methods should live on it somewhere, but I'm having a hard time finding them
19:53clizzinalright, time to give it a shot. thanks for the help!
19:54clizzintechnomancy: haha nice
19:54technomancynp
19:59joshua__Is there a way to tell congomongo to declare an index on a key?
19:59joshua__declare/create
20:00joshua__or do I need to do that within mongodb itself
20:05midsjoshua__: add-index!
20:07joshua__thanks!
20:15joshua__mids, any idea where I can get more thorough documentation of congomongo?
20:22joshua__Best I've seen: http://clojuredocs.org/incanter/1.2.3-SNAPSHOT/incanter.mongodb
20:35joshua__Where can I find info on query maps for mongodb?
20:59arohnerdoes anyone have any good tricks for figuring out what part of performance problems are caused by cache misses?
21:33datkaAre multimethods supposed to hold on to their dispatch fn, or is it possible to change that function dynamically. I made a change to my dispatch fn, and it wasn't picked up. (1.3)
21:33amalloydatka: i don't know what is "supposed" to happen, but that is the behavior in 1.2 also
21:34datkait's probably by design and for performance reasons, but it's a bit annoying
21:34amalloyagreed
21:39pdkoh snap is 1.3 out
21:40tomojI don't see it
21:40joshua__(GET "/item?id=:id" [id] (archive-item id)) Why is this not matching /item?id=2312312?
21:41datkaI'm jumping the gun on upgrading to 1.3, it's not out yet. (unless I missed something)
21:44joshua__To answer my own question the ?id is being treated as a get parameter.
22:01brehautanyone here know much about moustache ?
22:05bhenrybrehaut: depends on how much
22:05brehautbhenry: how easy is it to use moustache's pattern matcher outside of moustache
22:06bhenrybrehaut: uhh. i've only ever used it the standard way. what are you trying to do?
22:06brehautbhenry: minimise the amount of repetition in a pingback implementation
22:07brehautbhenry: pingback is xml-rpc which means it tunnels through http and then dispatches itself based on the method not the resource
22:07brehautbut pingback also has to check that the resource being pinged back exists
22:09bhenrybrehaut: well i guess i'm not the man for this, but moustache is only one file, so you should take a look at it. https://github.com/cgrand/moustache/blob/master/src/net/cgrand/moustache.clj
22:09brehautbhenry: that was my next step.
22:13brehautjudging by the number of private functiosn that i think i would need, i might be screwed