#clojure logs

2010-12-20

00:00tonylnot that i know of
00:01mister_roboto1ok thanks
00:03lopexthere's positions in seq-utils
00:05amalloy&(count (take-while (complement #{:b}) [:a :b :c]))
00:05sexpbot⟹ 1
00:06amalloymister_roboto1: ^^ won't work for maps, but for seqs and vectors...
00:07mister_roboto1thx, lopex and amalloy. i think i like that positions function better :)
00:21mister_roboto1&(count (take-while (complement #{:x}) [:a :b :c]))
00:21sexpbot⟹ 3
00:21amalloywell, that too :P
00:22mister_roboto1hehe
04:44bartjwhat is the best way to rename keys in a hash-map
04:44bartjinstead of doing a dissoc and then an assoc
04:45raekbartj: clojure.set/rename-keys
04:48bartjraek, cool, thanks!
05:21octe12
07:39naeuI'm trying to plot an array of floats on a graph in Incanter
07:39naeuis this a sane idea?
07:44edoloughlinCan someone tell me what's the difference between 'x' and '(val x)'?
07:45AWizzArdedoloughlin: val is a Clojure fn which is pretty much just doing this: http://download.oracle.com/javase/6/docs/api/java/util/Map.Entry.html#getValue%28%29
07:45cemerick&(val (first {:a :b}))
07:45sexpbot⟹ :b
07:46raek,(first {:a 1})
07:46clojurebot[:a 1]
07:46raek,(val (first {:a 1}))
07:46clojurebot1
07:46AWizzArdedoloughlin: raeks example returned [:a 1] which looks like a Vector. But this is not a vector.
07:47AWizzArdClojure just prints it visually in the same way. But those examples above return a MapEntry object.
07:47raek,(class (conj (first {:a 1}) :x))
07:47cemerickAWizzArd: of course it's a vector
07:47clojurebotclojure.lang.PersistentVector
07:47raeka special kind of vector that only has two slots
07:47raekbut you get an ordinary vector if you "change" it
07:48raeknaeu: I don't see why not. (seq some-vector) gives you an ordinary clojure sequence of values
07:49raekchances are that you don't even have to call seq
07:49edoloughlinThanks all. Saw it in some sample code and was just confused by it in context.
07:50raekthe most common way of getting a map entry is when viewing a map as a sequence, I think
07:50AWizzArd,(class (first {:a 1}))
07:50clojurebotclojure.lang.MapEntry
07:50raekfind can also be used
07:50naeuraek: it doesn't work if i don't call seq, and now i have it seems to be churning all the cpu ;-) I got it to work by just taking enough vals to see the patterns I was looking for though
07:50cemerick&(vector? (first {:a 1}))
07:50sexpbot⟹ true
07:50raek,(find {:a nil} :a)
07:50clojurebot[:a nil]
07:50raek,(find {:a nil} :b)
07:50clojurebotnil
07:50AWizzArd,(instance? clojure.lang.PersistentVector (first {:a 1}))
07:50cemerick&(-> {:a 1} class supers)
07:50clojurebotfalse
07:50sexpbot⟹ #{java.io.Serializable java.lang.Object java.util.concurrent.Callable clojure.lang.AFn clojure.lang.APersistentMap clojure.lang.Seqable clojure.lang.MapEquivalence clojure.lang.IObj java.util.Map clojure.lang.IPersistentMap java.lang.Runnable clojure.lang.ILookup clo... http://gist.github.com/748347
07:51cemerickwhoops
07:51cemerick&(-> {:a 1} first class supers)
07:51sexpbot⟹ #{java.util.RandomAccess java.util.Map$Entry java.io.Serializable java.lang.Object java.util.concurrent.Callable clojure.lang.AFn clojure.lang.IMapEntry java.util.Collection clojure.lang.Seqable clojure.lang.IPersistentStack clojure.lang.Sequential clojure.lang.APers... http://gist.github.com/748348
07:52raeknaeu: is it a very large array?
07:52naeuraek: jup :-)
07:52naeuraek: it plotted eventually though
07:53raekyou could always do something like (take 100 the-array)
07:54naeuraek: that's what i ended up doing :-)
07:54naeuraek: I now have a beautiful plot of a saw-wave
07:57AWizzArdSo, a MapEntry is not a PersistentVector.
07:57AWizzArdI could have been more precise.
07:58AWizzArdFor me: Vector = clojure.lang.PersistentVector.
07:58cemerickAWizzArd: Shouldn't be. There are lots of IPersistentVector impls.
07:59raekheh, I guess my idea was: x is a vector <=> (vector? x)
07:59raeki.e. instance of IPersistentVector
07:59AWizzArdOkay, this makes more sense, I agree.
08:17raekwhat is your favorite way of representing a closed set of "typed" values that can contain different number of sub-values depending on the type?
08:17raeksomething like haskell's 'data'
08:17raek[:unary value-a] [:binary value-a value-b]?
08:18raek{:type :unary, :a value-a} {:type :binary, :a value-a, :b value-b}?
08:18raek[:unary [value-a]] [:binary [value-a value-b]]?
08:27Licensermorning
08:28chouserraek: ^{:type ::unary} [value-a], ^{:type ::binary} [value-a value-b] ?
08:28raeka good option
08:28chouserraek: (defrecord Unary [a]) (defrecord Binary [a b])
08:29raekeven better
08:30raekthat avoids the problem of not being able to put metadata on e.g. numbers
08:30chouseryes, but is a wrapper in that case, as is the metadata-on-vector
08:33raekanother question: do protocol method implementations that are introduced with exend become real java methods?
08:35chouserno
08:36raekI guess what I am wondering is: should I care about whether I put the methods in a extend or in the defrecords?
08:36chouserraek: http://kotka.de/blog/2010/08/Static_vs_Dynamic.html
08:37raek*reading*
08:41raekchouser: thanks for the input. it feels so obvious now... :)
08:42chouser:-)
10:39AWizzArdI have a namespace N1 in which I define a macro A and a macro B which expands into A. Now I am in namespace N2 and required N1. I call n1/B in my N2 file and get an error "Can't refer to qualified var that doesn't exist". In the expansion A shows up not being qualified as n1/A, but simply as A. Is there an idomatic way to solve this?
10:41chousercan you paste the macro, example usage, and expansion?
10:41chouseror at least the macro
10:41opqdonutyeah, that sounds like your definition is off
10:41dsopis there a better way than doing (if-let [f body] f (something else)) so a shortcut (my-if body (something-else)) ?
10:41opqdonutdsop: (or (body) (something-else))
10:42dsopah yeah, for sure
10:42dsopthanks
10:45charliekiloAWizzArd: Wonder if I has to do with ` vs. ' ... as far as I remember, ` expands to fully qualified var, while ' does not ... but thats my guess and chouser is a lot more qualified to answer that one.
10:46chousercharliekilo: you're likely right, but ' instead of ` is a rookie mistake and since AWizzArd is asking, I'm wondering if it's something more subtle
10:48AWizzArdIt was something else. It was the reset *warn-on-reflection* thing we talked about the other day.
10:48chouserAWizzArd: you solved it?
10:49AWizzArdEmacs was hiding the namespaces for me, so at a first glance I thought it was about NS qualification. But now I macroexpand-1'ed it and saw that the *old-wor* was not properly introduced. So yes, solved.
11:01AWizzArd(do (def wor# *warn-on-reflection*) (set! *warn-on-reflection* false) (defrecord ...) (set! *warn-on-reflection* wor#) (ns-unmap *ns* 'wor#))
11:24AWizzArdMaybe it is possible to type-hint this warning about .contains away. Though currently I don't see where the implementation is coming from. In core_deftype.clj I find no .contains call.
11:30jcromartieleiningen has some problems for me on cygwin
11:30jcromartieI'm running 1.4.0 and doing a self-install right now
11:30jcromartiebut this is what I get: https://gist.github.com/5622148f4ca0c0b2e36f
11:34jcromartiehmmm
11:34jcromartiepart of what lein tries to run ... -Dleiningen.original.pwd=C:\Documents and Settings\ ...
11:34jcromartieunquoted
11:36jcromartieah, looks to be fixed in https://github.com/technomancy/leiningen/blob/master/bin/lein
11:47raekI'm writing a function called 'available?' that checks whether a sequence is at least 'n' elements long (without forcing more than n elements). have I overlooked something like this in core?
11:49fliebelraek: (= 3 (count (take 3 seq)))
11:49AWizzArd(def available? #(= %2 (count (take %2 %1))))
11:50Clintegerwhat editor do you guys use for clojure? :<
11:50fliebelBut I don't know anything in core, which is what you asked.
11:50raekfliebel: AWizzArd: thanks
11:50fliebel(also, yay, I wasn't to slow this time)
11:51raekClinteger: emacs
11:51fliebelClinteger: vim
11:51raekI was about to implement it with a manual loop
11:51Clintegerfliebel do you have rainbow parens? D:
11:51AWizzArdraek: that would be probably most efficient.
11:51raekbut piggybacking on take seems more simple
11:51fliebelyes
11:52AWizzArdraek: if you need a highspeed available? then loop is good.
11:52raekwell, the manual loop isn't exactly hard to read
11:52raeka cond with zero? pos? and neg?...
11:52raekit will be called a lot (I'm making a class file parser)
11:53fliebelAWizzArd: Why is the loop faster, and is this still the case with 1.3?
11:55AWizzArdfliebel: take constructs a new seq and thus more garbage. A loop would not need to collect the elments, just count.
12:01AWizzArdI just compared those: (time (available? x 999888)) => "Elapsed time: 222.466157 msecs" for the count+take version vs. (time (foo x 999888)) ==> "Elapsed time: 44.764726 msecs" for the loop
12:01ohpauleezjust about all the people you dunk on while playing rec basketball
12:26amalloyClinteger: having a problem with rainbow parens or something?
12:31Clintegeramalloy it seems kinda buggy, i think thats all lol
12:33amalloyClinteger: well, you'll never get it figured out if "buggy" is the best you can do. and the source is simple enough; i changed the colors to fit my color scheme, and made it work on []{} as well as just ()
12:33Clintegeramalloy no it just doesn't seem to always work o.O
12:33Clintegerbut when it does its fine
13:16fliebelWhat would be the functional equivalent of an ORM?
13:19ohpauleezfliebel: ClojureQL
13:20ohpauleezfliebel: You typically only use relational functions, and call representations of data
13:20ohpauleezrelational algebra functions*
13:21ohpauleezbut I don't know of any special name, since mapping data is always happening (I tend to use vectors and hashmaps to represent most things)
14:14amalloyi'm having some trouble with (i think) nested backticks. my goal is to take some code from the user, insert a defmacro in front of it that they can use in that context, and then eval it. https://gist.github.com/3738c7ddac879aa790b1 is a simplified version of what i'm trying to do
14:17amalloythis may not be the best way to accomplish my goal, but i don't understand how (macroexpand '(blah)) can expand to (+ 5 10), and (blah) in the same context result in an error
14:18chouserthe auto-gensym is probably causing problems
14:18chouserthey're only the same when used within the exact same back-tick
14:19Rayneschouser: Ooh. That's bit me in the ass with fury before.
14:20amalloychouser: but they are, right? both use-foo are within the outer `, and not the inner one. are you talking about foo# instead?
14:20chouseryou have foo# and x# in the outer one, and then again in the inner one
14:20Rayneschouser: Oh, by the way. Is there any particular reason that you opted for using a finite state machine to demonstrate mutual recursion rather than the classic odd? even? example? In JoC, of course.
14:21chouserRaynes: I think you'd have to ask fogus on that one
14:21amalloychouser: right. but i'm unquoting them to try and make them resolve properly, and it /seems/ to be working, since my first example with the macroexpand resolves them right
14:21chouseramalloy: hm...
14:22chouseramalloy: fascinating. you appear to be correct on that.
14:23amalloychouser: i try to only provide you with interesting problems :)
14:23ohpauleezRaynes: Did you want me to push the new clj-github to clojars on my account, or did you want to push to yours
14:23chouseramalloy: :-)
14:23Raynesohpauleez: Oh! I totally forgot to push the new version. Sorry. I'll do that immediately.
14:24ohpauleezawesome, thanks man, I'm using it in a new project now
14:24ohpauleezping me when it's up there :)
14:24RaynesSure thing.
14:24chouseramalloy: your second example just has an extra (eval ` ) that you don't need
14:26amalloychouser: i need use-foo to have a gensymmed name
14:26chouserdoesn't it/
14:26chouser?
14:27amalloynot if i take out the outer ` :P
14:28Raynesohpauleez: Pushed.
14:28amalloyie, i can't change it to (let [foo 10] (defmacro use-foo))
14:28ohpauleezRaynes: You're the man now dog
14:28ohpauleezthanks!
14:29chouserah
14:29chouserright-o
14:30ohpauleezDoes anyone know the process stu uses for signing off on tickets?
14:30ohpauleezbesides the process seen at /patches
14:30chouseramalloy: note that foo# gets its unique name generated at read time, so if you do this in a function or macro and call it from multiple places, they'll all use the same name for use-foo
14:31amalloychouser: aw man, really?
14:31amalloyin that case you're right - the eval ` is meaningless
14:32chouserjust use a manual gensym in your function instead
14:33amalloychouser: so like...(let [name (gensym)] (eval `(defmacro ~name))), right?
14:33chouseryes
14:35amalloychouser: interestingly, this seems to have fixed the problem
14:35Raynesamalloy: You're defining macros in macros?
14:36chouserhm
14:37amalloychouser: gist updated (for convenience: https://gist.github.com/3738c7ddac879aa790b1)
14:37chouserthe exception you were getting suggests an attempt to call a macro as a function
14:39amalloyhm
14:39chouserthe problem was the let, fixed by changing it to a do
14:39chousera let is compiled as a single top-level form
14:39amalloychouser: buh?
14:40chouserso use-foo# was not yet a var when (use-foo# 5) was compiled
14:40chouserso it was compiled as a function call
14:40chouserhm. I think.
14:40chouserand then fun as a function call, causing the error.
14:40chousers/fun/run/
14:40sexpbot<chouser> and then run as a runction call, causing the error.
14:40Rayneschouser: Do you buy that braininess at some store? I'd like to see about purchasing some for myself.
14:41chousera runction call. exactly.
14:41amalloylol
14:41pdkwe're takin lessons from scooby doo here
14:41chouseranyway, 'do' is special-cased in the compiler
14:41chousereach form in a do is compiled and run in turn, as if each were a separate top-level form
14:42chouserso that by the time (~fname 5) is compiled, Clojure knows it's a macro call
14:42chouser(let [] (defmacro foo []) (foo)) ; same error
14:42amalloycrazy
14:42amalloychouser: ooc is that the case even when the do/let aren't at the top level?
14:43chouserno
14:49RaynesLet's all give amalloy a round of applause for making a very strong-willed attempt to fix ##(for [x ["a" "b" "c"]] (.length x)) :>
14:49sexpbotjava.lang.IllegalStateException: Var clojail.core/tester is unbound.
14:49RaynesI'm rooting for you, my friend.
14:50Raynesamalloy has ambitions to create his very own organization dedicated to fixing my bugs and cleaning my messes up.
14:51amalloylol
15:22fogus`Raynes: Because the even? odd? example is uninspiring. :-)
15:48clizzin_i have a situation where i'd like a function foo to return a lazy seq over the lines of a file, which another function will then read from. the problem is that it seems the reader is being closed after foo exist. i'm using with-open within foo to open the file and create the lazy seq over the lines. how can i achieve the behaviour i'm looking for?
15:52amalloyclizzin_: do you care about retaining laziness?
15:52mduerksenclizzin: with-open ensures that the file is closed properly after its body is evaluated. you would have to process the files contents inside the with-open, or you can't use with-open, but then you will have to take care of the "cleaning" yourself
15:53alpheusOr open/close on successive accesses.
15:54clizzin_amalloy: yes
15:54amalloythen mduerksen and alpheus have the answers for you: either manage the file yourself, or put the with-open in a context that includes both the reading and the processing
15:55clizzin_mduerksen: i see. is there a standard solution to this, or is it just wrapping it in a try with a finally to close the reader?
15:56clizzin_alpheus: i thought that if i close a reader and then reopen it, it would read from the beginning again. is that not the case?
15:56amalloyclizzin_: fyi, your foo function already exists: ##(doc line-seq)
15:56sexpbot⟹ "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
15:58clizzin_amalloy: yeah, i actually wanted to do some additional processing on the lines into a custom record format as they were read from the file, hence my use of "foo." but you're right, the behaviour is just like line-seq.
15:59alpheusclizzin: yes, you'd have to manage your own state with regard to previously read offset etc. I can't give you specifics because I don't know clojure well enought.
15:59amalloyclizzin_: the solution that "feels" most natural to me is to modify foo to accept a continuation function argument: (defn foo [file process] (with-open [stream file] (process (line-seq stream))))
16:00amalloythat way you're still within the dynamic scope of foo, so the file is still open
16:00clizzin_amalloy: that actually makes the most sense. nice one. thank you!
16:00amalloybut that may be a clojure monstrosity, a hold-over from my C days. i'm not sure
16:01clizzin_thank you also, alpheus and mduerksen
16:02clizzin_amalloy: well, i'll write it, and we'll see if it results in something monstrous...
16:03amalloyclizzin_: you'll have to realize the sequence at some point, so you'll need to make sure that all happens within the with-open's dynamic scope
16:03amalloyotherwise you're just delaying the problem
16:18alpheusDidn't the need for laziness disappear with the continuation function argument solution?
16:19clizzin_alpheus: no, because the process function is still consuming the sequence lazily.
16:21alpheusI don't see how. How much of the stream does "process" consume when invoked?
16:23amalloyalpheus: if it consumes the sequence lazily, none
16:24amalloyfor example, (defn process [lines] (map #(str "line: " %) lines))
16:26amalloywould be no good: it returns a lazy seq, and when you force the first element, you find that lines can't be read because the file is closed
16:26alpheusI was just about to type that.
16:27brehaut(inc lpetit)
16:27sexpbot⟹ 1
16:28jcromartieI like the bit in the try block, it's like a mini-dsl for only this function https://gist.github.com/e79f096508ef51b20459
16:29lpetithello. Maybe I'll look like a moron, but what does (inc lpetit) mean, really ? :)
16:29brehautlpetit: sexpbot's karma tracker
16:30jcromartie(repeatedly #(inc jcromartie))
16:30jcromartie:(
16:30brehaut(inc jcromartie)
16:30sexpbot⟹ 1
16:30brehautjcromartie: thats inspite of me nearly sneezing coffee over my new computer
16:30lpetitbrehaut: than
16:30lpetitarhg
16:30jcromartieI want a reader macro for a special kind of left and right paren that are :( and :) respectively.
16:31lpetitbrehaut: my karma's thanking you. What did I do to deserve it ?
16:31jcromartiesexpricons
16:31brehautlpetit: for services toward rational discussion on the mailing list
16:31amalloyjcromartie: oh my god what a name
16:31jcromartiesounds like a B-movie race of alien sex robots
16:32lpetitbrehaut: oh, ok. It's hard to both, at the same time, try to be adult and concise, without being just "more noise" :)
16:32brehautlpetit: yeah :(
16:32chewbran1aanyone seen this error before? "Anonymous modules have no name to be referenced by" http://pastie.org/1393291
16:32chewbran1abah
16:32chewbran1asorry wrong window
16:33amalloyjcromartie: add a v to the emoticon and they look kinda like unicorns...sexpricorns?
16:33lpetitchewbran1a: yeah, I wish clojure already had modules :)
16:33chewbran1alpetit: haha
16:34lpetitamalloy slowly leaning towards adult content ... ;)
16:35jcromartieCURSE YOU SQL SERVER TEXT TYPE!
16:36lpetitbed time in France, cu later guys
16:36brehautlpetit: later
16:41alpheusI'm going on a 53 hour train ride. I want to read some Clojure source on the way. Any recommendations?
16:44amalloyalpheus: sexpbot?
16:44Raynesamalloy: I think he wants to read some good Clojure source code.
16:44brehautalpheus: have you read enlive ?
16:44RaynesNot that sexpbot wouldn't keep him busy for 53 hours.
16:45amalloyalpheus: and sexpbot has a brand-new quick-start guide to go with the source: http://is.gd/j6an1
16:45alpheusenlive, no, but I respect it. good idea
16:46brehautalpheus: i learnt a bunch from the code. it covers a huge range of the language in a very small space
16:46brehautalpheus: im planning to dig into logos over the holidays
16:47brehautalpheus: https://github.com/swannodette/logos its a miniKanren implementation; an embeded logical language basically
16:48Raynesalpheus: With 53 hours of train ride, you should have plenty of time to traverse the code of several projects.
16:49brehautalpheus: may i also suggest ring? its got lots of bite sized pieces
16:49jcromartieis there already an indent-level macro?
16:51alpheusI like all those suggestions. I wanted to have a bunch of code loaded on my laptop before I lost net access.
16:51bobo_Raynes: has i understood try-clojure and clojail correct, al the security stuff and so on is in clojail? so if i want to make my own try-clojure i can just use clojail? nothing "important" in try-clojure?
16:52Raynesbobo_: Right. try-clojure is mostly a wrapper around clojail.
16:52bobo_awesome!
16:52Raynesbobo_: tryclojure adds a little stuff to allow def safely, however.
16:52RaynesYou looking to make your own try-clojure? :p
16:52brehautalpheus: also for mind expanding but not strictly useful, grab the monads lib in clojure.contrib and a bunch of texts from the web ;)
16:52bobo_i want 2 terminals in the same window =)
16:52bobo_so i can write test in one and code in one
16:53bobo_and i noticed you used hiccup, so... il start from scratch :-p
16:54bobo_as everything i do, il probably get boored before im done but still
16:54Raynes:p
16:54jcromartiehere is my contribution to the Clojure community, an indentation level macro that rebinds println
16:54jcromartiehttps://gist.github.com/749062
16:55jcromartiefinally, I can sleep
16:55jcromartieno, I can die
16:56amalloyjcromartie: ((fnil inc 0) *indent*) might be cleaner? i dunno
16:57jcromartieI just realized something silly
16:57jcromartiethere, updated https://gist.github.com/gists/749062/edit
16:57jcromartiethe first (with-indent ...) should start indenting
16:57jcromartienot start at zero
16:58amalloyjcromartie: that's what my little fnil friend does
16:58jcromartieright, but I just bind *indent* to 0 at the root
16:58jcromartiethat's all it needs
16:59amalloythat's true
16:59jcromartieshould work across threads too
17:12jcromartiedurr, nobody needs an edit link... https://gist.github.com/749062
17:33alpheusRaynes: you're in the "most forked this month" on github
17:34Raynesalpheus: Really? :o
17:34alpheusat least in the Clojure language category
17:35RaynesNeato.
17:35Raynesamalloy: We're in the "Most Forked This Month" category! :D
17:36amalloy!
17:36amalloylinky?
17:36brehautamalloy: https://github.com/languages/Clojure
17:36Rayneshttps://github.com/languages/clojure
17:37kotarakPeople fork *richhickey*/clojure-contrib? o.O
17:38brehautkotarak: but only this month, this week and today clojure/clojure-contrib is ahead
17:38amalloykotarak: google still turns that up first
17:38ohpauleezScala is the 17th most popular language on github, clojure... the 18th
17:39brehautls
17:40Raynesbrehaut: I've tried to join channels by using /cd
17:41brehautRaynes: hah awesome
17:48raek,(clojure-version)
17:48clojurebot"1.2.0"
17:48raek&(clojure-version)
17:48sexpbot⟹ "1.2.0"
17:52Clintegerhmph. writing clojure on windows is a pita :|
17:53kotarakClinteger: I don't notice much difference to my mac setup: everything works fine on Windows too.
17:54Clintegerkotarak what editor do you use?
17:54kotarakVim
18:07RaynesClinteger: Emacs and Vim both work fine in Windows.
18:07RaynesI mean, last time I used them on Windows.
18:07RaynesQuite a while ago.
18:07RaynesThere is always Eclipse+Counterclockwise.
18:08RaynesI hear the Intellij support is pretty good as well.
18:24ClintegerRaynes emacs forkbombs me :(
18:24RaynesClinteger: Install Ubuntu. :>
19:13zemariammHello everyone
19:29jweissshouldn't surrounding for or map with doall force the evaluation of all the items?
19:30jweisswhether they're consumed by something lower in the stack or not?
19:30qbgIt should
19:31zemariammhas anyone successfully used compojure on appengine ?
19:32ossareh'lo
19:34ossarehtechnomancy: your emacs starter kit rocks out, though the clojure function fnil falls foul of the pretty-lambdas hook. I'm unfamiliar with elisp, is there a quick fix for that?
20:02dsopis there a short way for (((foo :bar) :baz) :blub) ?
20:05qbg,(doc get-in)
20:05clojurebot"([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of ke(ys. Returns nil if the key is not present, or the not-found value if supplied."
20:06hiredman(-> foo :bar :baz :blub)
20:06dsopqbg: thx
20:10KirinDavehiredman: Call me crazy, but I like yours better.
20:10KirinDaveI am a sucker for thrush, tho.
20:11qbg-> is more general, but get-in may convey the intent better
20:18brehautdsop: if you need to pass it in to another fn, you might find (comp :blub :baz :bar) useful too
20:21dsopbrehaut: hmm interesting that I can comp those
20:21dsopI'm quite new to lisp and clojure so it's kind of hart to find the right fn everytime.
20:21brehautdsop: its the exact same trick as hiredman's -> namely that keywords implement the function interface
20:24brehautdsop: have a play with fn? and ifn? in a repl
20:24brehaut,(fn? :keyword)
20:24dsopbrehaut: i figure it's the best way to do use this, so (:foo map) is better than (map :foo) as (nil :foo) will cause an illegal argument
20:24clojurebotfalse
20:24dsopbrehaut: yeah, palying around in slime with it :)
20:24brehaut,(ifn? :keyword)
20:24clojurebottrue
20:24brehautdsop i believe the answer to that depends on the usage of the map
20:25brehautdsop: if its being used as a record, then (:key map) is prefered
20:26brehautdsop: and thats usually the case if you have keyword keys
20:28dsopyes I mainly use json-parse and therefore maps that are records
20:30brehautdsop: sure. keyword first then :)
20:31brehautdsop: at some point you should also check out the clojure.zip namespace
20:33brehautdsop: its a generic library for walking tree shaped things
20:34dsopI've seen this while I searched for what zip is in haskell
20:34brehautzip in haskell is different; it takes two lists and returns a list of pairs
20:34brehautthe clojure equivalent is map
20:34dsopexactly, I searched for that
20:34dsopbut yeah
20:56krumholthi
23:38DeranderWhat is the function that returns a function that is the result of applying both functions?
23:38brehautDerander: juxt ?
23:38Deranderyes!
23:45hiredman,(doc case)
23:45clojurebot"([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are ...
23:45amalloy&(doc case)
23:45sexpbot⟹ "Macro ([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need no... http://gist.github.com/749506
23:46amalloyoh haha, sorry hiredman, didn't notice it was you looking up case. i was just giving whoever it was a gist
23:47RaynesI just wrote a subsubsection on case.
23:47hiredman*shrug*
23:47RaynesBut that's still a secret.