#clojure logs

2011-12-28

01:06quizme_how do you select a subset of attributes from a sequence of hashes? {"id1" {:name "Bob" :age 21 :favorite-icecream "vanilla" } "id2" {:name "Fred" :age 22 :favorite-icecream "chocolate" } …..} I only want a sequence with :name and :age, but not :favorite-icecream.
01:07quizme_can you do that with restructuring?
01:07quizme_i mean destructuring
01:08quizme_i want the result to look like {"id1" {:name "Bob" :age 21} "id2" {:name "Fred" :age 22}}
02:03quizme_http://pastie.org/3083295
02:32clj_newbhow does reload-all and reload differ?
02:34clj_newbhow does reload-all and reload differ?
03:03gf3is there an idiomatic naming scheme for conversion functions? e.g. `namespace-to-filename`
03:31clj_newbare the values java.awt.event.KeyEvent/VK_A -> java.awt.event.KeyEvent/VK_Z guaranteed to be consecutive?
03:33CmdrDatsclj_newb: I wouldn't count on it, no
03:42kralmorning
03:43CmdrDatsgood morning :)
03:49sgronblo2Anyone know of any video presentations for writing web apps in clojure? I've already seen the one on ring on blip.tv.
04:08clj_newbis there a way to get a list of all the files in clojure.core? I want to answer questions like: "what function will tell me if X is a substring of Y"
04:08clj_newbs/files/functions/
04:12jakeskikclj_newb: http://clojuredocs.org/quickref/Clojure%20Core
04:29clj_newbjakeskik: thanks
04:31clj_newbwhy does every? have a ?; but some does not have a ? ?
04:34pyrtsasome doesn't in general return true or false but the first truey item it finds.
04:35clj_newbpyrtsa: makes sense now; thanks!
05:31clj_newbwhen an assertion fails; waht is thrown/generated?
05:32clj_newbI'm writing my own assertion-like macro (the default asertion is not expressive enough, even w/ its msg argument); and I want it to generate the same runtime objects as asert does
06:42CmdrDatsanybody know of a site that one can automatically upload your library code docs and samples to when you do a lein build (similar to clojars, but for documentation)?
06:52clj_newbis there a builtin for converting lists/vectors into maps?
06:52clj_newbinquiring minds want to know :-)
06:56CmdrDatsif your vector is in the format [key value key value] , you can just (apply hash-map myvector)
06:57clj_newbwhoa
06:57clj_newbcool
06:58clj_newbdumb question: what if it's in the form of [ [k1 v1] [k2 v2] [k3 v3] ... ] ?
07:00CmdrDats##(apply merge [[:k1 1] [:k2 2]])
07:00lazybot⇒ [:k1 1 [:k2 2]]
07:00CmdrDatshmm, no
07:01clj_newbi want somethign liek flatten
07:01clj_newbbut only 1 level
07:01CmdrDats##(apply hash-map (flatten [[:k1 1] [:k2 2]]))
07:01lazybot⇒ {:k1 1, :k2 2}
07:01clj_newb##(flatten [ [ [ 1 2] 3 ] ])
07:01lazybot⇒ (1 2 3)
07:01clj_newbthis is bad, as I do have nested vectors
07:01CmdrDatsah
07:03CmdrDats##(apply into {} [[:k1 1] [:k2 2]])
07:03lazybotclojure.lang.ArityException: Wrong number of args (3) passed to: core$into
07:04CmdrDats##(into {} [[:k1 1] [:k2 2]])
07:04lazybot⇒ {:k1 1, :k2 2}
07:04CmdrDatsthat works :P
07:04CmdrDats##(into {} [[:k1 [:epic :vector]] [:k2 "simple"]])
07:04lazybot⇒ {:k1 [:epic :vector], :k2 "simple"}
07:05CmdrDats(i always forget about into for some reason)
07:08clj_newb##(doc into)
07:08lazybot⇒ "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
07:08clj_newbbrilliant; thanks!
07:13CmdrDatscool :) anytime
07:19SomelauwIs there ever any difference between merge and conj? They seem to behave exactly the same.
07:21cemerickSomelauw: For maps, no, but I'd classify that as an implementation detail you shouldn't rely upon.
07:22SomelauwWhen should I favor merge over conj?
07:29cemerickSomelauw: per the docs of `merge`, it should be used when combining maps.
07:36SomelauwSo conj shouldn't be used when combining maps? Or should conj only be used when adding a single pair of key value.
07:46zawzeyHi, trying to download with clojurescript. but having lots of problems trying to get the sample code to run
07:48zawzeyhttps://gist.github.com/1527832
07:49cemerickSomelauw: IMO, no, conj should only be used to add an entry to a map; the fact that it merges maps as well is likely vestigial.
07:49cemerickhttp://groups.google.com/group/clojure/browse_frm/thread/e499d7d184aba772
08:19Somelauwthanks
09:27fbru02Hi all, this must be a stupid question : if I have a closure over a function "foo" let's say (def bar (foo 2)) : is there a way having the var #'bar to get '(foo 2)
09:28fbru02?
09:29CmdrDatsfbru02: I doubt there is a way to do that as (foo 2) would get evaluated when you (def bar …)?
09:30CmdrDatsyou could (def bar `(foo 2)) and then you can get the actual closure function via (eval bar) maybe?
09:32fbru02CmdrDats: you a right , i think it gets evaluated right away to a IFn obj
09:34CmdrDatsfbru02: ye, a bit difficult to reverse engineer from there :P (except maybe with some macro/metadata kung-fu)
09:35fbru02CmdrDats: yeah meaybe i put it in the metadata :) thanks ! :)
09:35CmdrDatsfbru02: cool, glad i could help
10:17TimMcfbru02_: You could write a macro to do that.
10:18fbru02_TimMc: can't think how now :/
10:19TimMcInstead of def, you would use your macro.
10:20TimMcI believe serializable-fn does exactly this, check it out.
10:21fbru02_TimMc: thanks will look into that :)
10:31clj_newbis there a clojure builtin to read all files in the current directory?
10:32clj_newbso it would return me a []
10:32clj_newbwhere for files, it stores a string, and for directories, it stores some object that I can recursively read
10:33clj_newbhttp://rosettacode.org/wiki/Walk_a_directory/Recursively#Clojure
10:33clj_newbvictory
10:39stuartsierraclj_newb: file-seq is what you want
10:40stuartsierramaybe
10:49TimMcclj_newb: slurp
10:53miggyxHi guys, can anyone recommend a book on Clojure? I have some Amazon gift vouchers to use up and I want to make them count :)
10:55antares_miggyx: the joy of clojure is my personal favorite but it is not for complete beginners. Clojure Programming from O'Reilly (not in print yet, AFAIK) and Practical Clojure are also good.
10:55antares_miggyx: Programming Clojure 1st edition from PragProg is pretty outdated, 2nd edition I haven't read yet
10:55miggyxantares_: by complete beginners, do you mean to functional programming in general or specifically clojure?
10:56antares_miggyx: a little bit of both :) if you are well versed in multiple different languages, then you probably should go with The Joy of Clojure
10:56miggyxantares_: sounds like a plan - thanks :)
11:03miggyxantares_: order placed :)
11:05antares_miggyx: I hope you enjoy it :)
11:06miggyxantares_: me too - always keen to stretch the mind :)
11:14tscheiblwas sinf WMS, LCNS und MOPS?
11:14tscheibloops sorry... wrong window
11:57ambrosebswhat does with-loading-context do, and why is it necessary to wrap the body of each `ns` form with it?
12:07ambrosebsI see it has something to do with classloaders, but whats the diff between (with-loading-context (require ...)) and (require ....)
12:27clj_newbis ther esime java lib I can import; which will give me one of those "choose a file: dialogs" that can navigagte the file system (and return to clojure the filename)
12:28clj_newbIs there some java lib I can import which will give me one of those "choose a file: dialogs" that can navigagte the file system (and return to clojure the filename that the user has chosen)? Thanks!
12:29ldhclj_newb: I've used seesaw (https://github.com/daveray/seesaw) to do Swing stuff from Clojure
12:33clj_newbseesaw provides this?
12:33clj_newbi've just been using java interop via proxy
12:34dabd_The following code that uses http-agent https://gist.github.com/1528807 is not working. Could it be because of the shutdown-agents being called out of place? Why is the println in the handler function not showing anything in the console? thx
12:35ldhclj_newb: IIRC, seesaw provides a more clojure-y way to do the regular Swing stuff
12:45tmciverdabd_: It looks like file in your let binding is just a String; you're trying to call a java.io.File method (getCanonicalPath) on that String.
12:46clj_newbsuppose I need to do real time java
12:46clj_newbi.e. have a timer ticking down to be accurate to teh seconds
12:46clj_newbwhat options do I need to pass to the jvm?
12:49dabd_tmciver: I also tried with File. but it does not work either
12:52tmciverdabd_: I'm not familiar with http.agent but I'm wondering if you have access to 'url' in your handler function.
12:53tmciverdabd_: I suspect you may be able to get the uri through the agent that is passed in to your handler function.
14:22amalloyanyone have an opinion about writing (concat foo [bar]) vs `(~@foo ~bar) to add something to the end of a sequence?
14:24duck1123wouldn't it be less runtime for the latter?
14:24duck1123not that it's going to make a whole lot of difference
14:26Raynesamalloy: I wouldn't beat you with a 2x4 if you did the former while I would if you did the latter.
14:27amalloyduck1123: no, they're the same
14:27amalloy&'`(~@foo ~bar)
14:27lazybot⇒ (clojure.core/seq (clojure.core/concat foo (clojure.core/list bar)))
14:27RaynesExcept one of them looks like perljure.
14:28duck1123I would probably use the former if faced with that situation
14:36TimMcamalloy: Define snoc and no one will complain.
14:39amalloyugh, snoc. that name always sounds insufferably "clever" to me
14:39TimMcHow about (tacnoc [bar] foo)?
14:40TimMcIt doesn't have to be *called* snoc. How about append?
14:40TimMcHeck, you could even take multiple seqs, and call it concat.
14:41TimMcs/seqs/colls/
15:55wingiewould you write a game with a functional programming style?
15:55wingieor is it better with oop?
15:55TimMcSure, why not?
15:56wingiesince we have objects like soldier, weapon, grenade, tank etc isn't oop more suitable and fits the mind/game?
15:56TimMcwingie: How is this not an object? {:type :character, :subtype :NPE, :health 30, :healthmax 100}
15:57TimMcs/NPE/NPC/
15:58amalloywingie: since you have functions like "shoot", "eat", "travel", isn't fp more suitable?
15:58wingieamalloy: could have those as methods too
15:58amalloyobviously. my point is that you've framed the question in a way that assumes a particular answer, but it's easy to frame it differently
15:58wingieTimMc: won't we need inheritance for a game? eg. Corprol extends Soldier
15:59wingieCorpral
15:59TimMcwingie: Multimethods.
15:59amalloyCorporal
15:59wingie:)
15:59wingiewhy didn't i choose Lieutenant instead
15:59amalloyheh. i'd probably spell that one wrong. those big messes of vowels are confusing. bureau, really?
16:00wingie:)
16:00wingieenglish. hah!
16:00wingieare you guys using ClojureScript?
16:00wingiefor writing frontend apps
16:01amalloyanyway, you're saying "i will need all these oop techniques to build a game", which is true if and only if you choose to do it in an oop language. it's not clear what you hope to get from asking your question
16:01TimMcwingie: So, I think the question you were trying to ask is: Does a game require lots of mutation?
16:01wingieamalloy: just wanted to know if it would fit one's mind using a FP lang to code a game
16:01wingiesince OOP was kinda targeting systems like that
16:02wingieor if OOP would be a better choice in some areas, and FP in others
16:02wingieTimMc: by mutation you mean state changes?
16:03amalloyheh. you definitely need mutation if you're playing zerg, am i right?
16:04wingieyeah
16:04wingiehow did you know im playing Starcraft =)
16:04wingieand Zerg
16:07gunsI am trying to run Marginalia over Noir, and I get this error: "Map literal must contain an even number of forms" The stack trace:
16:07gunshttps://gist.github.com/1529739
16:07gunsHow do I go about debugging this?
16:08TimMcguns: Can you generate docs for just one file at a time?
16:08gunsTimMc: You can pass paths to Marginalia?
16:08gunsokay I will try
16:08TimMcguns: dunno
16:09gf3is there an idiomatic naming scheme for conversion functions? e.g. `namespace-to-filename`, etc...
16:09TimMcI've used foo->bar occasionally.
16:10gf3TimMc: good call, thank you
16:22mcrittendengiven a 3x3 multi-dimensional vector, I need to figure out if ANY of the values are numbers and return true if so, otherwise false. any hints on the best way to do this?
16:24TimMc&(some number? (apply concat (apply concat '[[[a b] [c]] [[d]]])))
16:24lazybot⇒ nil
16:24TimMc&(some number? (apply concat (apply concat '[[[a b] [9]] [[d]]])))
16:24lazybot⇒ true
16:25TimMcmcrittenden: Wait, is it 3-dimensional, or n-dimensional but always 3 on a side?
16:25wingiecan't it be said that functional programming and oop is different abstraction layers .. fp is low level (micro) and oop is an higher abstraction (macro). oop is using fp in the same way objects in this world is bound by the law of nature. so its just a matter of what level you wanna work on? And a stateful object (human) is not a function that runs and exits .. but runs and never exits (til its
16:25wingiedestroyed) why it never leaves its state and thus is stateful. Thoughts?
16:26mcrittendenTimMc it will always be [[val val val][val val val][val val val]]
16:26TimMcmcrittenden: Yeah, then the code above will work.
16:26amalloy(first (for [xs matrix, x xs, :when (number? x)] x))
16:26amalloyfinds you the first number, as a bonus
16:27mcrittendenis one preferred over the other? amalloy TimMc
16:28amalloyi think most people prefer TimMc to amalloy. as for the code, write whatever you like
16:28TimMchaha
16:28mcrittendenhaha
16:28mcrittendenthanks a ton guys
16:28RaynesI don't always talk to programmers, but when I do, I prefer amalloy.
16:28TimMcmcrittenden: I like amalloy's solution better, for the record -- but maybe with better binding names.
16:28RaynesKeep hacking my friends.
16:28amalloytbh though i hate the apply concat, personally. i'd write either that for, or possibly (some #(some number? %) matrix)
16:30mdeboardTimMc: lol
16:30mdeboardKeep drinking my beer.
16:33TimMcwingie: oop and fp are at the same level -- they're just different ways of modeling process and state.
16:33TimMcwingie: and they're not incompatible, either
16:41wingieTimMc: if everything is pure functions without side effects, how can a "person" be stateful?
16:42hroarkewingie: Imagine a top-level game loop function like (defn update-world [timestamp world input] ...) that returns a new world.
16:42hroarkeupdate-world can be pure, and you're still updating state.
16:43TimMcwingie: Why do you think there's any relationship between computers and the real world?
16:44wingieTimMc: since FP reminds me about math so Im trying to figure it all out
16:45Raynes(defn make-blue [person color] (assoc-in person [:hair :color] "blue"))
16:46licenserRaynes: that is wrong: (defn make-blue [person] (update-in person [:blood-alcohol] inc)) ^^
16:46wingiecould someone write that in javascript =)
16:47licenserit is in javascript :P with cljs
16:48wingiedo we have a compiler bot? =)
16:48Raynes&(+ 3 3)
16:48lazybot⇒ 6
16:48RaynesWe have two, actually.
16:48Raynes,(+ 3 3)
16:49clojurebot6
16:49licenserRthat was your cue,
16:49licensermono he means something like ,(cljs '(+ 3 3)) -> 3+3
16:49TimMcwingie: There's no bot here to compile CLJS , no.
16:50RaynesI assumed he wasn't talking about cljs.
16:50licenserI wonder why is the cljs compiler so unbelievable slow?
16:51TimMcwingie: And I'm working on a try-cljs with some other folks, but it is kind of broken-ish.
16:51RaynesYeah, it uses hiccup! It can't possibly work with hiccup.
16:51wingieTimMc: yeah .. didn't get the impression it was solid
16:51Raynes~guards
16:51clojurebotSEIZE HIM!
16:51TimMcwingie: I should really put up a warning on that page.
16:53hroarkeSo, core.logic is pretty close to magic.
16:53hroarkeBut, a little under-documented...
16:54hroarkeIs there any way to stream out relations and their facts, so I can save them persistently?
16:54amalloylicenser: it has to compile all of clojure.core twice in order to decide (+ 1 1) is 1+1, which i assume causes most of the dealy
16:55TimMc(+ 1 2) is instantaneous on my craptop.
16:55clojurebot3
16:55TimMcThanks, clojurebot.
16:56licenseramalloy: oi why twice/
16:57amalloyonce to get the compiler itself going (since it's written in clojure), and then again to compile the cljs you gave it
16:57amalloy(i realize it doesn't have to do the first step if you have a persistent compiler up)
16:57amalloy(or even the second, probably)
16:58emezeskeyeah, the only way to go with cljs is a persistent compiler
16:58emezeskeI have one that watches my cljs dir for changes, and it rebuilds everything in a fraction of a second
16:59licenser^^ I see
16:59licenseremezeske: cljs-watch?
16:59emezeskelicenser: nah, I rolled my own for some reason
17:00licenser^^
17:00licenseris it better? :P
17:01emezeskeyeah, I think maybe
17:01licenseris it on github (or alternatives)? ^^
17:01emezeskenot yet.. I guess if you want to see it I could throw it up there real quick without any packaging
17:01clojurebotHuh?
17:02licenseremezeske: well if it is better then cljs-watch I'd love to see it since I am using clojurescript on one of my projects ^^ that is if you won't mind - I guess others might like that too
17:03TimMcI'm curious how deep you had to go into the layers of the compiler to do that.
17:03emezeskelicenser: gimme a few, I'll put a rough copy on github. I'm not sure if it's better than cljs-watch, but maybe you can tell me!
17:04licenseremezeske: take all the time you need I really appreciate it :)
17:05emezeskelicenser: I actually have a bunch of cljs I want to put up eventually. I have a framework for sharing code between clj and cljs
17:05licenserneat
17:05licenserso I don't use clojure on the server side so I won't end up using that right away ^^
17:06emezeskeah, yeah, interesting
17:07licenserso cljs+json works great as a client only thing
17:07emezeskeyeah I was doing that for a while, was nice
17:07emezeskeI do use clj on the server side though, so I switched to just shuffling clojure expressions back and forth :)
17:09licenseremezeske: *nods* that is nice too ^^
17:15darrintI'm having trouble figuring out the state of the art for handling errors. I did (assert (= 200 statusCode)) which bails but doesn't show me what the code actually was. Any guidance?
17:15darrintI'd like to pack more info into my exception if I fail.
17:16TimMc&(doc assert)
17:16lazybot⇒ "Macro ([x] [x message]); Evaluates expr and throws an exception if it does not evaluate to logical true."
17:16TimMcYou could have a message that includes the info.
17:18darrintoh kay. I'm an an idiot. Thanks TimMc.
17:21amalloyTimMc: you should go into neurosurgery. irate patients: "I'm an idiot now. Thanks, TimMc.
17:25emezeskelicenser: super-ultra-rough version up at https://github.com/emezeske/cljs-autobuild
17:26emezeskelicenser: I'm sure it's broken; I ripped it out of my private repo
17:26licenseremezeske: thanks :) I'll have a look at it :)
17:27TimMcemezeske: I see clojure.contrib in there...
17:27TimMcIs that the 1.3-compat version?
17:28emezeskeI'm not actually sure how that works in my project. I think I don't explicitly depend on it, and some other dep I pull in does...
17:29emezeskeThe project.clj is probably very wrong, I just sort of tacked it in there
17:34licenseremezeske: it crashes with 'Could not locate clojure/contrib/command_line__init.class or clojure/contrib/command_line.clj'
17:35emezeskehmm, I guess it needs to depend on some clojure.contrib jar
17:36licenserclojure.tools.cli is supposed to replace c.c.command_line
17:36emezeskeahh
17:37emezeskeso maybe add [org.clojure/tools.cli "0.2.1"] to the :dependencies?
17:37licenserprobably will need to change some code to :use it instead of c.c
17:38Raynestools.cli has an entirely different API.
17:38RaynesIt isn't a drop-in replacement.
17:38TimMcemezeske: I guess the parts of contrib you are using are 1.3 compatible.
17:39licensersneaky sneaky
17:39emezeskeRaynes: is tools.cli meant to fully replace contrib.command-line?
17:39RaynesYes.
17:39emezeskeHmm, guess I should port it then
17:41licenserlooking at it it does not look too complicated
17:46emezeskeyeah, should just take a few
17:53emezeskelicenser: I changed it to use the new cli
17:57licenseremezeske: looks good :)
17:58emezeskelicenser: thanks for testing it!
17:58emezeskenow that it's up, I think I might add some features
17:58emezeskelike an option to find *.cljs files automatically
17:58licenseremezeske: thanks for setting it up :) now I'm trying out if it actually compiles stuff :P
17:59emezeskeawesome
17:59licensernot bad it seems to compile now lets see if the output makes sense
18:00licenserlets see lets see :)
18:00emezeskegogo!
18:01licenserlets fire up the erlang server ^^
18:01gf3if anyone has a moment to help me out, I'm having an issue using the second argument in clojail's sandbox function to pass in some bindings
18:01emezeskewhoa, you are erlang on the backend?
18:02licenseremezeske: yap :)
18:02gf3whenever I try to bind #'doc I get the following error "Unable to resolve var: doc in this context"
18:02emezeskelicenser: now that's a unique stack :P
18:02licenseremezeske: it is a quite excellent one ^^
18:02amalloygf3: does #'doc work in isolation?
18:02licenserthey are a good fit in my eyes
18:02emezeskeI can believe it
18:03gf3amalloy: in the context of the sandbox or the runner?
18:03amalloyi'd guess the runner
18:03gf3amalloy: no
18:03amalloywell then
18:03gf3amalloy: actually, in neither
18:03RaynesWhat are you trying to do, precisely?
18:04amalloyhe just needs to get his namespace forms right. doc in in clojure.repl
18:04gf3Raynes: I just want to use a different `doc` in the sandbox for prettier output
18:04licenseremezeske: if you ever want to sneak a peak it's up on gitup
18:04licenserhub
18:04RaynesProbably don't need to rebind doc.
18:04gf3Raynes / amalloy: I wrote a macro to clean up the standard doc output
18:04RaynesIt doesn't exist at all in clojure.core in 1.3.
18:04RaynesSo, you can just pass your code in the :init option.
18:05emezeskelicenser: yeah, link it! I'm curious
18:06licenseremezeske https://github.com/Licenser/erlpic
18:06Raynesgf3: https://github.com/flatland/lazybot/blob/develop/src/lazybot/plugins/clojure.clj#L36
18:06gf3Raynes: hmm, let me try that again, thank you
18:07licenserand emezeske it compiles like a charm :)
18:07emezeskelicenser: that's great.
18:08licenserI agree ^^ thanks mate
18:08Raynesgf3: I'm also curious as to what you're using clojail for. :>
18:08RaynesAlways fun to hear what people are doing with it.
18:09gf3Raynes: amazing, thank you, I'm not sure why I didn't try that initially since I was using :init to (use) other libs
18:09gf3Raynes: I'm sure for the same reason everyone else uses clojail, IRC bots
18:09licenseremezeske: if you look at the erlang stuff, feel free to poke me, it is horribly (mostly not at all) documented and a rather complex system ^^ but I'll glady explain things
18:09RaynesHaha.
18:09licensergf3: there is also try-clojure :P
18:09RaynesWell, I *did* use it for tryclj.
18:10emezeskelicenser: got a link that explains what EPIC is?
18:10gf3Raynes: I saw that, your source was actually very helpful to me
18:10licenseremezeske: not really no, the whole source material is not open sourced yet sadly but I probably should do that at some point. In short words it is a game engine for turn based combat
18:11gf3actually, Raynes, since I have you here, what is the purpose of this? https://github.com/Raynes/tryclojure/blob/master/src/tryclojure/models/eval.clj#L27-28
18:12licenserEPIC is the part of the game that handles combat logic, including stuff like custom AI scripts and fun like that ^^
18:12Raynesgf3: It is an extra precaution against keeping defs from residing in memory.
18:12RaynesI'm not sure it is actually necessary, but it doesn't hurt.
18:12gf3ahh neat, thanks
18:13emezeskelicenser: sounds like a fun project!
18:13licenseremezeske: it is started it with a few friends like 4 years back, they all ditched out over time sadly but I hate giving up since I love the idea behind it :P
18:14emezeske:)
18:16licensersadly I am stuck now at the GUI - and my gui-guy (I love the word) ditched me too but I hate guis so much :P
18:17emezeskebleh
18:18licenseremezeske: exactly, so I hope that cljs gets me around the tight spot there, since I am way more inclined to write clojure then javascript :P
18:21emezeskelicenser: yeah, I hear that!
18:24licenserso I still struggle a lot with it, I rather set up a network of dedicated erlang servers then write a webpage :P
18:27licenserbut one day, like 2020 I will have a game :P
18:28emezeskew00t!
18:29licenserso then likely all the technique will be outdated :P
18:29emezeskeyour game will just be retro
18:30licenserheh outdated not retro
18:38gf3hey Raynes, you know what would be cool, is if you could link to tryclj.com with some code pre-filled, a la coffeescript
18:39gf3http://jashkenas.github.com/coffee-script/#try:alert%20%22Hey%20there%2C%20Raynes!%22
18:40licenseremezeske: I'd have one request for your cljs-autobuild, show the time it used to build the file :)
18:40emezeskelicenser: yeah, I want that too.
18:41emezeskelicenser: I seem to remember running into some difficulty with that; maybe I'll revisit it
18:41licenseralso a DWIM mode would be nice so I could write (ns evil.gui) (make-my-damn-gui)
18:43emezeskelicenser: hmm, I'm not sure what you mean. just so you could compile via a REPL?
18:44licenseremezeske: DWIM is Do What I Mean, it is a joke mate :)
18:45emezeskehahaha
18:45emezeskeI read "make" in (make-my-damn-gui) as "compile" :P
18:45emezeskeas opposed to actually make :)
18:46licensermono, I meant make as in do it for me :P
18:46licensershoud slap a sudo in front of that perhaps
18:46emezeskehaha
18:49licenser*ponders* perhaps winning in the lottery and can buy a gui-guy is a more realistic goal o.O
19:12licenseremezeske: thanks mate you just gave me the energy to tackle the thing again :P
19:12gf3hmm, I wonder why strings weren't made collections...
19:12licensergf3: probably for performance reasons
19:13emezeskelicenser: glad to hear it!
19:14emezeskelicenser: just pushed my changes to print the time taken to compile
19:14gf3licenser: ahh, likely
19:14tmcivergf3: it can be ##(seq "Strings")
19:14lazybot⇒ (\S \t \r \i \n \g \s)
19:14licenserneat neat :D
19:14gf3tmciver: yes, they're seq-able, but they aren't collections
19:15gf3e.g.: ##(contains? "abc" "b")
19:15lazybot⇒ false
19:15tmcivergf3: curious, what do you need that you can't get with seq?
19:15tmciverahh
19:15gf3tmciver: of course it's all possible, I just thought it'd be interesting to use the collection goodies
19:16tmcivergf3: Yes, I see.
19:19amalloyaugh. that usage of contains? would be wrong with seqs too
19:20gf3also another cool feature could be strings as functions of their chars
19:20gf3actually, on that note, it seems inconsistent that vectors and hashmaps are functions of their members, but not lists
19:21amalloyit'd be cool if lots of things were functions, but it's never going to happen on the jvm. invoking functions needs to be fast, which means it needs to be a host-level thing like calling an interface method, which means you can't make built-in host objects support it
19:22gf3amalloy: do lists map to built-ins?
19:22amalloyno, that was a point about strings
19:22gf3ahh
19:22amalloy(and clojure chooses to use java.lang.String for strings, instead of inventing a clojure.lang.String, to make interop seamless. jruby has these sorts of features, but a lot more plumbing/busywork about mapping back and forth to real-java)
19:23amalloyif lists were functions of their indices, you would be tempted to use them in inefficient ways for no reason
19:24tmcivergf3: I too dumb to make this work in any case: ##(coll? (seq "abc"))
19:24lazybot⇒ true
19:24tmciverbut ##(contains? (seq "abc") \a)
19:24lazybot⇒ false
19:25tmciverwhat's wrong?
19:25amalloycontains?
19:25amalloyclojurebot: contains?
19:25clojurebotNo entiendo
19:26amalloywth
19:26amalloy~contains?
19:26clojurebotIt's greek to me.
19:26amalloywho deleted that factoid?
19:27tmcivercontains? is greek to me too. ;)
19:27amalloyclojurebot: contains? |is| for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use clojure.core/some or the Java method .contains
19:27clojurebotIk begrijp
19:27gf3ahh
19:28tmciver,(.contains "abc" "a")
19:28clojurebottrue
19:29tmciverwould that be an idiomatic approach then?
19:29tmciverusing a character doesn't work: ##(.contains "abc" \a)
19:29lazybotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.CharSequence
19:30technomancythere comes a time for every Clojure beginner when he thinks to himself "wait, vectors, maps, and sets are all functions... why aren't lists functions?" ... and then he realizes it doesn't make any sense
19:30technomancyregexes, on the other hand...!
19:32amalloyhaha
19:32amalloytechnomancy: also doesn't make sense, just for different reasons
19:33technomancythat's just, like, your opinion, man.
19:37amalloytechnomancy: if i were a better man, i'd have a response cleverly crafted to sound like that Ocean Marketing guy
19:43emezeskeI'd like to create a leiningen plugin that requires Clojure 1.3, which as I've read, is supported by lein 2.0. Does anyone know whether lein 2.0 is generally usable at this time?
19:44technomancyemezeske: it's a long way out
19:45emezesketechnomancy: thanks!
19:45technomancyemezeske: there's a trick in doc/PLUGINS.md that explains how to use 1.3 from lein 1.x; you basically create a dummy project to eval inside
19:45emezesketechnomancy: aha! that's exactly what I need.
19:47darqhello. i have a tree and i would like to output the path to the leafs using clojure.walk .. is it possible with clojure.walk?
19:48darrintDo I need to restart emacs/slime if I add deps to project.clj?
19:50darqYou have to start a new swank server (lein swank) ... so yes.. you must reconnect
19:50amalloythe full path to each leaf? it's pretty easy without clojure.walk
19:50darqyes . to each leaf
19:54technomancydarrint: yes, unless you use https://github.com/cemerick/pomegranate
19:55amalloydarq: sketch at https://gist.github.com/1530833
19:57amalloyyou can write something similar if you want your tree and nodes to just be sequences, by testing coll? to see if it's a sequence. but in that case interior nodes can't have values, so the path is not very interesting
19:59darqthx.
19:59TimMctmciver: The idiomatic approach would be ##(not= -1 (.indexOf "abc" "b"))
19:59lazybot⇒ true
20:00amalloy&(.contains "abc" "b")
20:00lazybot⇒ true
20:00tmciverTimMc: why that and not .contains?
20:01amalloyi suspect TimMc's point was that .indexOf has an overload for Character, but he forgot to actually do that
20:01tmciver,(not= -1 (.indexOf "abc" \b))
20:01clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: indexOf for class java.lang.String>
20:01amalloywelp, i lose again
20:02amalloy$javadoc String indexOf
20:02lazybothttp://download.oracle.com/javase/6/docs/api/java/lang/String.html#indexOf(int)
20:02TimMcwait wait wait .contains works?
20:02tmciverTimMc: nice of you to join the conversation. :)
20:02amalloyof course, why wouldn't it?
20:03TimMcAh, I missed the bot responses.
20:03TimMcamalloy: I guess because everything since Java v1.3 is new to me.
20:04amalloyTimMc: funny you should mention that, i was just reading through old javadocs to see if indexOf always took an int rather than a char
20:04TimMcI last used Java in 2001 and picked it up again in about 2007.
20:04amalloybut .contains has worked for substrings since at least 1.1
20:04TimMcamalloy: String#contains says "since 1.5"
20:04amalloyman, really?
20:05amalloymy memory has betrayed me
20:05TimMcI wonder if that refers to a widening from String -> CharSequence.
20:05TimMcNope, not there in 1.4.2.
20:05weavejesterI remember using Java 1.4 some years ago and being annoyed by String#contains
20:06amalloyweavejester: it allegedly wasn't there in 1.4, but i remember it too
20:06weavejesteramalloy: No, I mean I remember it not being there.
20:06weavejesteramalloy: It only worked with chars
20:08TimMcweavejester: That doesn't work now, does it?
20:08TimMc&(.contains "abc" \b)
20:08lazybotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.CharSequence
20:09amalloyTimMc: it does, if you write in java, because 'a' will be upcast to an int
20:09amalloywait, that's probably not true either
20:10weavejesterHm... I've just checked and .contains didn't exist in 1.4
20:10weavejesterMaybe I'm thinking of indexOf or something...
20:10TimMcyep
20:10amalloyjust tested, java does upcast characters to ints
20:10TimMccorrect
20:11TimMcOh, wild -- I never noticed that indexOf can take an int.
20:11TimMcWhat are the semantics of that?
20:12TimMc&Character/MAX_VALUE
20:12lazybot⇒ \￿
20:13TimMc&(.indexOf "abc" (inc Character/MAX_VALUE))
20:13lazybotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
20:13TimMc&(.indexOf "abc" (int (inc Character/MAX_VALUE)))
20:13lazybotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
20:14TimMc&(int \b) ; that's annoying
20:14lazybot⇒ 98
20:14TimMcOh wait, it's inc that's complaining.
20:15TimMc&(.indexOf "abc" (inc (int Character/MAX_VALUE))) ; no complaints
20:15lazybot⇒ -1
20:15gf3bah, I keep expecting ('(a b c) 'a) to work like (some #(= % 'a) '(a b c))
20:16amalloyTimMc: it's to account for the fact that unicode characters no longer fit in a java char
20:16weavejesterOh, it was .replace I was thinking of.
20:16weavejesterIn 1.4 it was only for chars
20:16weavejesterIn 1.5 and above it's overloaded for CharSequences as well.
20:17TimMcamalloy: They never did.
20:17amalloyso if you cast a character to an int, it looks up that character like a one-character string. if it's an int larger than a character, it goes into the "be careful, characters might be really large" mode
20:17weavejestergf3: ('#{a b c} 'a) does :)
20:18amalloyTimMc: really? i was under the impression that they picked the size of char in order to fit all standardized characters of the time
20:18gf3weavejester: amazing, thank you
20:18gf3weavejester: sets can only contain unique members though, correct?
20:18TimMcamalloy: I think surrogate pairs have been around since forever.
20:18TimMcMaybe I'm wrong!
20:18weavejestergf3: Yes, and they're unordered
20:19weavejestergf3: But if you have a list, and want to check it for something...
20:19weavejestergf3: Then sometimes you can just do ((set xs) x)
20:19weavejesterIt works well in maps and things
20:20weavejesterBy which I mean clojure.core/map, not hash-maps :)
20:20gf3weavejester: thanks for the tip, I'll be using that
20:20amalloy(some #{x} xs) is surely nicer
20:23technomancyin 1.2 sets can contain duplicate numbers
20:23technomancyif one is an Integer and one's a Long
20:23gf3technomancy: hax
20:24TimMctechnomancy: I noticed that ##{(long 5) :a, (int 5) :a} throws now!
20:24lazybotjava.lang.IllegalArgumentException: Duplicate key: 5
20:24TimMcSo glad.
20:25TimMcamalloy: "The Unicode standard has since been changed to allow for characters whose representation requires more than 16 bits."
20:26TimMcThat's Character in 1.5
20:27amalloyTimMc: so, that sounds like it means two bytes used to be enough, yeah?
20:27TimMcyep
20:28TimMcI guess I should keep read the "History of Unicode" section in that book I have in my cubicle at work.
20:28TimMcs/keep//
20:29technomancyTimMc: it still falls back to the broken behaviour if you use the Java methods, which is arguably correct since the interfaces require you to be wrong.
20:29amalloytechnomancy: well, sets can already have duplicate elements, sorta: ##(let [o (reify Object (hashCode [this] (rand-int 1000)) (equals [this x] false))] (hash-set o o))
20:29lazybot⇒ #{#<sandbox22696$eval25262$reify__25263 sandbox22696$eval25262$reify__25263@303> #<sandbox22696$eval25262$reify__25263 sandbox22696$eval25262$reify__25263@2d6>}
20:30technomancyheh
20:41TimMcClearly, the Java devs should have made j.l.Character an enum. That would have solved it.
20:44amalloyTimMc: worked for the haskell booleans (i think? not sure if that was something they *did* do, or just something that would be easy)
20:47xandrewswhat do people use in place of the old clojure.contrib.repl-utils/show ?
20:48TimMcIf it doesn't exist, that would be a nice little project.
20:51amalloyclojure.reflect, right?
20:52amalloy&(require '[clojure.reflect :as refl])
20:52lazybot⇒ nil
20:53amalloy&(keys (ns-publics 'clojure.reflect))
20:53lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
20:54amalloy&(refl/reflect (java.util.Date.))
20:54lazybot⇒ {:bases #{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.Cloneable}, :flags #{:public}, :members #{#clojure.reflect.Constructor{:name java.util.Date, :declaring-class java.util.Date, :parameter-types [java.lang.String], :exception-types [], :f... https://gist.github.com/1531104
20:56xandrewswow. lots of info there. show just prints out the method names and argument types. I'll need to write something to make it a bit more readable. Thanks!
20:57chipdude&(refl/reflect (java.util.Date))
20:57lazybotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
20:57chipdude&(refl/reflect java.util.Date)
20:57lazybot⇒ {:bases #{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.Cloneable}, :flags #{:public}, :members #{#clojure.reflect.Constructor{:name java.util.Date, :declaring-class java.util.Date, :parameter-types [java.lang.String], :exception-types [], :f... https://gist.github.com/1531121
20:57chipdudek
21:16aaelonyis this the right forum to ask a beginner's swank-clojure with Emacs question? I've finally decided to try emacs, have done lein deps with a project.clj containing swank-clojure as a dev dependency, have done M-x clojure-jack-in, and now I've got a simple (ns foo) expression that I'd like to send to the repl. C-x c-e gives me a backtrace, what do I need to do to get this to work?
21:18amalloyIME you have to C-c C-k the file it's in, to load the code
21:20aaelonythanks! that works :)
22:17gf3technomancy: ping
22:34unlinkHow do I interact with Java properties in clojure 1.3
22:34unlink...now that clojure-contrib has been split up?
22:36mindbenderunlink: what do you mean by Java properties
22:37unlinkj.u.Properties
22:41mindbenderunlink: I don't think you have to do anything special to use properties
22:41mindbenderfrom my repl I can do this without errors: (def prop-obj (doto (java.util.Properties.) (.putAll {"a" 1 "b" 2})))
22:41unlinkmindbender: Ah, yes, I'd like to *parse* properties files.
22:42mindbenderare you having any issues doing that?
22:44amalloy$javadoc java.util.Properties
22:44lazybothttp://download.oracle.com/javase/6/docs/api/java/util/Properties.html
22:45amalloyobserve the Properties#load method. give it an input stream, and your file is parsed
22:45unlinkBasically, I'm looking for something like (defn load-properties [f] (doto (java.util.Properties.) (.load (clojure.java.io/reader f))))
22:46unlinklike this (but not deprecated): http://richhickey.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/read-properties
22:46lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/read-properties and try to stop linking to rich's repo.
22:47amalloyso...you know exactly what code you want, and you've already written it. tada, problem solved, you're done!
22:48unlinkno, I was done after I complained about not being able to find it outside of clojure-contrib. My problem was a social one.
23:47ldhi'm struggling with getting vimclojure/nailgun to work (i suspect classpath issues). now i'm trying lein-nailgun, but when I add ["lein-nailgun" "0.1.0"] to my leiningen :dev-dependencies,
23:47ldhthen do "lein deps" and then "lein" I get "Warning: problem requiring leiningen.hooks.classpath hook: java.lang.ExceptionInInitializerError (classpath.clj:1)"
23:47ldhproblems persist until I delete the lein-nailgun dependencies from lib/dev