#clojure logs

2011-03-28

00:01joshua__findfn \a "a"
00:01brehautchar
00:01joshua__&findfn \a "a"
00:01sexpbotjava.lang.Exception: Unable to resolve symbol: findfn in this context
00:01brehautstr
00:01joshua__brehaut, it has to work for both \a and `(\a \b \c) etc
00:01joshua__I was using (reduce str letters)
00:01brehautapply works ?
00:02joshua__.. probably.. one second testing it ;p
00:02joshua__brehaut, thank you.
00:03joshua__brehaut, I didn't know that findfn worked as well as it does o.o
00:03brehaut$findfn \a "a"
00:03sexpbot[clojure.string/trim clojure.string/lower-case clojure.core/munge clojure.core/print-str clojure.core/str clojure.core/namespace-munge clojure.contrib.string/as-str]
00:03joshua__brehaut, I meant you ;p
00:03brehautamalloy (apply (fn [s a] ((a 599) (fn [& r] ((a 599) ((a 477) r) ((a 606) r))) (((a 599) (a 681) ((a 297) (fn [length] ((a 440) (a 68) #((a 441) % length))) [20 12])) ((a 356) ((a 440) ((a 438) ((a 245) (((a 440) (a 567) (a 205)) ((a 640) ((a 706) ((a 640) ((a 465) (a 164) ((a 297) ((a 440) ((a 560) (a 599) (a 472)) ((a 560) (a 297) (a 567))) '((77 97 116 104) (112 111 119))))) 2 6)) 1))) (a 186) (a 374) (a ((a 180) 123 342 12))) s)))) (((
00:03brehaut(a 503) ((a 440) ((a 560) (a 392) {}) (partial map-indexed (fn [n [_ v]] [n v])))) (seq (ns-map (the-ns 'clojure.core)))))
00:03brehautperfected
00:05amalloyquick, someone saw brehaut's broadband connection in half. it's time for an intervention
00:05joshua__What are we trying to do?
00:05joshua__Hide false?
00:05brehautjoshua__: obfuscate false
00:06joshua__(def true false) ?
00:06brehautthe down side is i think it only works in clj 1.2.0
00:07brehauti dont think true and false are symbols, so they probably cant be rebound
00:07amalloy&(let [true 1] true)
00:07sexpbotjava.lang.Exception: Unsupported binding form: true
00:12brehautthe heart of that big old blob is ##(seq? neg?) (or similar)
00:12sexpbot⟹ false
00:21johnmn3is there a simple tutorial on how to build an accumulator function?
00:21johnmn3I keep overflowing the stack
00:21tomojamalloy: filthy habit?
00:22amalloytomoj: poorly stated, sorry. i meant: if you do that you'll often be confused
00:22tomojah, yes
00:22tomojit was just so nice to find an explanation for the abomination
00:23amalloy&((fn ! [n acc] (if (zero? n) acc (recur (dec n) (* acc n)))) 5 1)
00:23sexpbot⟹ 120
00:23johnmn3Basically, I want to un-interleave a collection, like: [0 1 0 1 1 0 0 1] -> [[0 0 1 0] [1 1 0 1]]
00:24amalloyjohnmn3: ^ is obviously not a tutorial, but maybe helpful. look at it, let me know what parts didn't "stick", maybe?
00:24johnmn3ok
00:24tomojhow do you get from "un-interleave" to "accumulator function"?
00:24johnmn3I was calling the defining function
00:25amalloytomoj: when i was learning CL, i thought tail-recursion was the only way to do anything interesting; he's probably similar
00:25brehautamalloy: and then you learnt about the point free trifecta?
00:25amalloybrehaut: comp, partial, and...apply?
00:26brehautjuxt!
00:26amalloydamn. second guess
00:26amalloyjuxt is just a special case of map
00:26brehaut(juxt (partial take-nth 2) (comp (partial take-nth 2) (partial drop 1)))
00:26brehautmaps just a special case of reduce but its still useful to call it map :P
00:26tomojreduce?
00:27amalloytomoj: sure
00:27tomojI could maybe imagine definining maps in terms of reductions
00:27tomoj.. map
00:27brehautmap the function, not map the structure sorry
00:27tomojindeed
00:28amalloytomoj: clojure's reduce isn't lazy so it's harder, but i imagine in haskell it's not hard to define map in terms of reduce
00:28pdkand then you'd have...
00:29pdka mapreduce
00:29tomojah, that was my confusion
00:29tomojba dum ching
00:29brehautyeah it helps to have left and right folds as well as lazy and strict ones
00:30johnmn3you hung my repl :|
00:31amalloyjohnmn3: i did?
00:31johnmn3just kidding :) I just did it wrong or something
00:31amalloy*chuckle*
00:31brehauttomoj: assuming a appropriate folds in place of reduce: ##((fn [f s] (reduce (fn [l v] (conj l (f v))) [] s)) inc [1 2 3])
00:31sexpbot⟹ [2 3 4]
00:32johnmn3(defn unzip [asq acum bcum]
00:32johnmn3(if (nil? asq) [acum bcum] (recur (rest (rest asq)) (conj acum x) (conj bcum y)))))
00:32johnmn3shouldn't that reach a nil?
00:32amalloyno
00:33amalloyrest is lazy, and an empty seq isn't false
00:33amalloy&((juxt rest next) [1])
00:33sexpbot⟹ [() nil]
00:33brehauttomoj: of course in haskell its probably not implemented in terms of a fold because its heavily optimized and the rewrite rules perform a lot of fusion on folds and maps
00:34johnmn3an empty seq doesn't return nil?
00:34amalloyjohnmn3: see abone
00:34amalloyabove
00:35johnmn3what does juxt do again?
00:35amalloy(next [1]) is nil because it's (seq (rest [1])), but (rest [1]) is a lazy seq that's not sure if it's empty yet
00:35tomojthe funny thing to me is that rest appears to be implemented using next
00:35tomoj
00:35amalloytomoj: i think it uses RT.next?
00:36amalloy$source rest
00:36sexpbotrest is http://is.gd/kSLdsP
00:36johnmn3so I just need to add a seq
00:36tomojyeah, not next the function
00:36tomojevery time I see "rest" I think "that should be 'next'"
00:36amalloyjohnmn3: or just use next to begine with
00:37tomojI imagine that there is some reason for rest to still be around but I have never found one
00:37amalloytomoj: there are like a hundred. i rarely use next
00:37tomojoh, laziness stuff?
00:38amalloyyes
00:39johnmn3man 1, computer 0
00:39johnmn3thats a lie
00:44tomojbut if rest is implemented with next, how can it be more lazy?
00:44johnmn3https://gist.github.com/890019
00:44tomojI guess the piece of next that it uses is lazy and next does something extra
00:45johnmn3maybe the bot should post summaries of gists that are posted
00:46amalloyjohnmn3: i'd try to implement it with keep-indexed
00:47amalloy&(keep-indexed (fn [idx val] (when (even? idx) val))) [0 1 0 1 0 1])
00:47sexpbotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep-indexed
00:48amalloy&(keep-indexed (fn [idx val] (when (even? idx) val)) [0 1 0 1 0 1])
00:48sexpbot⟹ (0 0 0)
00:48amalloydo that for even? and odd? and you're all set
00:48tomojwhy that over take-nth?
00:48amalloytomoj: no particular reason
00:48amalloyi guess take-nth is better
00:48amalloybut now he's learned about *two* useful functions :)
00:49johnmn3so take-nth on the even and odd ranges?
00:49brehaut,(take-nth 2 [1 2 3 4 5 6])
00:49clojurebot(1 3 5)
00:49brehaut,(take-nth 2 (rest [1 2 3 4 5 6]))
00:49johnmn3oh, I was thinking of nth
00:49clojurebot(2 4 6)
00:50dr0idhmm
00:52johnmn3(defn uninterleave [asq]
00:52johnmn3 [(take-nth 2 asq) (take-nth 2 (rest asq))])
00:52johnmn3better
00:53amalloy(map (partial take-nth 2) ((juxt identity rest) asq))?
00:53amalloyas sorta an alternative way of looking at it
00:56johnmn3oh I see
00:56johnmn3so juxt will let you create two colls out of one, among other things
00:56amalloyjohnmn3: it calls two functions on the same arms
00:56amalloyargs
00:57amalloy&((juxt inc dec) 1)
00:57sexpbot⟹ [2 0]
00:57johnmn3or more
00:57amalloysure
00:57johnmn3&((juxt inc dec inc) 1)
00:57sexpbot⟹ [2 0 2]
00:57johnmn3neat beats
01:01amalloyi especially love (juxt identity blah blah blah). get some information about the object, attached to the original object
01:12mecIf I remove a function from a namespace after having run (use 'my-ns) how do I remove the binding?
01:13mecFrom the repl namespace, without having to restart it*
01:14no_mindcan I find logs for yesterday's discussion ? Someone replied to my question and at the same time my client crashed. I could not see the answer
01:15amalloylogs?
01:15clojurebotlogs is http://clojure-log.n01se.net/
01:17amalloymec: ns-unmap
01:17amalloyor just (def myfn 0)
01:18mecThat gives an IllegalStateException, fn already refers to my-ns/fn in namespace: user
01:18mecbut ns-unmap works, i was just using it wrong :D Thanks
01:19amalloymec: yeah, that def probably has a lot of cases it won't work inn, now that i think about it
01:55mec##(findfn '+ +)
01:55sexpbotjava.lang.Exception: Unable to resolve symbol: findfn in this context
01:55mec##(find-fn '+ +)
01:55sexpbotjava.lang.Exception: Unable to resolve symbol: find-fn in this context
01:55amalloymec: it's $findfn, but it won't find you resolve, i suspect
01:55amalloy$findfn '+ +
01:55sexpbot[clojure.core/time clojure.core/dosync clojure.core/with-loading-context clojure.core/doto]
01:56mecweird
01:56amalloymec: resolve is unsafe in an eval context so sexpbot doesn't allow it
01:56mecah i see
01:56amalloyeg, ((resolve 'eval) '(hack the computer))
01:57amalloy$findfn '+ #'+
01:57sexpbot[clojure.core/defn- clojure.core/defn clojure.core/defmacro clojure.core/declare clojure.core/defmulti]
01:57amalloyhaha defmulti. nice one sexpbot
02:04mecI think I broke clojure, (+ 1 2) is giving me a NPE
02:07tomojhaha
02:08amalloymec: (resolve '+) yields...?
02:09mecwas still giving clojure.core/+
02:09mecbut I've already killed and restarted the repl
02:09meci think it was from using findfn
02:10amalloymec: you used findfn locally?
02:10amalloynice
02:10mecya its really handy, use it all the time
04:21thorwilis there a convention regarding * at the end of function names?
04:25raekthorwil: sometimes it is used when you have a function and a macro that makes it "prettier"
04:27raekthorwil: like with bound-fn: (bound-fn [x] (foo x)) expands to (bound-fn* (fn [x] (foo x)))
04:27raekthere are other conventions as well, e.g. future and future-call
04:30raekfrom http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards : "Don't use a macro when a function can do the job. If a macro is important for ease-of-use, expose the function version as well. (Open question: should there be a naming convention here? A lot of places use "foo" and "foo*".)"
04:30no_mindin enlive we have a function for set-attr which takes an attribute and its value. How can I specify the attribute dynamically ? Using keyword function is throwing error
04:57no_mindwhat is the significance of % ?
04:58ejacksonits the value of the first argument passed to anonymous function created with #( ... )
04:58ejackson,(map #(+ % 2) [1 2 3 4 5 6])
04:58clojurebot(3 4 5 6 7 8)
05:01no_mindk
05:01thorwilno_mind: you mean in something like (en/set-attr :value title) switching out :value? i guess a function symbol in that place won't be evaluated (?)
05:03no_mindthorwil, I tried this (en/set-attr (keyword k) v) and I get this runtime error clojure.lang.Keyword cannot be cast to java.util.Map$Entry
05:09thorwilno_mind: looks like you can do (en/set-attr (foo) title)
05:10thorwiland then (defn foo [] :value) with a body that makes sense
05:15ephconis there an equivalent of (member ) in clojure?
05:23no_mindthorwil, no I do not want to hard code :value or :id , I want these to be passed as arguments
05:23no_mindthorwil, I tried this (html/set-attr #([] (keyword (get value (first (keys value))))) (get value (first (keys value)))) but I get eh same runtime exception
05:26thorwilno_mind: where/how do you decide which keyword to use?
05:27thorwilno_mind: btw you misread what i said
05:29no_mindthorwil, from a db and the "value" used above is a map with one key something like {:id "hello"}
05:33thorwilno_mind: either bind your key and value in a let, or use functions. putting all that stuff into set-attr from is only confusing
05:35thorwilno_mind: if your db query delivers a map, shouldn't it just be (:id query-result) to get at your "hello"?
05:35no_mindthorwil, any example of using let ? Say I pass a map {:id "map"} and want to set the id attribute to "map"
05:36no_mindthorwil, I am not aware of the db query part. I am calling a function which returns me a map. That function is written by third party
05:39thorwilno_mind: (let [value (:id your-map)] ...code-goes-here...)
05:39no_mindk
05:40no_mindthorwil, but what is the cause of the runtime exception ? from what I understand, set-attr takes a keyword as first arg
05:42thorwilno_mind: it does. but do you know what (keyword (get value (first (keys value))))) delivers? to me, it just looks wrong
05:42no_mindthorwil, it delivers clojure.lang.keyword
05:43thorwilno_mind: i'm pretty sure it's much more convoluted than it has to be
05:44thorwilno_mind: how about you paste your stuff https://gist.github.com/
05:44no_mindthorwil, ok, I will post the version where I am sending a hardcoded map
05:46no_mindthorwil, I have pasted it here http://pastebin.com/uGqRK91t (with hardcoded map that is similar to the result I am receiving)
05:56thorwilno_mind: what is [[:input]] supposed to do? (why double []?)
05:57no_mindthorwil, that is how I have always specified the elements. Saw it in one of the examples. It works fine else here
05:57no_mindwhere*
05:59thorwilbad or misunderstood example, then. single like with [:div#content] works
06:01thorwilno_mind: hows input-element defined
06:01no_mindthorwil, it returns a string with html input element.
06:02no_mindthorwil, the code works fine if I use hard-coded attribute i.e (en/set-attr :id "h") works and generates the required element
06:03thorwilno_mind: what's the [value] after [[:input]]?
06:03thorwilugh, real life calling, be back in half an hour
06:03no_mindk
06:03no_mindthorwil, ping me when you are back
06:28thorwilping no_mind
06:29no_mindthorwil, pong
06:38no_mindthorwil, any success ?
06:39thorwilno_mind: i still wonder about [[:input]] [value]
06:40no_mindhmm these are standard parts of defsnippet definition
06:43thorwild'oh, just the formatting had thrown me off
07:21thorwilno_mind: try http://pastebin.com/MvBjZHLk
07:22thorwilis there a way to destructure {:id "value"}, where :id could be any other key? that is, just match {key value}?
07:23Chousukehm
07:24Chousuke,(let [[k v] (seq {:key 'val})] [k v])
07:24clojurebot[[:key val] nil]
07:24Chousukeoh, I guess you need another pair of brackets
07:25Chousuke,(let [[& [k v]] (seq {:key 'val})] [k v])
07:25clojurebot[[:key val] nil]
07:25Chousuke,(let [[[k v]] (seq {:key 'val})] [k v])
07:25clojurebot[:key val]
07:25Chousukethere we go
07:25Chousukekinda tricky
07:25thorwilthanks. maybe i will even understand it in a few minutes :)
07:26Chousukepossibly the (seq ...) is unnecessary
07:26Chousukethorwil: well
07:26Chousuke,(seq {:key 'val})
07:26clojurebot([:key val])
07:26Chousukeyou're not destructuring the map, you're destructuring the seq it becomes
07:27Chousukeand the destructuring form is [[key val]] which matches the structure of the seq
07:28thorwilic
07:30thorwilthat can't be translated to work in an fn signature, i guess?
07:33solar_seaHi. I'm trying to learn clojure and I'm getting a behavior I'm unable to explain. http://pastebin.com/DQiSzNsH
07:34solar_seaWhy am I getting "true" for the last expression?
07:36hoecksolar_sea: because the second a in "0abc" matches your regex
07:37hoeckI mean the second character, not the second a
07:38solar_seashame on me, I see
07:38thorwilno_mind:or http://pastebin.com/biY3Gshg
09:40chouserSo much of my code is just wrapping objects in other objects.
09:41chouserI live inside the expression problem.
09:41dnolenchouser: wrapping Java objects in Clojure types/records?
09:42kephale00you might want to bring it up to the emacs analyst ; )
09:42chousersure that, among others. At least I can use reify for those cases, making Java objects look like Clojure maps/vectors
09:42chouserAlso, wrapping Clojure reference types in subclasses of (usually concrete) Java types, which requires gen-class or proxy
09:43Rayneshttp://stackoverflow.com/questions/5457066/use-of-clojure-macros-for-dsls/5457754#5457754 Yikes.
09:46dnolenchouser: I've been impressed by the perf of the JVM in the presence of wrapping.
09:48chouserdnolen: wait come back, I have more inane prattle to spew on this topic!
09:48chouserOh well, I guess I'll have to invest my prattle elsewhere.
09:57gfrlogI was just forced to use a ModelFactory to create a ModelMaker that I could use to create a model
09:58meckill it with fire
09:59jolyNuke it from orbit; it's the only way to be sure.
09:59chousergfrlog: I know, right? But it's like 6 lines of Clojure. So much less pain than Java.
10:00chousergfrlog: or were you doing it in Java?
10:00gfrlogchouser: yeah, I think I did it in three (clojure)
10:00gfrlogchouser: at least I didn't have to type out the type of each dang object
10:00chouseryep
10:01gfrlogI have to think that the only reason it wasn't called a ModelFactoryFactory was to preserve dignity
10:01chouserI've got two of these right here. Set a static field to be an instance of a Factory that has a method that returns an instance of a thing that provides a method with my custom behavior.
10:02RaynesHehe, that fellow called me a "little coward" for downvoting his answer.
10:02chousergfrlog: heh
10:02gfrlogchouser: so it wants you to pass in a function, eh?
10:02chouserRaynes: well, I disagree with his conculsions about macros, but I find appealing to "consensus" to be rather unappealing.
10:03gfrlogchouser: good pun.
10:04chousergfrlog: Is it any wonder high-order functions are hard for Java programmers to grasp at first? These giant stacks of classes and instances, and we're just slinging them around all over the place.
10:04Rayneschouser: What do you mean? nickik and friends managed to point out some of the reasons pretty nicely. I didn't think I should reiterate.
10:04pdki was picturing more
10:04pdk"but i thought we still had to make wrapper classes with 1 function in them and pass those"
10:05pdki hated that shit when i started off learning swing
10:05pdkcause it was ton of boilerplate just for every litttle button event handler
10:05RaynesAnd I was under the impression that what the community advocated was generally the direction one should go.
10:05pdkwhat's this post, i havent been around
10:05pdki think learning to use swing was where i started going way back when
10:05pdk"why can't i give it the name of the function directly?"
10:06gfrlogchouser: it's okay, Eclipse tells you if you did it right :)
10:06gfrlogyou just keep pressing auto-complete key-combinations until you get the first syntactically correct expression.
10:06Raynespdk: http://stackoverflow.com/questions/5457066/use-of-clojure-macros-for-dsls/5457754#5457754 Specifically, the comments related to this post in nickik's answer.
10:07pdki thought people were saying to use macros on an as-needed basis
10:07pdkis that basically the crux of the debate
10:07chouserRaynes: I agree some good reasons were pointed out. Once I saw that cgrand's talk onthe subject had been linked, I didn't think I had anything else to cntribute to the conversation.
10:08Rayneschouser: I was mostly pointing that out because, inevitably, new people will end up reading that, and that's how you end up with confused programmers.
10:08RaynesNot that it matters, as this guy is determined to get the last word in.
10:08chouserpdk: I think the disagreement is over whether, in a situation where either a macro or a function would suffice at the moment, if you default to using a macro are you more likely later be happy or sad about it.
10:09chouserIn my experience, I'm more likely to be sad.
10:09chouserThen again I'm apparently now a LISPer that knows the cost of nothing.
10:12RaynesI'm fairly certain, now, that this guy is a troll. Alas, everybody should have probably ignored him. He was actually getting upvotes though, which scared me, so I acted quickly.
10:14RaynesThis sort of thing annoys me in general though. People who ignore common community-accepted conventions just for the hell of it. That Miki fellow who wrote fs is strongly in favor of single-segment namespaces. When my persuasion could do no good, I created a joke version of his project with a comical README and those things that seemed wrong fixed. I'm happy to report that he found it funny as well though.
10:19pdki recall reading a couple months ago this long giant article
10:19pdkthe short of it was just it was your typcial fighting over lisp indentation and the author thought he was dropping a bombshell going "guys... why don't we use block indendation and put )'s each on their own line?!"
10:19RaynesI remember that.
10:20RaynesThat irked me.
10:20pdkhell now i wanna find it again
10:20gfrlogwe hate him
10:20pdkdid he write any other "choice" stuff like that
10:20chouserSomeone is wrong on the internet. But we're working on it, making progress, and soon people will only be right.
10:20mecwe could always switch to using m-expressions as god intended :D
10:21Rayneshttp://gregslepak.posterous.com/on-lisps-readability
10:23RaynesLooks like he got rid of the comments after-the-fact.
10:23mecThats not any more readable, the extra ) dont help you line up. What he really wants is an editor that shows indent lines
10:23semperossay I have a running Jetty instance (using ring.adapter.jetty); how can I write a function which sends a request to my server app running on Jetty, gets a response, and then causes the server to shutdown after the response has been sent?
10:24RaynesWhen I start seeing that post referenced by people on his side of the argument, I vow to jump off my roof into a glass of water.
10:26semperosto be more precise, how do I write a server-side function that will return a response and then shut down the server
10:27semperosa somewhat hackish solution seems to spawn a new thread, wait X seconds and then call (.stop)
10:27semperosbut I was wondering if folks could think of something more robust
10:38Fossilet is defined as let*. where's that defined?
10:39devn_M-. ;)
10:41Fossiwon't tell me
10:41Fossi:/
10:41Fossineither did repl-utils
10:44gfrlogFossi: some grepping turns up src/jvm/clojure/lang/Compiler.java
10:45gfrlogFossi: so it's probably bootstrapped in Java
10:45NetfeedRaynes: i think that his way is more readable right now, but i started with clojure yesterday so that thought might change quiet fast :)
10:45Fossiah
10:47gfrlogFossi: let is a 'special form', which I believe means it's more fundamental than a fn or macro
10:47pdkspecial forms are the builtins that come hardcoded into the implementation
10:47gfrlog,#'let
10:47clojurebot#'clojure.core/let
10:48gfrlog'let
10:48gfrlog,let
10:48clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/let
10:48gfrlogeh what do I know
10:48Fossithe real question was whether let binds a var
10:48gfrlogFossi: I doubt it
10:48Fossiie whether you can pass the result with #'something
10:49gfrlogI'm not sure why let would have to be a special form actually. Maybe for performance. I think you could write a let macro that translates everything to fns
10:49gfrlog(let [x 12] (+ x (* x x))) => ((fn [x] (+ x (* x x))) 12)
10:53gfrlog,((fn [x] #'x) "foo")
10:53clojurebotjava.lang.Exception: Unable to resolve var: x in this context
10:53gfrlog,(let [x "foo"] #'x)
10:53clojurebotjava.lang.Exception: Unable to resolve var: x in this context
10:54malbertifegfrlog: sure you could, see sicp chapter 1
10:54malbertifegfrlog: section 1.3.2, shows how let is syntactic sugar for lambda expressions
10:54gfrlogmalbertife: I believe it
10:55gfrlogmalbertife: which would mean it doesn't have to be a special form in clojure
10:55gfrlogmalbertife: but probably all the fn calls are expensive compared to creating local variables in the bytecode
10:56gfrlogmalbertife: integers could be sugar for lambda expressions as well ;-)
10:56malbertifegfrlog: i see your point
11:01gfrlogman this class has an #as(clazz) method, and then a #canAs(clazz) method to go with it
11:02gfrlogmakes me think of middle school and wrestling
11:08gfrlogchouser: oh crap now I need to pass the model-maker back to another createModel method on the original ModelFactory
11:09kephale00Is there a prettier way of converting a nested seq to a string than a recursive (if (seq? coll) (map nest-to-str coll) (str coll))?
11:12chousergfrlog: yes, let as a special form is almost certainly for performance, in a couple differenct directions.
11:13chouserfn calls are more expensive than let, and every fn is a class which already stresses the JVM in a direction it wasn't really designed for.
11:13chouserlet and fn locals have nothing to do with the Var reference type
11:14chouserkephale00: nested exactly one level deep, like [["a" "b"] ["c" d"]]? Or sometimes deeper?
11:14chouser& (apply str (flatten [["a" "b"] ["c" "d"]]))
11:14sexpbot⟹ "abcd"
11:19kephale00chouser: almost always deeper, and I am attaching '(' ')' on either side, so the snippet I sent wasn't exactly what I'm doing
11:19kephale00oh duh
11:19kephale00print-str
11:20kephale00thanks!
11:23kephale00& (clojure.contrib.str-utils2/replace (print-str '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C))) #" " "")
11:23sexpbotjava.lang.ClassNotFoundException: clojure.contrib.str-utils2
11:23kephale00heh
11:25gfrlog_kephale00: so you want a nested seq of strings to be returned?
11:26kephale00gfrlog_: yes, and that expression worked in my repl
11:28gfrlog_kephale00: I'm not too familiar with the clojure.walk namespace, but I think that has something
11:28gfrlog_kephale00: particularly the post-walk function?
11:28chouser& clojure.string/replace
11:28sexpbot⟹ #<string$replace clojure.string$replace@18d68a9>
11:29kephale00gfrlog_: yeah, walk did seem like a reasonable alternative
11:29kephale00ah I guess I might use str-utils2 too much : P
11:30chouserkephale00: no it's fine, it's just been superceded by clojure.string
11:30AWizzArdIs there a good example for the use of 'ensure'?
11:30kephale00& (clojure.string/replace (print-str '((E (C) (F  F) (A A) H ((G) B) ((E G (I (I I A)) H  (B)  C (D (H))) (F C C))) irc://irc.freenode.net:6667/#" " "")
11:30sexpbotjava.lang.Exception: EOF while reading
11:30kephale00upps
11:31kephale00& (clojure.string/replace (print-str '((E (C) (F F) (A A) H ((G) B) ((E G (I (I I A)) H (B) C (D (H))) (F C C))))) #" " "")
11:31sexpbot⟹ "((E(C)(FF)(AA)H((G)B)((EG(I(IIA))H(B)C(D(H)))(FCC))))"
11:31kephale00yeah that
11:31kephale00chouser: good to know
11:32Raynes&(clojure.walk/postwalk #(if (coll? %) % (str %)) '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C)))
11:32sexpbot⟹ (("E" ("C") ("F" "I") "F") ("A" "A") "H" (("G") "B") (("E" "G" ("I" ("I" "I" "A")) "H" "I") ("B") ("A") "C" ("D" ("H"))) ("F" "C" "C"))
11:32RaynesThat was fun.
11:32gfrlog_Raynes: does it not have a version that only applies to leaf-nodes?
11:32Raynesgfrlog_: Not sure. Didn't bother checking.
11:33chouser& (-> '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C)) pr-str (clojure.string/replace " " ""))
11:33sexpbot⟹ "((E(C)(FI)F)(AA)H((G)B)((EG(I(IIA))HI)(B)(A)C(D(H)))(FCC))"
11:34Raynesgfrlog_: Doesn't look like it.
11:35gfrlog_Raynes: I understood it that way too, as that's what I thought he told me.
11:35gfrlog_Raynes: see exchange at 11:22
11:35RaynesWell, there she blows, for future reference. :D
11:36kephale00Raynes: nono, you answered what i originally asked
11:36kephale00i just asked the wrong thing
11:36RaynesUnderstood.
11:36gfrlog_now this story has come to a satisfying conclusion
11:39chouser&((fn f [s] (str \( (apply str (map #(if (list? %) (f %) %) s)) \))) '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C)))
11:39sexpbot⟹ "((E(C)(FI)F)(AA)H((G)B)((EG(I(IIA))HI)(B)(A)C(D(H)))(FCC))"
11:39AWizzArdWhy can refs change in other transactions when I don't (ensure them)?
11:39chouserI guess that was the original "bad" solution?
11:40chouserAWizzArd: Refs can change in other transactions regardless of whether you ensure them.
11:40kephale00not bad persay, but I'm going to be running the function on the order of millions of times
11:41chouserkephale00: might be more efficient recursing directly like than than pr-str+replce
11:41chouserkephale00: or maybe not -- would be interesting to find out
11:41kephale00chouser: hrm… i'll do some speed tests
11:41chouserof course millions of times still might not be enough to matter.
11:43kephale00incidentally, is there a simple way of doing speed tests? I have been doing such tests with nanoTime inside a let
11:44chouser(doc time)
11:44clojurebot"([expr]); Evaluates expr and prints the time it took. Returns the value of expr."
11:45gfrlog_,(time (doc time))
11:45clojurebot"Elapsed time: 0.48 msecs"
11:45clojurebot"([expr]); Evaluates expr and prints the time it took. Returns the value of expr."
11:45kephale00ah… *forehead smack*
11:45chouserbut you still have to be very careful about Hotspot warmup, etc.
11:45mduerksenchouser: "Refs can change in other transactions regardless of whether you ensure them". really? from what i understood from the docs, it should not happen. did i miss something?
11:45gfrlog_if (time) had a version that returned the time, that would make it convenient to time 10000 runs and average them
11:47mec(defmacro new-time [expr] `(let [start# (System/nanoTime) ret# ~expr] [(/ (double (- (. System (nanoTime)) start#)) 1000000.0) ret))
11:47mec(defmacro new-time [expr] `(let [start# (System/nanoTime) ret# ~expr] [(/ (double (- (. System (nanoTime)) start#)) 1000000.0) ret]))
11:48chousermduerksen: We're using sloppy language here, I'm afraid. The same Ref can change, independently of each other in two separate transactions at the same time, but if both try to commit it has to be resolved somehow.
11:49chouseralter and commute resolve such a conflict in different ways.
11:49mduerksenchouser: ah, thanks for the clarification, my world view makes sense again ^^
11:49chouseroh, good. :-)
11:50chouserI'm not quite sure what AWizzArd meant.
11:54raekmaybe he was referring to "write skew" (http://java.ociweb.com/mark/stm/article.html#write-skew)
11:55mduerksenAWizzArd: do you mean this: why do i have to ensure a ref when "alter" will take care of consistency? in that case, consider the skew anomaly
11:56mduerksenoops, raek was faster
11:58AWizzArdI will look up that link.
11:59AWizzArdI just thought that as soon a ref is touched via deref or alter, then a consistent view is guaranteed.
11:59AWizzArdSo, "why ensure"? I will now check that link.
12:00mduerksenAWizzArd: deref does not touch, thats exactly what ensure does
12:01mduerksenbut while we're at that topic: i observed that when an ensured ref is altered by a competing thread to *the same value*, neither of the transactions will fail. did i observe correctly, and is this what is meant by "allows for more concurrency than (ref-set r @r) ?
12:03mduerksenraek: that link is great, btw
12:12DantasBest wishes from Brasil( Brazil ) :P
12:12Dantasim wondering : how could i know the market rate for clojure/scala jobs ?
12:19technomancyDantas: there aren't really enough of them yet to generalize about
12:21Dantastechnomancy: yes , that is my conclusion after a quickly search in google
12:21Dantastechnomancy: thnx
12:37thorwil(def article-atts '[title, body, created-t, updated-t])
12:37thorwil(ds/defentity Article (vec (concat [^:key slug] article-atts)))
12:38thorwilfails with: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
12:38thorwilany way around that?
12:39amalloyum. i bet defentity is a macro
12:39amalloyin which case, like all macros, it can't do compile-time stuff (define an entity) with data that exists only at runtime (article-atts)
12:40amalloyto get this basic effect, you would need to define a macro that expands into a call to defentity with a *literal* argument, because macros love literals
12:41thorwil*bulb-lights-up*
12:46amalloythorwil: well i'm glad you got the idea, because i can't find any of my code that actually does this at the moment
12:46amalloyi guess my article http://hubpages.com/hub/Clojure-macro-writing-macros has an example. it's kinda ugly and not targeted right at what you're doing, but it's in the ballpark and you would probably find it educational
12:47thorwilamalloy: i will see if i really got the idea after dinner. but just really getting that i sometimes have to know if i deal with a macro or a function is a step forward :)
12:55cgrayhi, what's the inverse of `name'?
12:55amalloycgray: name is a many-to-one mapping; it has no strict inverse. but keyword is probably what you meant
12:55cgrayamalloy: thanks
13:01DantasAtoms doesn´t need to be inside a transaction, right ? and atoms are shared for all threads. How coordinate this kind of shared state ?
13:02chouserDantas: an atom's value is changed using 'swap!', only one of which can happen at a time.
13:03Dantaschouser: so , the update-function is atomic
13:03Dantaschouser: right ? thx in advance
13:04raekthe atomicity is handled automatically (but requires the update funtion to be free of side-effects)
13:07raekbasically, what swap! does is something like (defn swap! [a f & args] (loop [] (let [old-val @a, new-val (apply f old-val args)] (if (compare-and-set! a old-val new-val) new-val (recur)))))
13:08fliebeland it calls the watch fns ;)
13:14elb0wWhat function do you guys see clojure serving now (5 years from now)? Im trying to decide if its something I should pick up as a primary/secondary language. Always good to hear from people who use it Day to Day imo
13:15chouserIn 5 years many key concepts from Clojure will have been adopted by several existing languages as well as new ones.
13:16chouserClojure itself by then may have acheived maximum mindshare that a LISP can (that is, somewhat less than, say, ruby has today)
13:17chouserMost academic papers will continue to use either Haskell or Java for their examples.
13:17chouserelb0w: How's that for a stab in the dark? :-)
13:18TimMcelb0w: Pick it up if only to learn some of the concepts it is based on. THere's some really neat stuff in there.
13:18elb0whmm
13:18elb0wIs it a either or thing with haskell?
13:19elb0wOr can you see a benefit to both?
13:19elb0wmost people I speak with compare it to haskell
13:19chouserelb0w: I don't know haskell as well as I intend to, but I think each will give you unique insight.
13:20elb0wok cool, can you suggest any good entry books to it? I have a 6hr plane ride im trying to get some material together :P
13:21cemerickchouser: I think it's got more upside potential than Ruby had back in the day, mostly due to far lower switching costs re: the JVM.
13:21chouserelb0w: start with any of Programming Clojure, Practical Clojure, or Clojure in Action, and follow up with Joy of Clojure. [I've only read the first and last of those]
13:21lucianthat depends a lot on what platform you're already using
13:21lucianbut yeah, clojure's great. i think it's likely the best lisp ever, perhaps better than racket
13:21lucianlearn it
13:22chousercemerick: I do think the syntax will continue to be an impediment to maximal adoption.
13:22TimMcelb0w: If you haven't used software transactional memory before, you need to try Clojure. :-)
13:23chouserIt has already grown the LISP base (if you will) in some directions, but there's a lot of people who I think will continue to reject it on syntax alone.
13:23fliebelchouser: Someone suggested a whitepsace absed syntax for Clojure, as a pre-processor :)
13:24chouserfliebel: Pleajure, iirc
13:24lucianwell, if it went farther in replacing lists with more appropriate data structures, the syntax might not be a big issue anymore
13:24lucianfliebel: i'd love that
13:24cemerickfliebel: the CL'ers went through that years and years ago. Doesn't seem to have panned out so well.
13:24luciancemerick: i think they just did it wrong
13:24chouserhttps://github.com/apatil/pleajure
13:25TimMcelb0w: Just beware of the syntax in older Clojure books -- some trivial changes (like #^ -> ^) have occurred that will confuse you if you are unaware.
13:25lucianthere's http://portal.acm.org/citation.cfm?id=1566481
13:25fliebelYou know, basically it's just a yaml parser… :)
13:25luciani think it comes close to having nice syntax
13:28fliebellol @ pleajure (defn zip "Like Python's zip" …)
13:28lucianpleajure is a bit wrong
13:29fliebelyea, he seems to use 4 spaces as well.
13:29lucian4 spaces is fine
13:29lucianbut if it's a preprocessor, it's failed already
13:29fliebellucian: Why?
13:29lucianit has to be either official or a reader macro (which clojure doesn't have) to succeed at all
13:30pdk(doc zip)
13:30clojurebotIt's greek to me.
13:30fliebelpdk: zip is like (map vector list list2)
13:31lucianhttp://docs.python.org/library/functions.html#zip
13:32dnolenchouser: cemerick: I think people deeply familiar with FP have little problems with with the parens. As FP becomes more mainstream, I think the ceiling on Clojure adoption gets much higher.
13:33luciandnolen: they're just redundant
13:33luciani wish more people realised that
13:33cemericklucian has never seen cemerick's code ;-)
13:34luciancemerick: i take it you misindent your code?
13:34cemericklucian: no, but it's not a 1:1 correspondence between lines and sexprs
13:34amalloyredundant?
13:34opqdonutdnolen: FP is not the same as lisp syntax
13:35luciancemerick: lines aren't they only whitespace, and whitespace doesn't have to be the only delimiter
13:35cemerickdnolen: I'd generally agree, but I'd go a little further. The stigma surrounding sexprs seems to have been dwindling for quite a while. A generational thing, perhaps.
13:35cemericklucian: sounds like you have something in mind that is *way* more complicated than I'd like to consider.
13:35amalloylucian: reduce partial apply + 2 range 10
13:35luciancemerick: i don't have something particular in mind
13:36luciani do however know that python is very, very readable
13:36amalloythat needs parens to make any sense; putting it on like five lines would be a mess
13:36dnolenopqdonut: most interesting FP papers are in, SML, Scheme, Haskell, Oz, Erlang. Point is, FP languages have many approaches to syntax. For FPers, syntax sits on equal footing with semantics.
13:36fliebelamalloy: Your unicode is all wrong there, that second space should be a nbsp, and the last one should be a zwj.
13:36lucianamalloy: i never suggested that
13:36lucianamalloy: one line? put the parens in
13:36opqdonutdnolen: yeah sure
13:36amalloylucian: my point is you said parens are redundant
13:37lucianamalloy: most of them, yes
13:37opqdonutdnolen: I guess I misinterpreted your earlier comment :)
13:37opqdonutlucian: no no, you must mean that indentation is redundant!
13:37luciani'd say all of them, if lisp didn't insist on only using lists
13:37fliebellucian: Not that Python has some additional and very important hinst about what is a block.
13:38Chousukelucian: Clojure doesn't only use lists.
13:38amalloylucian: python is fine to read, but it gets away with a lot because it's imperative and large "expressions" can easily be split up by newlines
13:38lucianfliebel: yes, of course. which is part of why i think lisp failed when it comes to syntax
13:38lucianamalloy: that's irrelevant. the syntax is awesome
13:38lucianChousuke: barely
13:38Chousukelucian: no
13:38amalloy*sob* srsly lucian
13:38Chousukelucian: vectors are pretty common
13:38lucianChousuke: it uses a few vectors, that's it
13:38hiredmanlucian: I disagree
13:38hiredmanclojurebot: python
13:38clojurebotpython is ugly
13:39Chousukelists are common in code because most of the time you're calling functions or other operators
13:39lucianChousuke: and that's a failure of lisp if you ask me
13:39Chousukelucian: what, calling functions? :P
13:39lucianit may be relatively nice as a language, but its syntax sucks, because its ast sucks
13:39fliebellucian: What is the difference between somthing(args arg) or (something args arg)?
13:39lucianChousuke: no, using lists for everything
13:39lucianfliebel: that's not what i'm arguing about
13:40lucianfliebel: that's absolutely fine
13:40lucianfliebel: but parents + newlines is redundant
13:40zakwilsonNo modern lisp uses lists for everything.
13:40Chousukelucian: lists are pretty much exclusively used for operator calls in Clojure
13:40zakwilsonOr do you mean syntax?
13:40lucianzakwilson: yes
13:40Chousukeeven in syntax.
13:40zakwilsonI'd say most of them do use lists for almost everything in syntax, and that's where Clojure differs.
13:41hiredmanlucian: conflating the datastructures generated by the reader is a common mistake, but it is a mistake, so please stop doing it
13:41Chousukezakwilson: that's true.
13:41pdkhaving [] #{} {} is helpful in some spots
13:41hiredmanlucian: conflating with an ast
13:41pdkif you think about it works well for delimiting stuff like argument lists in fns/binding lists in let
13:41pdkto visually separate them from the following bodies
13:42zakwilsonClojure uses lists and vectors heavily in its syntax, maps less so. I haven't seen sets used as part of the syntax.
13:42pdkclearly we need to fork it
13:42Chousukemap syntax is pretty much only used in destructuring
13:42pdkand make it more set based!
13:42pdkpicture it
13:42pdkfunction bodies can be sets of forms
13:42ChousukeBut people have tried to "fix" Lisp syntax many times before
13:42pdk"yeah just execute these in any order you like"
13:42clojurebotExcuse me?
13:42Chousukethey've always failed
13:43opqdonutyep
13:43opqdonutit
13:43opqdonut's always some newcomer
13:43opqdonutwho doesn't want to believe that yes, yo do get used to the parens
13:43opqdonutquite quickly in fact if you just stop hating them
13:44ChousukeI don't know why you'd hate them in the first place.
13:44opqdonutmany do, I've found
13:44amalloyi liked this weekend's tweet: lisp is the most-hated language among people who've never used lisp
13:44fliebelHas anyone seen Io? They claim it's like lisp without the Syntax. It;s pretty uniform at least, with code blocks implemented as methods and all.
13:44opqdonutamalloy: indeed.
13:44opqdonutminimal syntax is nice, I think lua succeeds at this too
13:44pdkio is pretty neat conceptually though i don't know of anything serious using it yet
13:45amalloyi found the parens a stumbling block too. it's just very different from what we learned in school for both math and programming
13:45zakwilsonI've seen attempts by Lisp experts to overlay a syntax on top of Lisp, but it's always for the purpose of making the language more attractive to beginners.
13:45Chousukeany attempt to do away with the parentheses will just obscure the fact that lisp code is data
13:45fliebelI wonder what message passing and prototype based inheritance would do to functional programming. :P
13:45amalloythe important thing is to man up and get over the language's *punctuation* and look at the language. then you find out the punctuation is there for a reason
13:45dnolenfliebel: Clojure already has a form of protoype inheritance.
13:46fliebeldnolen: Yea, multimethods, right?
13:46Chousukeif you can find a better and more succinct notation for lists than (foo bar) I'd like to see it :)
13:46dnolenfliebel: yes.
13:46Chousukebecause if the lisp code you write does not correspond directly to a lists and other data elements, then it's not lisp code :/
13:46Chousuke-a
13:46amalloyChousuke: haskellers would suggest just "foo bar", i suspect
13:47zakwilsonHaskell lists are [foo, bar]
13:47lucianChousuke: yes, code is data. but the wrong kind
13:47Chousukeamalloy: hmm, but how do you do (foo (bar zonk)) then?
13:47Chousukelucian: what sort of data should it be then?
13:47lucianChousuke: yaml
13:47amalloyzakwilson: Chousuke is talking about code lists: calling functions
13:47fliebelstack based programming to the rescue… maybe
13:47opqdonuthahahahah yaml
13:47opqdonutoh my
13:47lucianmeh, not literally
13:47Chousukelucian: you mean maps?
13:48zakwilsonhaskell nested function calls are foo (bar baz)
13:48lucianChousuke: no, i mean non-redundant data structures
13:48amalloyChousuke: foo and bar know how many arguments they expect. i think the syntax is foo $ bar zonk, or foo (bar zonk)
13:48RaynesI think I'd rather Clojure never see a new user than for it to adopt a Python-like syntax because people don't 'get' s-expressions.
13:48Chousukelucian: and in which way are lisp data structures redundant?
13:48lucianRaynes: i "get" s-expressions, i just know they're uselessly redundant
13:48lucianChousuke: they're indented *and* paren-separated
13:48Raynes"You're so wrong, you're visible from satellite."
13:49Chousukelucian: eh, that's not lisp code.
13:49TimMcheh
13:49Chousukelucian: that's text.
13:49Raynesamalloy: Is that good enough?
13:49opqdonutlucian: most other languages have punctuation + indentation
13:49opqdonutlike for example jagva
13:49opqdonut-g
13:49lucianopqdonut: that's also wrong
13:49RaynesIt doesn't make a lot of sense, but it's along the lines of what I used before.
13:49opqdonutpython is about the only exception I know of
13:49lucianopqdonut: python, haskell, a few others
13:49TimMclucian: A little well-placed redundancy aids readability.
13:49Chousukelucian: the problem is that if the *text* does not map trivially to code, using features like macros becomes difficult.
13:50TimMcThat's why most languages are written with capital initial letters.
13:50opqdonutokay yeah Haskell's layout rules too
13:50lucianTimMc: i disagree with that. again, look at python
13:50TimMc*natural languages
13:50fliebellucian: So you want to replace : with ( and \n\n with )?
13:50lucianChousuke: not text, other datastructures
13:50lucianfliebel: dunno, maybe
13:50luciansweet-expressions is close
13:50Chousukelucian: what data structures? I honestly don't understand you
13:50Chousukelucian: if you talk about indentation and parens, that's text.
13:50lucianChousuke: yaml represents data structures, right?
13:51lucianChousuke: forget about s-exps
13:51zakwilsonI tihnk that Clojure is just not for lucian, and that's why it's a good thing we have thousands of languages to choose from.
13:51RaynesAre we currently using Python as an example of perfect syntax here?
13:51lucianRaynes: I am. but not perfect, just very, very good
13:51lucianzakwilson: i like clojure very much, just not its concrete syntax
13:51jolyIndention in Clojure is for readability, not syntax or symantics
13:53zakwilsonlucian: you could write your own parser or borrow jython's and hook it up to Clojure's data structures and standard library.
13:53lucianzakwilson: sure
13:53Chousukelucian: I don't know why yaml would be better for code than Clojure's version of s-expressions
13:53dnolenlucian: present a good macro system w/o sexpr syntax. Dylan tried and failed.
13:53Chousukethat too
13:53luciandnolen: the problem is no one else tried
13:53fliebellucian: So it's not that parens are redundant, you are just proposing an alternate syntax for lists that is more liek yaml.
13:53lucianclojure tried a little, with vectors
13:53pdk#ifdef!
13:53lucianfliebel: sure, that'd be a start
13:54Chousukeif your syntax is dependent on whitespace or indentation, it's pretty difficult to beat syntax/quasiquote
13:54pdkyea baby
13:54zakwilsonNemerle, Ioke and Mirah also have macro systems without sexp syntax. I looked at Nemerle's and it seemed much harder to use than Lisp's.
13:55RaynesIt's only natural that it be harder to use. When your syntax is unnecessarily complex, so is your macros.
13:55Raynesare*
13:55zakwilsonI should note that I did not actually use it; I just read example code.
13:56Raynesair*
13:56dnolenlucian: many people have tried. Template Haskell, camlp4. Those are serious systems. But go ahead, give a shot as well.
13:56luciani'm not very worried about macros being easy
13:56luciani'm much more worried about readable syntax
13:57RaynesI certainly am. That's one of the greatest things about Lisp.
13:57lucianRaynes: well, lisp fails at macros anyway :)
13:57Chousukelucian: You're still simply asserting that lisp is not readable.
13:57ChousukeFrankly, I think you're wrong.
13:57lucianscheme gets macros a little better, but still not quite perfect
13:57lucianChousuke: it's not, at all
13:57lucianit's much more readable than, say, java
13:57fliebelrainbow parens to the rescue :)
13:57opqdonutlucian: have you tried racket's macros?
13:57lucianbut nowhere near lisp
13:57lucianopqdonut: yes, they're very close to being perfect
13:57zakwilsonlucian: you're trying to convince a bunch of lispers that some other syntax is better.
13:58lucianzakwilson: yes, i see the folly of my ways
13:58ChousukeNowadays I find Clojure more readable than python honestly
13:58lucians/but nowhere near lisp/but nowhere near python/
13:58ChousukeCL is a bit iffy because they really do use lists for everything
13:58jolyhard to make a general "more readable" declaration when it depends so much on the person doing the reading
13:58dnolenlucian: no Scheme messed up macros royally, and it's taken 20 years to fix it. clearly you haven't seen at the monstrous macros in CPS style hacks.
13:58Chousukebut Clojure code is nice.
13:59luciandnolen: that's not the point, they're better because they happen later in the compilation process
13:59zakwilsonThe thing that I always have trouble with in other languages is seeing where the scope of a variable ends.
13:59Rayneslucian: You're filled from your toes to your eyeballs with "better", but you have no implementations. You sound like the kind of person that should create their own programming language! Maybe us primitive Lispers will understand better if we actually see a successful implementation of your ideas.
13:59fliebelMan, I'm so going to make a yaml to clojure converter :D
14:00Chousukefliebel: well, that's not too hard.
14:00lucianRaynes: i didn't mock you, you know
14:00RaynesI am dead serious.
14:00Chousukefliebel: just find a yaml reader and convert its output to clojure data structures :P
14:00fliebelChousuke: I'd think so, otherwise I'd not waste my time on it.
14:00zakwilsonPeople with ideas about languages that other people just don't get *should* write their own language.
14:00lucianRaynes: when it comes to readability, lisp is "primitive". i offered no insult to other aspects of lisp or its users
14:01lucianthe reason i don't bother to write a language is because i know i'll be the only user, forever
14:01ChousukeI still don't agree with that assertion
14:01zakwilsonLisp is primitive, or perhaps simple.
14:01luciannot worth the trouble
14:01Rayneslucian: What zakwilson just said. If we don't feel it's better, then show us it's better. Write your own language with perfect macros and great syntax.
14:01Chousukeand you're not doing anything to support it either :/
14:01zakwilsonWrite your own syntactic overlay for Clojure then. I bet you could get a few users.
14:02zakwilsonI'd even try it, just to prove that I like Clojure's syntax better.
14:02Rayneszakwilson: He has asserted that an 'overlay' wouldn't be good enough, IIRC.
14:02lucianit just wouldn't survive
14:02luciani have no urge to add to the pile of unused languages
14:03luciani'll just grumble and use python and clojure
14:03fliebelI do… I think tree based programming is the future!
14:03zakwilsonOf course it wouldn't. Syntactic overlays for Lisp have been tried many times, the first being from John McCarthy himself.
14:03jolyI've used several languages I'd love to add to that pile :P
14:03lucianjoly: heh
14:04zakwilsonIf you actually came up with the "perfect syntax", perhaps other languages would emulate it. Research/experimental languages aren't meant to be *used* but to influence the future.
14:04amalloylucian: if it's a really great idea, you won't be the only user
14:04RaynesPrecisely.
14:04lucianamalloy: i don't (yet) have a clear picture of what i want
14:05zakwilsonOr what amalloy said.
14:05luciani do know that i want readable syntax in a homoiconic language
14:05amalloyhah i was going to amend myself to "actually more like what zakwilson said"
14:05zakwilsonHeh. Either is a possibility.
14:05zakwilsonClojure was, after all just some guy's attempt to make a better language for himself.
14:05lucianthe problem is that apparently people don't agree on what's readable
14:06RaynesNobody agrees on anything. That's why we have a million different languages.
14:06lucianC, C#, Java, Python, PHP people all largely agree that python clearly has a readable syntax
14:06zakwilsonlucian: are you familiar with Ioke?
14:06lucianzakwilson: vaguely
14:07fliebelcemerick: Google just threw up a log where you mentioned you are working on spatial index structures in Clojure. Do you have any of these laying around?
14:07cemericklucian: Seriously, get one programmer from each camp in a room, and you'll have N+1 opinions.
14:07Chousukelucian: I won't deny that Python is readable, but I don't think that it's better than Clojure, either.
14:07dnolenlucian: semantics and syntax are intertwined. Clojure permits new scopes via let, it discourages side effects, it's doesn't support arbitrary control flow. These are all un-Pythonic. What would a paren-less Clojure even look like?
14:07luciansure, that's why ruby, clojure, python programmers can't decide which clearly has the most readable syntax
14:07cemerickfliebel: mm, haven't worked in that area in a while. But yeah, I did. They're done. Nothing open sourced, tho.
14:08luciandnolen: well, they're not all unpythonic
14:08zakwilsonIoke claims to be homoiconic but has a syntax that looks more like popular scripting languages. It has macros. I think it's close to what you want.
14:08lucianabstract syntax is linked to semantics, yes
14:08lucianconcrete syntax, not really
14:08lucianzakwilson: yes, i know. it's interesting
14:09fliebelcemerick: Oh, to bad… I'm in a need for some spatial indexing. R-tree would be nice for example. I'm about to cut corners and base it on java.awt.Rectangle.
14:09dnolenlucian: I repeat my question. Given Clojure's semantics what would a block syntax look like?
14:10cemerickfliebel: make sure your dataset and query types really warrant it. Brute-force search outperforms R-Trees depending on those factors, especially over smallish N's.
14:10luciandnolen: i'm not sure
14:10Rayneszakwilson: Also, see Atomo.
14:10cemerickdnolen: probably something like scala, but without vars
14:10fliebelcemerick: What scale of N's are we talking about here? Is a couple of hundred still smalish?
14:11zakwilsonAtomo is in my browser history. I don't remember it though.
14:11luciandnolen: close to http://www.dwheeler.com/readable/ perhaps
14:11lucianor ginger
14:11cemerickfliebel: yes -- just a couple of helper fns and filter will do you just fine there
14:11fliebelcemerick: Okay, I wrote overlaps? and contains? already...
14:12cemerickfliebel: right; (filter (partial overlaps? query-region) data), etc. You need many thousands of rects to make indexing worthwhile.
14:12luciandnolen: but without the infix bit, i don't think that's very useful
14:12cemerick(at least for typical queries)
14:12amalloylucian: people make the same assertions about python's whitespace that they do about lisp's parens. i don't know how you can claim that programmers from every language claim python is readable
14:13zakwilsonFor something on-topic: do we have a roadmap for 1.3's release yet?
14:13lucianamalloy: not every, just several
14:13Rayneshttp://amplicate.com/users/15168213/anthony-simpson-iorayne
14:13RaynesEr, wrong window.
14:13fliebelcemerick: Yea, just collision detection mostly. A intermediate shortcut would be a flat grid.
14:13lucianamalloy: as i said, other sets of programmers don't
14:13amalloyi disagree with you about every language on your list except for python
14:14amalloyhaving written in all of them but C# myself for at least a year each. i'm sure if i wrote python it would look readable to me, but it doesn't really yet. the same goes for any C programmer who's never written python
14:15cemerickfliebel: If you're really interested in digging into the field, start here: http://www.amazon.com/gp/product/0123694469/ref=as_li_ss_tl?ie=UTF8&amp;tag=httpcemericom-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0123694469
14:16lucianamalloy: my data is mostly anecdotal, so of course i'm not certain. but an overwhelming majority of programmers who's language of choice was one in that list agreed
14:16lucian(the small subset that i asked, of course)
14:17Raynes6 out of 10 programmers agree that programming languages are microwaves.
14:17fliebelcemerick: I'm not *that* interested, but I like to implement and understand algorithms and data structures from time to time.
14:18fliebelcemerick: What where you using these R-trees for?
14:19cemerickfliebel: Still being used. In the bowels of docuharvest, the next rev of PDFTextStream, and other places.
14:19cemerickfliebel: see, you're misquoting me slightly :-)
14:19mattmitchelli have a lein project which uses sdb and mysql. I'd like to create tests that actually prove the data is getting inserted into mysql, and not just mock everything.
14:19cemerickI know *nothing* about collision detection per se
14:20mattmitchellwhat's the recommended approach for switching environments (use test db when running tests etc.) ?
14:20cemerickEspecially in real-time contexts (i.e. gaming)
14:21cemerickMy most common queries over spatial indexes are nearest-neighbor, neighbor traversal (which is a sort of compound query), and windows.
14:23cemerickIf you're in a real-time environment, your biggest problem will be the update penalty: adding regions to e.g. R-Trees can be very expensive, depending on what variant and configuration parameters you're using.
14:24fliebelcemerick: Yea… So that is another plus for just using the way I store objects already.
14:24cemerickThere are other structures that are more dynamic, but I'm not super familiar with them (since all my use-cases involve static datasets).
14:26fliebelFor a sorted-map, what is the insertion cost? I currently store objects in a map, so sorting that would limit brute forcing to one axis.
14:27cemericksorry, I don't keep big-O times at the tip of my tongue :-)
14:28fliebelno? oh, disappointment al around. ;)
14:28fliebelI'll google it
14:28gfrlogO(log(log(n^(n!)))) probably
14:28fliebelgfrlog: Is that much?
14:29gfrlogfliebel: it's completely fictional; I have no idea
14:29zerokarmaleftthat reduces to O(log(n)) so no
14:29gfrlogzerokarmaleft: does it?
14:30amalloyfliebel: logn insertion to sorted map is right in imperative/mutable context. i don't see a reason it would be different here but it could be
14:30raekhas Clojure 1.2.1 been announced yet?
14:31amalloyzerokarmaleft: that does not reduce to logn. it reduces to "holy crap that's a lot"
14:32Raynesraek: It's already out, iirc.
14:32amalloyRaynes: but not "announced"
14:32RaynesWhy would you expect it to be announced 3 weeks after it was released?
14:33RaynesI gave up on that.
14:36zakwilsonRaynes: the download link on clojure.org is 1.2.0
14:36zerokarmaleftamalloy: n^n! is huge sure, but the outer functions are logarithms...as a generalized growth rate, it's still small relative to O(n!) by itself
14:37Rayneszakwilson: It's on maven though. Leiningen uses it by default in new projects.
14:37RaynesCake probably would to if anybody cared to release a new version just for that.
14:37zakwilsonRaynes: I see 1.2.1 on github too. I wonder why the link on the main site hasn't been updated.
14:38amalloyzerokarmaleft: even if log(n^n!) were n! (which i don't believe it is but it's been some time), log(n!) is clearly much larger than log(n)
14:39amalloyand you proposed that log(log(n^n!)) was the same as log(n), big-O wise
14:40zerokarmaleftyea, now that i've said that i can't remember for sure...i pulled O(n log n) = O(log n!) out of that fuzzy place
14:41thorwilamalloy: i guess this is not quite what you meant, as indicated by the fact that it doesn't work: https://gist.github.com/890995 :)
14:41amalloythorwil: nope, definitely not what i meant
14:41zerokarmaleftat any rate, my point was stick to ^ and ! if you're pulling fictionally ginormous big-oh functions out of thin air
14:44joshua__ended up writing my own html-to-markdown thingy for Clojure..
14:44amalloy(defmacro def-entity-and-attrs [entity-name slug attrs attr-name] `(do (def ~attr-name ~attrs) (defentity ~entity-name ~(vec (concat [slug] attrs))))) or something like that
14:44joshua__here is what it looks like having been run back and forth =) http://notepag.es/serG8H
14:46fliebelThere is really no way you can sort a map by its values without having a reference to the map you're sorting, right? Which means that you need to re-sort the whole thing every time basically.
14:47amalloyfliebel: what?
14:47amalloyoh, by its values
14:47fliebelamalloy: ##(doc sort-map-by) takes only keys, so to sort by the values, you need to get them from the map.
14:47sexpbotjava.lang.Exception: Unable to resolve var: sort-map-by in this context
14:48amalloyfliebel: you can't really maintain a map sorted by value, no. that's an abomination
14:49zakwilsonI use a function that gives you a vector of mapentries sorted by value. It's also possible to maintain an arraymap sorted by value, but not a very good idea.
14:50amalloythe reason maps are efficient is because you can do fast lookups by key. if you sort them according to value only, you either have a non-map that's slow to look up by key (not the worst thing ever) or a map that you can insert into slowly and look up by key quickly, but it doesn't matter because you seem to prefer lookup by value anyway?
14:50kephale00is unify in clojure 1.2.1?
14:50Netfeedunless you cheat and have something like [[:c 1] [:a 2] [:b 3]] :)
14:50thorwilamalloy: thanks! i suspect the critical part is (def ~attr-name ~attrs) to get around the runtime vs compile-time thing?
14:51fliebelamalloy: Maybe you are right… Maybe I can use a vector instead… ##(doc disj)
14:51sexpbot⟹ "([set] [set key] [set key & ks]); disj[oin]. Returns a new set of the same (hashed/sorted) type, that does not contain key(s)."
14:51amalloyfliebel: can't disj in the middle of a vector
14:52amalloythorwil: no actually. that's just for your convenience so you can reuse the name later
14:52amalloythe defentity still needs to use the literal that was passed in as a macro arg
14:52fliebelamalloy: sorted-set then… Something that can do this stuff but hasn't the keys
14:53duncanmi started enabling *warn-on-reflection*, but now I don't know how to hint an array of java.awt.Points
14:53amalloychouser: these "manning" people are sending me a book, for some reason
14:53amalloy^"[Ljava.awt.Point" I think
14:53tufflaxfliebel: maybe this interests you, i dunno http://clojure.github.com/clojure-contrib/branch-master/priority-map-api.html
14:53amalloyi think there's a more convenient way but that's the one i remember
14:53duncanmi have (let [points (into-array Point [(Point. 0 0) (Point. 0 w) (Point. h 0) (Point. h w)])] ...), I'd thought that'd be sufficient
14:54fliebeltufflax: Interesting, but I think I can get away with a set instead.
14:54raekkephale00: I think it's a separate project: https://github.com/clojure/core.unify
14:55duncanm[Ljava/awt/Point [Thrown class java.lang.ClassNotFoundException]
14:55duncanmboo
14:56duncanmoh, semicolon
14:58fliebel&(type (make-array java.awt.Point 3))
14:58sexpbot⟹ [Ljava.awt.Point;
14:58duncanmfliebel: what does that mean?
14:59duncanmfliebel: if it knows the type already, why do i get a reflection warning?
14:59fliebelduncanm: I think that code reflects, but than tells you what it found.
14:59duncanmahh
15:00kephale00raek: ah, i was confused by the naming...
15:01fliebelBut that isn't a readable type, clojure waits for me to typ the closing brackot for the vector
15:07chouseramalloy_: cool!
15:21fliebelHow would I "XOR" a set? i.e. get the elements that are in one but not both sets. The best I can do is (union (difference 1 2) (difference 2 1))
15:26amalloyfliebel: (difference (union a b) (intersect a b)) seems clearer
15:27fliebelyea
15:29choffsteinhey all! quick question -- is there an easy way to use lein with rich hickey's sdb library?
15:29choffsteinif it is on clojars, it should be good, right?
15:30dakronechoffstein: https://github.com/richhickey/sdb/network
15:30dakronea few of the forks have work added to make them lein projects
15:30dakronetake your pick
15:31choffsteinawesome. thanks.
15:34choffsteinwhat is the best way to manage java libraries? For example, when I download the java sdk for amazon AWS, I just get a bunch of jars. Where is the best place to put them? (I'm on OSX)
15:36gfrlogmy wife keeps her jars in the pantry
15:37fliebelchoffstein: Probably in your local maven repo
15:37RaynesI put all my jars in the cupboard.
15:37choffsteinokay
15:37fliebelchoffstein: That way you can use them as deps in lein and cake
15:38TimMcfliebel: Alternatively, (union (difference a b) (difference b a))
15:38TimMcwait, nvm, you wrote that
15:38choffsteinlove clojure ... hate the old library dependency scheme from the C days
15:39TimMcchoffstein: What would you have instead?
15:39choffsteinA uniform package manager. Can't do it with the java dependency though.
15:39choffsteinMaven sort of works.
15:39choffsteinI just got spoiled by python's eggs and ruby's gems.
15:39cemerickchoffstein: the AWS SDK is always in maven central
15:40cemerickThe problem with eggs and gems is that they require something like rvm or virtualenv
15:40choffsteincemerick: yep, they do.
15:40choffsteincemerick: is it really? I just tried adding the sdb library to my lein project file and it couldn't find the AWS dep.
15:41cemerickwhich sdb library?
15:41choffsteinorg.clojars.bapehbe/sdb
15:41cemerickThat's bizarre.
15:41TimMcI don't understand the security model with Maven. Is there one?
15:42gfrlogis it weird that ruby requires three separate components to manage dependencies well? RubyGems, RVM, & Bundler
15:42gfrlogI hadn't thought about it before
15:42amalloyTimMc: security?
15:42cemerickchoffstein: FWIW, I forked that a while ago -- Rich's original sdb lib was a good spike, but there were some holes to be plugged IMO. https://github.com/cemerick/rummage
15:42choffsteingfrlog: Well, I think that only really happened when ruby 1.9 started rolling out
15:43choffsteinnever really occurred in the days of Ruby 1.8
15:43cemerick</selfPromotion>
15:43gfrlogchoffstein: what changed with 1.9?
15:43amalloylike, preventing someone sending you a different jar than you want?
15:43TimMcamalloy: If I upload com.microsoft/blarg to clojars...
15:43amalloyTimMc: clojars is a free for all
15:43amalloymaven central is not
15:43amalloygfrlog: you've never said "blarg" when you look at their code?
15:43choffsteingfrlog: basically, people had 1.8 projects and 1.9 projects. the code was different enough that if you were stuck on legacy, you needed gems that were 1.8 compatible -- so all of a sudden you needed different gem sets
15:43TimMcamalloy: You have to prove domain ownership?
15:43cemerickTimMc: The security model is that you want to ensure you're consuming signed jars and not pulling stuff from untrusted repos (like clojars).
15:44gfrlogamalloy: never looked at it ;-)
15:44TimMcYeah, signing, that's the other thing.
15:44gfrlogchoffstein: ah, that's sensible
15:44TimMcDoes it work using SSL certs or something?
15:44choffsteingfrlog: then you had the different VMs coming out -- MacRuby, JRuby, Rubinius -- so you needed a different gemset depending on the VM you wanted to run
15:44amalloyTimMc: yes, that's how signing works
15:44cemerickTimMc: it grounds out against PGP keys
15:44choffsteincemerick: okay, i'll check out rummage. Thanks ;)
15:44amalloycemerick: signed jars aren't that interesting if you're pulling the signature from the same place, at the same time, as the jars. right?
15:45amalloywhoever spoofs the jars will spoof the signatures, and you don't have a more-trusted channel to verify against
15:45gfrlogamalloy: are you talking about the signature itself or the identity (public key) of the signature?
15:45cemerickamalloy: Yeah, if you care enough, you'll want to be checking things against a keystore backed by e.g. MIT or whereever else public PGP keys are held.
15:45choffsteincemerick: still getting an artifact missing for Java AWS library...
15:46gfrlogchoffstein: u can haz good explinayshun
15:46amalloygfrlog: either. if you don't check against a public keystore like cemerick says you're not getting any real security
15:46pjstadigwell people can publish fake pgp keys to MIT or whereever else too
15:46cemerickchoffstein: Odd. It's in maven central: http://mavencentral.sonatype.com/#artifactdetails|com.amazonaws|aws-java-sdk|1.1.5
15:46gfrlogamalloy: if you already have the public key, then getting the signature at the same time as the jar isn't a concern
15:47pjstadigthe idea is to have a web of trust
15:47gfrlogi.e., isn't risky
15:47pjstadighave people who you trust to have signed the key used for the signature
15:47pjstadigand so forth
15:47amalloygfrlog: do you have the public key for org.clojure handy?
15:47gfrlogamalloy: nope
15:48amalloypjstadig: i'm aware of the "idea", but maven most of the time just fetches from maven central and hopes for the best. you need another channel if you actually worry about security (i don't, especially)
15:48amalloyor you could have maven use https to do the fetching, and verify that it's coming from maven central. maybe it does that and i don't know
15:48cemerickThere's two sensible paths: either only pull in artifacts from trusted repos (central, jboss, apache, etc), or never pull artifacts from the public internet, restricting artifacts to those available from your local/private maven repo.
15:49cemerickThe former is a sane balance IMO. The latter is done in a lot of security-conscious orgs, but can be a PITA.
15:49gfrlog"People for the Inethical Treatment of Animals"
15:49amalloycemerick: or pull artifacts from anywhere and don't worry about security, which is what most do
15:50cemericksure
15:50cemerickUsually, it's obvious when you need to start being paranoid.
15:50amalloyi notice that cake deps fetches from an http:// url, not https://, so out of th ebox it's not really secure
15:51cemerickThat's not where the worst trouble would come from.
15:51amalloycemerick: it's one way
15:52cemerickSure. Not as easy as having a spoofed (but functional) database library that ships all records retrieved to Uzbekistan.
15:52amalloysomeone walks in and pretends to be maven central. they send me poisoned jars, whose signatures i don't really check against public keys because hey, they're from maven
15:52cemerickIt's the random-repo-hosted-on-Google-Code that I'd really worry about.
15:53amalloysure
15:53cemerick(this coming from the guy that blogged about hosting random repos on github) :-P
15:53amalloyhah
15:53amalloywell, i added sun's repo to one of my projects. i hope i'm not going to hell
15:53fliebelIs there anything like deref that would do (deref 1) -> 1
15:54brehautindentity ?
15:54brehaut:P
15:54amalloyfliebel: if you don't mind using amalloy-utils, that function is called (transform-if #(instance? clojure.lang.IDeref %) deref)
15:55fliebelMaybe (keep identity (juxt identity deref) :D
15:55fliebelonly deref throws
15:55amalloyfliebel: hope you like exceptions in that case :P
15:58choffsteincemerick: ech. maybe I don't have maven central set up as a maven repo?
15:58cemerickchoffstein: it's a default repo in both lein and maven
15:58choffsteinwell....crap
15:58cemerickcan you download the artifact directly?
15:58cemerick(i.e. click on the .jar file in the page I linked before)
15:58choffsteinI have http://repo1.maven.org/maven2 as the only maven repo
15:59cemerickyou don't need that, though it shouldn't hurt anything
15:59amalloychoffstein: are you sure that's the jar you're having trouble getting?
15:59choffsteinUnable to resolve artifact: Missing:
15:59choffstein----------
15:59amalloyit might be failing to fetch one of its dependencies; mvn's error messages are hard to read
15:59choffstein1) com.amazonaws:aws-java-sdk:jar:1.1.5
15:59choffsteinWhoops, sorry
15:59Raynescemerick: And cake.
16:00choffsteini'll throw it in a gist
16:00choffsteinhttp://pastebin.com/SbZ9qdwN
16:01cemerickchoffstein: try killing the extra central repo def?
16:02choffstein?
16:02amalloycemerick: extra?
16:02cemerickhe said he had maven central mapped in, perhaps to "central"
16:02cemerickchoffstein: can you paste your project.clj?
16:02amalloyhis gist shows exactly one central repo
16:03choffsteinThis is confusing. It is right there in the repo ... but doesn't want to be downloaded
16:05choffsteinIs it because the repo2 layout is different than what maven is expecting?
16:05amalloyno
16:06amalloyplz take cemerick's advice and paste your project.clj as well just in case there's anything funky there, choffstein
16:06choffsteinOh, didn't see that advice. Sorry
16:06amalloy(too many dang cho- names in here. how can i be expected to tab-complete)
16:07choffsteinhttp://pastebin.com/s850wHpj
16:07choffsteinyfinance, expojure, and smoothing are my own projects
16:07choffsteini installed through "lein install"
16:07cemerickok, so no explicit central repo, that's good
16:10choffsteini'm so confused.
16:11fliebelCan I extend-type for interfaces, or only protocols?
16:12choffstein...this makes no sense what-so-ever.
16:12amalloyfliebel: you can extend protocols to interfaces. not sure i understand the question because i don't think that's what you're asking
16:12cemerickchoffstein: after dropping the references to your personal projects, running lein deps here finishes without a problem.
16:13choffsteincemerick: oh ... let me try that
16:13choffsteinstill fails for me
16:13amalloyfliebel: i see. that should work, yes
16:13cemerickI suspect there's something that's gone pear-shaped in your maven repo's metadata
16:14choffsteincemerick: I suspect that you are right!
16:14amalloybut i don't think you can extend-type for protocols at all, so maybe i still don't get it
16:14cemerickchoffstein: try moving ~/.m2 to e.g. ~/.m3
16:14amalloychoffstein: rm -rf ~/.m2 maybe?
16:14cemerickyou'll need to `lein self-install` again
16:14choffsteinokay
16:14choffsteinheerrreeee we go
16:14amalloycemerick's suggestion is better, of course, but if you never follow the advice of strangers that starts with rm -rf you're a chicken :)
16:15choffsteinI play rm -rf roulette
16:15choffsteinreally keeps work interesting
16:15cemerickblowing away local repos never *really* hurts, it'll just force you to redownload a bunch of stuff again
16:16cemerickI'd always restrict it to ~/.m2/repo, so that settings.xml files and such aren't affected
16:16cemerickchoffstein: speaking of which, have you ever messed with ~/.m2/settings.xml?
16:16choffsteinnot that i'm aware of
16:16cemerickok
16:16amalloycemerick: maybe he downloaded a jar whose project has since been banned by the censors
16:17fliebelamalloy: Well, if I understand things correctly, when I define a protocol, I can use extend-type to make an implementation for an existing type. Can I do the same to interfaces?
16:18fliebelWhat I want to do is make sets support assoc *evil grin*
16:18amalloyfliebel: no. interfaces participate in java's static inheritance hierarchy
16:18fliebelright
16:18choffsteinHerm, I keep getting "bogus chunk size"
16:19choffsteinDownloading: com/amazonaws/aws-java-sdk/1.1.5/aws-java-sdk-1.1.5.jar from central
16:19choffsteinBogus chunk size
16:19cemerickThat's an HTTP chunked output error.
16:19choffsteinmaybe I should change my central repo for maven?
16:19cemerickIs your network wonky?
16:19choffsteincemerick: nope -- everything else downloaded fine
16:20choffsteinevery other dependency was perfect
16:20cemerickwell, you pulled a lot of other deps from central, too, it's not there just for the AWS stuff and such
16:20amalloywow, it's like 1980s surfers are in charge of mvn dependencies: "whoa, gnarly. bogus chunk size, dudes"
16:21cemerickamalloy: that's an IOException message ;-)
16:21amalloyyeah i know
16:22choffsteincemerick: what do you mean? i know I pulled a lot of deps from central -- and they all worked fine
16:22cemerickchoffstein: I mean that you don't want to try to mess with the mapping of the central repo, as it is the source for a lot of foundational stuff.
16:23choffsteincemerick: ah, gotcha. can I add another maven repo though?
16:23cemericksure
16:23choffstein...not that I have ANY idea how to do taht
16:23choffsteinwhat ... the ... hell
16:24choffsteinI don't even have a settings.xml file
16:34fliebelWhy! I defined hashCode on my defrecord, but it gives me a CompilerException java.lang.ClassFormatError: Duplicate method name&signature
16:35hiredmanyou have to use deftype if you want to define hashCode I believe
16:35hiredmanwhy would you do that though? the hashCode impl you get is perfectly fine
16:36fliebelhiredman: But then I lose all my dictatorship, right?
16:36hiredmanfliebel: hmm?
16:36fliebelhiredman: A deftype does not have these dict implementations.
16:36technomancyfor the record, self-installs aren't in ~/.m2 anymore
16:37hiredmanfliebel: correct, why do you want your own hashcode?
16:37fliebelhiredman: Because I want equality to mean a different thing.
16:37gfrlog,(def = not=)
16:37clojurebotDENIED
16:38hiredmanfliebel: but still be a map?
16:38hiredmandon't be silly
16:39fliebelhiredman: well, if I make it a deftype, can I do type/member?
16:40fliebelI don't technically need all the map stuff, as long as I can get to the fields
16:41duncanmnow that i have warn-on-reflection turned on, i noticed that clojure.pprint has a lot of unresolved calls
16:41duncanmis it a goal for the next release to make all APIs that's part of distribution hinted so that everything can be resolved?
16:42hiredmanduncanm: pretty printing shouldn't be done in any performance sensitive code
16:42hiredmancaring about reflection warnings implies caring about performance
16:45choffsteinhow can I add my local maven repo to lein?
16:46dnolenchoffstein: it's already added.
16:46choffsteinHerm. This makes no sense to me. I download the amazon aws jar sdk, install it with maven to my local maven repo, and lein still can't find it
16:50gfrlog,(apply hash-map ((comp reverse flatten) {1 2 8 9 482 3 72 4}))
16:50clojurebot{}
16:50gfrlog,(flatten {1 3})
16:50clojurebot()
16:50gfrlog,(apply hash-map ((comp reverse flatten seq) {1 2 8 9 482 3 72 4}))
16:50clojurebot{2 1, 3 482, 4 72, 9 8}
16:52amalloygfrlog: clojure.walk/walk makes this fairly easy too
16:53amalloy&(do (use 'clojure.walk) (walk (comp vec reverse) identity {1 2 8 9 482 3 72 4}))
16:53sexpbot⟹ {2 1, 9 8, 3 482, 4 72}
16:53gfrlogwoah; it walks maps?
16:53amalloy&(doc walk)
16:53sexpbot⟹ "([inner outer form]); Traverses form, an arbitrary data structure. inner and outer are functions. Applies inner to each element of form, building up a data structure of the same type, then applies outer to the result. Recognizes all Clojure data structures except so... http://gist.github.com/891243
16:54gfrlogexcept so... except so many of them?
16:54amalloy*eyeroll* feel free to follow the gist link. it says sorted-foo-by
16:55gfrlogI know :)
16:55gfrlogamalloy: wouldn't it be great if repl languages did that with stack traces?
16:55gfrlog(the truncate-with-gist tactic)
16:55gfrlogI don't know how much of my life I've wasted scrolling up a stack trace
16:56amalloyi'm still a bit puzzled as to why walk is implemented as it is. it seems like it could be rewritten, and also support sorted-foo-by, to basically (outer (into (empty coll) (map inner coll)))
17:05mecwould postwalk and prewalk still work with that?
17:06phenom_hey, anyone famliar with yourkit profiler ?
17:07amalloymec: of course; my goal is to not change the output of walk in any noticeable way
17:07amalloyclojurebot: anyone?
17:07clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
17:07mattmitchellhow do you check if a var has been bound to something?
17:08amalloy&(let [outer identity, inner (comp vec reverse) coll {1 2 8 9 482 3 72 4}] (outer (into (empty coll) (map inner coll))))
17:08sexpbot⟹ {2 1, 9 8, 3 482, 4 72}
17:08amalloymattmitchell: bound?, i think
17:09mattmitchellamalloy: that's it thanks :)
17:12phenom_argh, trying to debug but in YourKit the stack trace shows Thread.run() as 99% of CPU then the next step below is my function myns.myfunc as 33% !!!! where did tht 66% of time go !?!!?
17:13mecHow do I truncate a number to int?
17:13dnolenphenom_: you can tell YourKit to ignore methods.
17:14dnolen,(int 4.3333)
17:14clojurebot4
17:14phenom_dnolen: I want it to include more ... i seem to be missing functions that use up 66%, they dont show up
17:14mec,(int 4023233417)
17:14clojurebotjava.lang.ExceptionInInitializerError
17:26krlis there any way to have cyclical references between namespaces?
17:27nickikno i dont think so.
17:28krlis it really so strange?
17:29nickikI don't know of any language where it is possible, do you?
17:29amalloynickik: a lot of languages
17:30krlcommon lisp
17:30amalloyjava
17:30phenom_anyone know how to fix the issue I'm having with my agent pool? the wait/run cycle looks like it's not making optimum use of the pool: http://imgbin.org/index.php?page=image&amp;id=3700
17:30amalloyi don't mind that clojure doesn't allow it, actually; it's a feature that can lead to messiness and wooly thinking
17:32krli'm not sure if that merits banning it on non-technical grounds though. is it something in clojures design that really does not work with it, it can be fine. but yeah
17:32krli guess i'll have to see if i can break something out instead
17:32nickikamalloy, thx didn't no that because im avoiding it since I had the problem in C++
17:34amalloynickik: works fine in c++ too. declare everything in headers, then implement it all in one big soupy mess
17:35amalloykrl: it could be made to work, but it would have repercussions
17:40krlproblem is that you don't really notice building circular stuff when using slime, since it seems to work fine until you try to reload the project
17:53waxroseehh... I wonder why Joy of Clojure didn't get released to B&N today..
18:01amalloygfrlog: please forgive me the following pedantry: "peruse" means the opposite of "browse". it means "to study thoroughly and in depth"
18:02waxrose:P
18:02gfrlogamalloy: I cannot forgive. Only thank.
18:03gfrlogI should point out however, that my use has a plausible interpretation
18:03amalloyit does
18:03gfrlog$google wiktionary peruse
18:03sexpbotFirst out of 379 results is: peruse - Wiktionary
18:03sexpbothttp://en.wiktionary.org/wiki/peruse
18:04amalloyin practice if i attack 100% of uses of the word peruse i have a 98% hit rate, so actually reading the usages is statistically a waste of time
18:04gfrlogamalloy: note wiktionary's definition #3 ;-)
18:05gfrlogwhat if computer languages were like human languages: misusing a function enough times changes its behavior
18:06amalloygfrlog: that's because everyone on the internet is dumb :P. try something that can't be edited by some guy who realized that the "right" meaning still isn't in wiktionary
18:06kephale00gfrlog: thats what ai techniques are for
18:06amalloyi'm happy to see that a google search for "define: peruse" does very well, at least
18:06amalloyevery use but wiktionary gets it right
18:07gfrlogkephale00: very good
18:07gfrlogamalloy: http://www.merriam-webster.com/dictionary/peruse
18:07gfrlog1b
18:08amalloysad
18:08gfrlogyou must be a prescriptivist
18:08amalloywait wtf does 2 even mean
18:08amalloy"especially, to read attentively or leisurely"
18:08amalloygfrlog: it's true, i am
18:08amalloyi sympathize with some non-prescriptive usages of things
18:09gfrlogamalloy: you oughta be put on an episode of "Scared Straight by Linguists"
18:13amalloygfrlog: they would dig up dirt to discredit me
18:14amalloythey would find out that i grew up saying "on accident" instead of "by accident" (by analogy with on purpose, apparently)
18:15gfrlogbet you don't like ending sentences prepositions with
18:15amalloymeh
18:16amalloyevery so often i make the effort, but there's no real reason to disallow it. unlike "using words to mean the opposite of what they mean", it doesn't hinder communication
18:16gfrlog:) how about 'cleave'?
18:18amalloygood word
18:20gfrlog,(= [3] #{3})
18:20clojurebotfalse
18:20gfrlog,(= [3] '(3))
18:20clojurebottrue
18:21gfrlog(= #{3} '(3))
18:21gfrlog,(= #{3} '(3))
18:21clojurebotfalse
18:21gfrlogI guess it makes sense
18:24amalloy&(map sequential? ((juxt set list* vec) [3]))
18:24sexpbot⟹ (false true true)
18:32gfrlog(doc list*)
18:32clojurebot"([args] [a args] [a b args] [a b c args] [a b c d & more]); Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."
18:32gfrlogcouldn't bother to name that list-but-where-the-last-one-is-a-seq ?
18:34amalloygfrlog: feel free to use ##(apply list [1]) instead
18:34sexpbot⟹ (1)
18:34gfrloglist* is kind of like a general version of cons
18:34amalloymhm
18:34gfrlogI guess the grandpa lispers would riot if the meaning of cons was changed though
18:34amalloygfrlog: it already has been
18:35gfrlogdangit where did I put my torch?
18:35gfrlogamalloy: to what do you refer?
18:35amalloy(cons 1 2) is allowed in...every lisp but clojure afaik
18:35gfrlogah
18:35gfrlogfunny I hadn't tried that
18:36amalloygfrlog: cons doesn't create pairs in clojure like in every other lisp: it creates a seq
18:36amalloyso there's no "convention" of "a series of pairs ending in nil is a seq"
18:38gfrlogis the 'seq' concept particular to clojure?
18:38brehaut,(type (cons 1 2))
18:38clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
18:38brehaut,(type (cons 1 ())
18:38clojurebotEOF while reading
18:39brehaut,(type (cons 1 ()))
18:39clojurebotclojure.lang.Cons
18:39gfrlog,(type (cons 1 nil))
18:39clojurebotclojure.lang.PersistentList
18:40gfrlog\[({})]/ is the syntax for an empty finger-tree, right?
18:41gfrlog,[({})]
18:41clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentArrayMap
18:42gfrlog,[({},,\,)],
18:42clojurebot[nil]
18:42gfrlog,[({}{})]
18:42clojurebot[nil]
18:44amalloybrehaut: you may be unaware, but sexpbot will fix mismatched parens for you :)
18:44brehautamalloy: really? thats amazing!
18:45amalloygfrlog: i think clojure takes it in a different direction than other lisps
18:45brehaut&(type (cons 1 ())
18:45sexpbot⟹ clojure.lang.Cons ; Adjusted to (type (cons 1 ()))
18:45brehautwow
18:45Raynesbrehaut: You don't write code for sexpbot and then run off and use clojurebot. It's like a deal with the devil. You go back on it, and he gets your soul.
18:46amalloyRaynes: well, he specifically wrote *that* code, is the joke
18:46brehautRaynes: its the seductive power of Arrows!
18:46Raynesamalloy: I got the joke.
18:46gfrlogRaynes: amalloy: when are either of you going to remove sexpbot's arrow so we can trampoline-quine the bots?
18:46amalloyRaynes: the channel as a whole probably didn't, in which case you come off sounding like a wacko zealot for real instead of as a joke
18:47amalloygfrlog: put that on the list of bugs to add
18:47Raynesamalloy: I don't have to say anything special to achieve that.
18:47Raynesgfrlog: Nevers.
18:48gfrlogRaynes: okay well then hack into clojurebot and get it to respond to the arrow
18:48RaynesI am taking suggestions for a better arrow though. Tired of complaints about it not rendering well in people's ugly fonts.
18:48gfrlogRaynes: commas make good arrows
18:48Raynes:)
18:49gfrlogevery time I see a comma I have to figure out what it's pointing at
18:49gfrlogit's real distracting
18:49spewnRaynes: What's the argument against the classic "->"?
18:49amalloyspewn: c'mon all the cool kids are doing unicode
18:49brehautgfrlog: just FYI i was talking about arrows as per github.com/jduey/conduit
18:49gfrlog,(let [-> :arrow] ->)
18:49clojurebot:arrow
18:50technomancyclojurebot: arrows?
18:50clojurebotarrows is http://ro-che.info/ccc/12.html
18:50RaynesIt's two characters and isn't unicode.
18:50amalloyRaynes: well. it's clearly unicode
18:50spewnI thought that was part of the problem ("not rendering well in people's ugly fonts").
18:51gfrlogpresumably he thinks there is another character in unicode that renders better. Good luck finding another unicode character. I think it's just that arrow and nothing else.
18:52amalloy&(map char (repeatedly 4 #(rand-int 0x0800 0xefff)))
18:52sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$rand-int
18:52Raynesgfrlog: There are like a million unicode arrows.
18:53RaynesSome long, some short, some wide, some thin.
18:53RaynesThis arrow is supposedly 'long', but it renders short in my font.
18:53Raynesamalloy: We still haven't fixed the logs so that the arrow shows up properly, have we?
18:53gfrlogRaynes: I've actually spent an above average amount of time staring at unicode arrows. I wasn't satisfied.
18:54Raynesamalloy: ##(doc rand-int)
18:54sexpbot⟹ "([n]); Returns a random integer between 0 (inclusive) and n (exclusive)."
18:55RaynesChirp.
18:55gfrlog&(map char (repeatedly 20 #(+ 0x0800 (rand-int (- 0xefff 0x0800)))))
18:55sexpbotjava.lang.NullPointerException
18:56RaynesOh, wow, lag.
18:56RaynesI think I've broke my internet.
18:56amalloynull pointer? that's a weird one to get
18:57__name__I blame Oracle.
18:57gfrlogI don't think the unicode space is all filled in
18:58gfrlog&(map char (take 20 (filter identity (repeatedly (try (+ 0x0800 (rand-int (- 0xefff 0x0800))) (catch Exception e nil
18:58sexpbotjava.lang.SecurityException: You tripped the alarm! catch is bad!
18:59gfrlogBAH
18:59RaynesDENIED
18:59gfrlogis there a built in fn for swallowing exceptions?
19:00amalloygfrlog: having unicode be "not all filled in" wouldn't give an NPE
19:00gfrlogamalloy: then what should calling char on an invalid integer return?
19:00amalloyfurthermore it's so filled in that it doesn't all fit in the two bytes java allocated for it
19:01amalloygfrlog: there is no such thing as an invalid integer. it returns a Character object representing that integer. if its name is NOT_FILLED_IN and your irc client can't render the glyph associated with it, why does java care?
19:01amalloy&(char 0xf555)
19:01sexpbot⟹ \
19:02CozeyHello. If i have a vector in an atom X, which itself contains atoms Yi, is it safe to modify them with (swap! X (fn [yi] (swap! yi .... )) ? Docs say swap! functions should not have side effects, but inner swap! yi would be a side effect. am I right? Is this a job for refs and dosync?
19:02gfrlogamalloy: I guess it doesn't
19:02amalloyCozey: uh, if you really want to do it then yes, use refs. srsly though don't put atoms inside atoms
19:03amalloy(or refs inside refs, or refs inside atoms, or...)
19:03gfrlogI keep my atoms inside refs of agents
19:03Cozey:-)
19:03gfrlog,(atom {(ref (agent)) (agent (ref))})
19:03clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$agent
19:04gfrlog,(atom {(ref (agent (var agent))) (agent (ref (var ref)))})
19:04clojurebot#<Atom@59bb55: {#<Ref@1545a38: #<Agent@3483ec: #'clojure.core/agent>> #<Agent@1c119d5: #<Ref@86fd2f: #'clojure.core/ref>>}>
19:05gfrlogI encode all my data in a form of binary where 0 is represented as the empty set, and 1 is represented as that structure up there
19:05amalloygfrlog: i'm starting to get the idea i should stop asking you about Best Practices
19:06gfrlogit's okay, I wrap it all in a try-catch
19:06amalloywell played
19:06gfrlog:)
19:32choffsteincemerick: you around? I have a question about rummage (and maybe SimpleDB)
19:44gfrlog&((({{}{}}{}{}){}{}){}{})
19:44sexpbot⟹ {}
19:46flying_sheepHi, how should I print a lazy-seq to stdout, and format it?
19:47gfrlog,(prn (map inc (range 10)))
19:47clojurebot(1 2 3 4 5 6 7 8 9 10)
19:47flying_sheepI use doseq to materialize the lazy-seq, but then I don't know how to format the output
19:47kephale00you might want pprint too
19:47gfrlogyeah I was going to say that
19:47flying_sheepoooo shiny ...
19:53TimMcgfrlog: Woah, I had no idea maps had an arity-2 invoke as well!
19:53pdk({1 2} 3 :hi)
19:53pdk,({1 2} 3 :hi)
19:53clojurebot:hi
19:53pdkBRILLIANT
19:54TimMcTHIS CHANGES EVERYTHING
19:54pdk,(#{1 2} 3)
19:54clojurebotnil
19:54pdk,(#{1 2} 3 :hi)
19:54clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentHashSet
19:54pdksets gotta spoil all the fun
19:55TimMc,({5 nil} 5 6)
19:55clojurebotnil
19:55TimMcexcellent
19:55TimMc,({5 nil} 'a)
19:55clojurebotnil
19:56pdkactually yknow
19:56pdki never looked into whether vecs have a getter syntax like this
19:56pdk,([1 2 3] 1)
19:56clojurebot2
19:56pdk\o/
19:56pdki'll assume () lists don't
19:57pdkthough either way
19:57pdki don't see why sets wouldn't
19:58TimMc,([0 1 2] 3 7)
19:58clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentVector
19:59pdkconclusion
19:59pdkmaps = daddy's favorite collections!
20:05amalloypdk: keywords and symbols too
20:05amalloy&(:foo {:bar 10} 20)
20:05sexpbot⟹ 20
20:05amalloy&(:foo #{:bar 10} 20)
20:05sexpbot⟹ 20
20:05pdkwhat do we make of the keyword/symbol examples
20:05amalloyso you don't need the set one :P
20:05pdkoh yeah
20:06pdkpoor sets don't get to be at the front of forms
20:06pdk,([1 2 3 #{4}] #{4})
20:06clojurebotjava.lang.IllegalArgumentException: Key must be integer
20:06pdkwait no
20:06pdk,({1 2 3 #{4}} #{4})
20:06clojurebotnil
20:06amalloystill not a set at the front :P
20:07pdk,(#{1 2 3 #{4}} #{4})
20:07clojurebot#{4}
20:07pdk,(#{4} #{1 2 3 #{4}})
20:07clojurebotnil
20:07pdkwelp
20:10amalloy&(instance? clojure.lang.IAssoc #{})
20:10sexpbotjava.lang.ClassNotFoundException: clojure.lang.IAssoc
20:10amalloy&(instance? clojure.lang.ILookup #{})
20:10sexpbot⟹ false
20:10clojurebotI don't understand.
20:25mecHow could I do a variable partition such that: (partition [1 2 3 4 5 6 7 8 9] [1 2 3 2 1]) -> [[1] [2 3] [4 5 6] [7 8] [9])
20:26brehautmec the second vector describes the partition sizes?
20:26mecbrehaut: correct
20:27brehautthat should be the first argument i think
20:27brehaut(the rest of the partition family (like all the seq fns) take the sequence as the last argument
20:27mecok
20:28mecI'm thinking some way to iterate split-at would work, but im not sure how to do that
20:29brehautunfold would be perfect
20:33tomojwould it?
20:34tomojwith a fn of type ([a], [Int]) -> Maybe ([a], [Int])?
20:34tomojer
20:34brehautyes
20:34mechttps://gist.github.com/891606
20:34tomoj([a], [Int]) -> Maybe ([a], ([a], [Int]))
20:34mechows that look?
20:35tomojtoo eager
20:36mechmm
20:37brehautTBH i think i would write it wilth lazy-seq and recur
20:37hiredmanrecur?
20:38brehauttail recursive function?
20:38hiredmanmixing recur and lazy-seq just strikes as odd
20:38brehautoh yeah. duh. excuse my brain failure
20:38mecok i think i got it
20:39mechttps://gist.github.com/891606 thats almost beautiful
20:40mechmm I should probably limit it on both of them
20:41mecis there a better way than using 2 when-lets?
20:42brehautmaybe-m or -?> ?
20:43brehautim not convinced they payoff till you hit 3 or 4 when-lets though
20:43mecso just use 2?
20:43brehautyeah
20:43tomoj:/ ##(->> [1 2 3 2 1] (reductions (fn [[_ coll] part] (split-at part coll)) [nil (range 10)]) next (map first) (take-while identity))
20:43sexpbot⟹ ((0) (1 2) (3 4 5) (6 7) (8))
20:44tomojshould be (take-while seq)
20:44brehaut,'do-monad
20:44clojurebotdo-monad
20:44brehautnot what i meant
20:44brehaut,#'do-monad
20:44clojurebotjava.lang.Exception: Unable to resolve var: do-monad in this context
20:45brehaut,#'domonad
20:45clojurebotjava.lang.Exception: Unable to resolve var: domonad in this context
20:45brehaut,(use 'clojure.contrib.monads)
20:45clojurebotnil
20:45brehautthe following is why maybe-m is overkill:
20:45brehaut,(macroexpand '(domonad maybe-m [a (when true 1) b (inc a)] (inc b)))
20:46clojurebot(let* [name__2462__auto__ maybe-m m-bind (:m-bind name__2462__auto__) m-result (:m-result name__2462__auto__) m-zero (:m-zero name__2462__auto__) m-plus (:m-plus name__2462__auto__)] (clojure.contrib.macro-utils/with-symbol-macros (m-bind (when true 1) (fn [a] (m-bind # #)))))
20:47brehautmec: ie it explodes in complexity and nested calls
20:47waxrose-_-
20:47mecya im just using a let and a when :D
20:48mectomoj: oh i completely forgot about reductions
20:50tomojbrehaut: is that just an ugly version of unfold?
20:51tomojkind of interesting if unfold is the intermediate steps of a fold
20:51clojurebotIk begrijp
20:51mectomoj: maybe-m is like nil safe threading
20:51tomojI meant my reductions thing above
20:53mecI believe so
20:58mecok which looks best https://gist.github.com/891606
21:00amalloymec: i like the second, but it's not lazy
21:01brehauttomoj: sorry, is what the ugly version of unfold?
21:03brehauttomoj: oh right. yeah roughly
21:09amalloytomoj: https://gist.github.com/805583 is my unfold, if you'd like to compare
21:18mecI cant get partitions to work using unfold
21:23gfrlog$findfn #{3 4} 4 #{3}
21:23sexpbot[clojure.core/disj]
21:23gfrlog$findfn [3 4] 4 [3]
21:23sexpbot[]
21:24gfrlogconj has no inverse
21:24mecoh whats the complement of every?
21:24gfrlognot-any?
21:24amalloynot-any?
21:24gfrlog$findfn [3 4] [3]
21:24sexpbot[clojure.core/butlast clojure.core/drop-last clojure.core/pop]
21:25mecamalloy: using your fold, this is only returning the first 4: https://gist.github.com/891606
21:26amalloywhat do you mean, the first four?
21:27mec((1) (2 3) (4 5 6) (7 8)) instead of ((1) (2 3) (4 5 6) (7 8) (9))
21:28amalloyhm, my version is doing that too, now that i've stopped writing it stupidly
21:29gfrlog(group-by #(apply + %) '((1) (2 3) (4 5 6) (7 8) (9)))
21:29brehautmec, you can define partitions as (comp (partial unfold ...) vector) ;)
21:29brehautamalloy: likewise
21:30mechuh?
21:30amalloyhe thinks it's undignified to build vectors by hand. don't listen to him
21:30mecah i see
21:30brehaut(def partitions (comp (partial unfold (fn [[[n & sizes] coll]] [(take n coll) [sizes (drop n coll)]]) (partial not-any? seq)) vector))
21:31mecstill truncates the last value :D
21:31brehautmec yeah it does :(
21:31mecI think that has to do with the test
21:32amalloyi wrote my test as (comp empty? second)
21:32amalloysame problem
21:32amalloy(cause i have mine in the other order)
21:35amalloymec: confirmed it's either a problem with unfold or with the test, though; using (constantly false) as the done? test and then taking 5 works
21:36mecthats what I was thinking would have to be done
21:36amalloymec: it looks like a problem with my unfold, now that i look at it
21:37mecIt's weird, because I've used your unfold perfectly fine before
21:38amalloymec: i think the issue is that (next the-seed) returns a pair, [data new-seed], okay? then the take-while checks to see that new-seed has no more data, so it doesn't include even that data element
21:38amalloyi think i should just rewrite unfold with raw lazy-seq; it'll probably be more readable as well as more reliable
21:39mectrue, I do like the partitions with lazy-seq the best
21:39mecIt's easiest to understand, tho I'm working on a when-lets macro for it :D
21:41cgrayhi, in compojure, how does one alter the session? do you treat it like a ref?
21:41amalloymec: the lazy-seq version of unfold, predictably, was trivial to write and works properly
21:41amalloyone sec and i'll amend the gist
21:43amalloyhttps://gist.github.com/805583 has a more-working unfold now
21:44mecvery nice. How do you determine where lazy-seq should go?
21:48amalloymec: pretty much always as far in-front as you can fit it
21:51amalloymec: basically when i'm writing a lazy-seq function it usually looks like (defn foo [foo bar baz] ((fn foo* [arg more-args] (lazy-seq ...)) (some intitial args from foo bar baz)))
21:51mecok
21:55tomojah, i
21:55tomojer. I wouldn't have guessed unfold would need the extra param
21:55amalloytomoj: which extra param?
21:55tomojnext and done? because no Maybe
21:56amalloyyeah
21:56tomojnever thought much about how type clutter can reduce code clutter
22:05cgrayanyone use ring's session middleware with compojure? I'm having trouble figuring it out...
22:05mechow does this look: when-lets https://gist.github.com/891691
22:08amalloymec: when-lets looks like it should be implemented using reduce
22:08kumarshantanuhi, given a vector [:a :b :c :d :e] how can i replace 2nd element with :Z so that the result becomes [:a :Z :c :d :e] ?
22:08mecI'm a total noob at macros, I'm amazed I got it working at all, I'm not sure how to do that
22:09amalloy&(assoc [1 2 3 4] 1 :Z)
22:09sexpbot⟹ [1 :Z 3 4]
22:09kumarshantanuamalloy: thanks!
22:11mecamalloy: ok I think I have an idea
22:11amalloy(reduce (fn [acc tstform] `(when-let ~tstform ~acc)) (reverse bindings)) looks like a good sketch
22:13no_mindI am confused about use of apply , when should one use apply and when should you rely on looping constructs ?
22:14mecuse apply when the function supports it
22:15amalloyno_mind: yeah, they're different things entirely
22:15amalloymec: https://gist.github.com/891697
22:16no_mindamalloy, ok, someone explain me apply then
22:16amalloyno_mind: more specifically, apply is for calling functions when you have an argument list instead of a bunch of arguments
22:16amalloymap is a looping-like function for calling some function on each element of a sequence
22:16amalloymec: your version may actually be easier to follow and/or better
22:17amalloybut it seemed like basically a reduce so i wrote it up as one
22:17mechow about this one https://gist.github.com/891691
22:18amalloyugh do not use 'when-let in a macro. the user might have excluded clojure.core from his refers, or given it a different alias
22:18amalloysyntax-quote takes care of it for you
22:18amalloyat least use `when-let
22:19amalloy(it's safe with 'do, because that's a special form, but maybe i shouldn't anyway)
22:20amalloybut otherwise sure, looks like a good way to expand, haha, your macro experience
22:20mecoh ok, would (fn [acc formtst] `(when-let ~formtst ~@acc)) work
22:21amalloymec: it would, but then you need to turn formtst into a vector, which is why mine has map vec
22:21mecya I did that initially
22:21amalloymaybe `(when-let ~(vec formtst))
22:23amalloymec: https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils/macro.clj has some stuff like this
22:24mecamalloy: thanks
22:25amalloyi guess i should promote unfold into amalloy-utils now that amalloy-utils exists :P
22:26gfrlogamalloy: short name: auts
22:26amalloywhat, and risk letting people forget my name?
22:26gfrlogyollama
22:27gfrlogah that's where you got it from
22:27no_mindamalloy, I have an argument list (a map) and I want to call a function on the whole list but one element (a map key) How do I do it. To be more precise I am calling function like (apply set-attr (apply concat value)) where value is a map. For a given requirement, I want to pass all but one keys of the map can I do this without removing the key from map ?
22:28gfrlogno_mind: maps are immutable, so it's okay to remove something from them
22:29mec(apply set-attr (apply concat (dissoc value bad-key))
22:30gfrlogyep
22:30gfrlog(the original map still has the key in it)
22:53pdkno_mind clojure's basic data types/collections are all immutable and persistent
22:54pdkif you do an operation on them you just get a copy with the changes applied, the original is still there as long as you have a reference to it
22:58amalloybrehaut: i've found myself wanting foldr twice in the last week or two. never thought i'd want a fold that could blow the stack, but for use in creating macroexpansions it's not such a big deal
23:03chouseramalloy: that's really interesting.
23:05chouseramalloy: you've written foldr?
23:11chouserI'd be awfully tempted to pour the data into a vector first.
23:14chouserHm, I suppose 'reverse' would be sufficient.
23:23Guest51360I want to destructure a value of a map within a map.. so I tried this in a let: {name :name, unit #(:unit (:quantity %))} but that doesn't seem to work (I thought maybe the destructuring bind was expecting a function of a single argument). Any thought on that ?
23:24brehautGuest51360: the LHS of a destructuring expression has to be all literals
23:25brehautyou'd need to break out the computation into a separate binding in the let.
23:25dnolen,(let [{{bar :bar} :foo} {:foo {:bar 'baz}}] bar)
23:25clojurebotbaz
23:26waxroseeeh
23:27@chouser& user=> (let [{name :name, {unit :unit} :quantity} {:name "foo", :quantity {:unit "meters"}}] [name unit])
23:27sexpbotjava.lang.Exception: Unable to resolve symbol: user=> in this context
23:27@chousersorry. ## (let [{name :name, {unit :unit} :quantity} {:name "foo", :quantity {:unit "meters"}}] [name unit])
23:27sexpbot⟹ ["foo" "meters"]
23:27@chouserjust like dnolen said. :-)
23:28Guest51360nice, thanks all
23:37simardwhat is the idiomatic way of naming function arguments that expect a struct of some kind ?
23:38amalloysimard: name them something that describes what they're used for, like anything else :P
23:39amalloyor if you want to be explicit about what keys they'll have, destructure them in the arglists directly: (fn [{:keys [year month date]}] ...)
23:48jweiss_is there a way to do "if f throws Exception return x otherwise return whatever f returns" without using an atom?
23:49jweiss_or i suppose just a plain elegant way
23:50amalloywell, not an especially elegant way
23:50brehautjweiss: ##[(try (/ 1 1) (catch Exception e :boom)) (try (/ 1 0) (catch Exception e :boom))]
23:50sexpbotjava.lang.SecurityException: You tripped the alarm! catch is bad!
23:50brehautle sigh
23:51brehaut,(try (/ 1 0) (catch Exception e :boom))
23:51clojurebotbrehaut: excusez-moi
23:51amalloybrehaut: they don't like catch, for good reason
23:51brehautreally?
23:51brehautwhy?
23:51clojurebothttp://clojure.org/rationale
23:51brehautthanks clojurebot
23:51jweiss_lol
23:51amalloybrehaut: imagine they caught the timeout/interruption exception
23:51amalloy&(loop [] (recur))
23:52amalloyinside of that loop
23:52brehauti hadnt realised that would have come from within the evaluated expression
23:52sexpbotExecution Timed Out!
23:52amalloyit has to
23:52amalloysorta :P
23:54brehautjweiss: anyway, i dont understand what you want that isnt handled by try catch
23:54jweiss_brehaut: maybe i'm confusing this use-case with a different one