#clojure logs

2011-03-17

00:00rata_I've used visualvm to detect the bottleneck... and it was that fn... but didn't know how to check if reflection was a bottleneck for that fn
00:01technomancyyou should see a lot of clojure.lang.Reflector frames in the traces I think
00:02technomancythat code looks unlikely to reflect a lot since it doesn't look like it makes any Java method calls. pure Clojure shouldn't reflect.
00:03amalloyrata_: i doubt it will make a difference, but you could pull the multiplication from the inner loop up into the outer one, with (apply * rate (mapcat (fn [[mol freq]] [(get-molecule state mol) freq]) lhs))
00:03amalloythat would probably reduce the amount of boxing and unboxing you do, since you call * in fewer places
00:03technomancyone thing you could do is switch to primitive math, another would be to use a transient map.
00:04technomancyyou could also replace for with reduce to avoid laziness overhead
00:04rata_how do I switch to primitive math in 1.2? or should I move to 1.3?
00:05technomancy1.3 is only needed if you need your primitives to cross function boundaries
00:06rata_ok, I think this is not the case
00:06rata_then how do I use primitive math inside that fn?
00:07amalloy&(doc unchecked-add)
00:07sexpbot⟹ "([x y]); Returns the sum of x and y, both int or long. Note - uses a primitive operator subject to overflow."
00:07amalloy&(doc int)
00:07sexpbot⟹ "([x]); Coerce to int"
00:07rata_&(doc long)
00:07sexpbot⟹ "([x]); Coerce to long"
00:08rata_perfect, so it should be (apply unchecked-math (long rate) (map long (mapcat ... lhs)))?
00:09rata_or does that (map long ...) won't work?
00:09symboleDo clojure projects use the Spring framework in any extensive way?
00:10amalloyrata_: you'll lose the casting if you map it to long - it'll just be boxed it back up into a Seq full of Longs
00:10amalloythat would probably just make it slower
00:12scottjsymbole: not unless they have to, from what I've seen
00:12technomancysymbole: never heard of anyone using Spring with clojure
00:12amalloyi don't have much experience with primitive optimization though so take my advice with a lot of skepticism here
00:15rata_hmmm... then (unchecked-multiply (long rate) (reduce (fn [result [mol freq]] (unchecked-multiply (long result) (unchecked-multiply (long (get-molecule state mol)) (long freq)))) 1 lhs))
00:16rata_it'll anyway do some boxing and unboxing
00:18rata_amalloy: are the math fns you mentioned before, those that throw an error when overflow, present in 1.2?
00:18amalloyi don't think so
00:18rata_ok
00:19rata_and does anyone know when 1.3 will be beta or stable?
00:22amalloyrata_: fwiw i just tried (reduce * (range 2 50)) and (reduce unchecked-multiply (map long (range 2 50)))
00:22amalloyunchecked-multiply is a bazillion times slower due to all the boxing
00:23amalloyclarify: it's a lot slower, and *i* think it's cause of the boxing
00:23sproustnrepl.el is born (5 minutes ago).
00:24amalloysproust: neat
00:25rata_amalloy: so maybe using unchecked-math before 1.3 is pointless?
00:25sproustJust mucking around with the protocol at this point.
00:26amalloyrata_: no, it's certainly faster in the right circumstances. i think this example would have the same behavior in 1.3
00:27rata_it shouldn't, because 1.3 doesn't box automatically, does it?
00:27technomancyrata_: 1.3 allows you to write functions that don't box their args
00:28rata_ok
00:28rata_I imagine that'd be very useful here
00:28amalloybut reduce will still have to box at every step, no?
00:29amalloybut would apply * work?
00:31rata_amalloy: you could write your own reduce that doesn't box
00:31amalloyyes
00:31rata_but I don't know if apply or reduce won't box by default
00:32rata_in fact, I know very little about 1.3 features =P
00:35scottjis there a function you can call on x to see if it's a boxed or unboxed long?
00:36tomojfunctions box their args (at least in 1.2)
00:37scottjsorry, in 1.3
00:40amalloyisn't there a function somewhere to tell you what the compiler thinks of a sexp?
00:41amalloyi've seen chouser using it, and that's more or less the only way i can think of that you could use to see whether something is being treated as primitive
01:10dsantiagoIf you call seq on a map, you get a seq of vectors of key/value pairs. Is there a function to get a map back from that?
01:11tomojthere's into
01:12tomojthey're actually MapEntrys
01:12tomoj&(key [1 2])
01:12sexpbotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
01:12tomoj&(key (first {1 2}))
01:12sexpbot⟹ 1
01:13tomojbut into will work with vectors too
01:19amalloyugh. i've been trying to figure out how to get the compiler to analyze an expr for me. i've gotten as far as finding clojure.lang.Compiler$LetExpr$Parser, which *seems* to have a no-arg constructor, but if i try ##(clojure.lang.Compiler$LetExpr$Parser.) it doesn't work
01:19sexpbotjava.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.Compiler$LetExpr$Parser
01:20amalloycan anyone see why? Compiler.java has "new LetExpr.Parser()" in a scope that's not closing around anything, and LetExpr is a static inner class
01:21dsantiagotomoj, thanks! I knew about into, but didn't realize it did that.
01:22tomojweird: ##(->> (range (* x 10) (* (inc x) 10)) (partition 2) (map vec) (into {}) (for [x (range 10)]) (into {}))
01:22sexpbotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$for
01:22tomojhmm
01:22tomojwell, that was a terrible way to illustrate the weirdness anyway
01:23hiredmanamalloy: I thing there is a static analyze method on Compiler, I would see what that does
01:23amalloytomoj: (for (big-old-expr) [x (range 10)] (into))...
01:23tomojamalloy: works fine for me here
01:23amalloyhiredman: i couldn't figure out how to get an Expr object to pass it
01:23tomoj,(->> (range (* x 10) (* (inc x) 10)) (partition 2) (map vec) (into {}) (for [x (range 10)]) (into {}))
01:23clojurebot{0 1, 32 33, 64 65, 96 97, 2 3, 34 35, 66 67, 98 99, 4 5, 36 37, ...}
01:24tomoj&(conj {} (map first [{1 2} {3 4} {5 6}]))
01:24sexpbot⟹ {5 6, 3 4, 1 2}
01:24tomojthat's the weirdness
01:25tomojso that (into {} s) where s is a seq of seqs of MapEntrys works, strangely
01:25hiredmanamalloy: you can use the specials map near the top to get a Parser object for a given special form, then call .parse
01:25amalloyoh of course. why make my own when there's one right there. thanks
01:26tomojamalloy: maybe the default constructor is not public?
01:26amalloytomoj: it is though. none is specified at all
01:26tomojright, those are public?
01:27tomojseems its supposed to be the same as the class
01:27tomojand the class isn't public
01:28tomoj..or does that nested class inherit public from LetExpr? brings back bad memories of the java cert test
01:29tomoj&(into {} [{1 2} {3 4}])
01:29sexpbot⟹ {1 2, 3 4}
01:29tomojmaybe that's why it works?
01:30amalloy,(.parse (get Compiler/specials 'let*) nil '([x 1] (long x)))
01:30clojurebotjava.lang.IllegalArgumentException: Bad binding form, expected vector
01:35amalloy,(.parse (get Compiler/specials 'let*) nil '(let [x 1] (long x)))
01:35clojurebotjava.lang.NullPointerException
01:50amalloydevn: what?
01:52rata_amalloy: it got better =) 65% now with mapcat and just one *
01:52amalloyhey cool. never would have guessed my suggestion was any good, there
01:55rata_I'll try with reduce as well, but now it's time to sleep
01:55rata_thank you amalloy =)
01:56metadaddy1Anyone having problems with ring/ring-httpcore-adapter 0.3.7?
01:56metadaddy1I was using it fine yesterday, now lein deps fails w a maven error
01:56rata_I hope I get that fn to run fast, I think it shouldn't use more than 20% of the time
01:57metadaddy1and it's missing from http://clojars.org/repo/ring/ring-httpcore-adapter/
01:57rata_but maybe I'm too optimistic
01:57rata_see you guys, good night
01:57metadaddy1http://clojars.org/repo/ring/ring-jetty-adapter/0.3.7/ is there
02:10dnolenbrehaut: there you go, https://github.com/swannodette/bratko-logos/blob/master/src/bratko_logos/monkey_banana.clj in 18 lines of Clojure.
02:10brehautdnolen: that is very nice
02:11dnolennow sleep
02:12brehautdnolen: ive been pondering the existance of the move type symbols; are they strictly necessary? seems to me they only exist to clarify it for the humans
02:12brehautdnolan: gnight
02:36metadaddy1figured it out, I think
02:56letronjehad a n00b doubt
02:56waxrosecabalamalloy, Does lein actually install 1.3 and swank-clojure or is it just for dependencies?
02:56letronje(defn test [n] (do (println "\ntrying " n "\n") (> n 2)))
02:56letronje(first (filter test [1 2 3 4 5 6 7 8 9 10]))
02:57letronjeif filter is lazy, why does it go through the entire the vector after it finds 3 ?
02:57amalloy&(class (seq [1 2 3 4]))
02:57sexpbot⟹ clojure.lang.PersistentVector$ChunkedSeq
02:58amalloyletronje: vectors are chunked
02:59amalloynot sure why that's actually related to your question though, now that i think about it
02:59letronjeexactly :)
03:00tomoj&(class (next (filter identity [1 2 3])))
03:00sexpbot⟹ clojure.lang.ChunkedCons
03:00tomojfilter preserves chunkiness
03:00amalloylike donuts
03:01letronjeis there a function that lets me apply a predicate on a sequence and return the first item in the sequence for which it is true ?
03:02amalloy(comp first filter)
03:02letronje((comp first filter) test [1 2 3 4 5 6 7 8 9 10]) ?
03:03amalloythat would work
03:03letronje@amalloy: I still see 10 prints
03:03amalloyusually it's written as (first (filter ...)), but it really should be its own function
03:03letronjei wanted something like some
03:03amalloylike tomoj said, filter preserves chunkiness
03:04tomojletronje: is the problem that you're actually doing side effects? or that applying the pred to a whole chunk is too slow?
03:04letronjethe actual predicate that i plan to give to filter is costly ( CPU + IO )
03:05letronjeso i want it to immediately stop once it finds it
03:05amalloyletronje: the easy solution is not to give it something it *can* chunk
03:05amalloyie not a vector
03:05tomojsounds strange. but I think there's an unchunker somewhere?
03:06amalloythere is
03:06amalloy&(filter (juxt identity println) (range 4))
03:06sexpbot⟹ (01230 1 2 3)
03:06amalloy&(filter (juxt identity println) [0 1 2 3])
03:06sexpbot⟹ (01230 1 2 3)
03:06amalloy&(filter (juxt identity println) '(0 1 2 3))
03:06sexpbot⟹ (010 21 32 3)
03:07amalloy&(first (filter (juxt identity println) '(0 1 2 3)))
03:07sexpbot⟹ 0 0
03:07amalloy&(first (filter (juxt identity println) [0 1 2 3]))
03:07sexpbot⟹ 0 1 2 3 0
03:08amalloywould have been a better demo :P
03:08letronjenot sure i understand, n00b here
03:09amalloythe point is that only vectors and (range) are chunked currently, i think
03:09brehautletronje: its confused because the println and the result are on the same line
03:09amalloyso if you filter on something that is neither of those, it won't chunk, and it will be as lazy as you want
03:09brehaut&(let [n 1] (println n) (println "this is the return >") n)
03:09sexpbot⟹ 1 this is the return > 1
03:09tomojletronje: what's the IO?
03:09letronjeyup
03:10letronjetomoj: network IO
03:10tomojI mean, what is it
03:10tomojwhat are you actually doing? just curious
03:10letronjescraping a url
03:10tomojyeah, having that inside the pred seems fishy to me anyway
03:11tomojthough an alternative doesn't quickly spring to mind
03:11letronjea set works
03:11amalloymy irc client hates me. going to bed before it gets worse
03:11letronje((comp first filter) test #{1 2 3 4 5 6 7 8 9 10})
03:11letronjeprints only till 3
03:12amalloyletronje: sets do not maintain order
03:12amalloy&(class (list* [1 2 3]))
03:12sexpbot⟹ clojure.lang.PersistentVector$ChunkedSeq
03:12amalloydang it
03:12letronjeyes, just validated that they are not chunked :)
03:12amalloy&(class (apply list [1 2 3]))
03:12sexpbot⟹ clojure.lang.PersistentList
03:13amalloy&(filter (juxt println identity) (apply list [1 2 3]))
03:13sexpbot⟹ (121 32 3)
03:13amalloy&(first (filter (juxt println identity) (apply list [1 2 3])))
03:13sexpbot⟹ 1 1
03:13amalloyso you can use apply list to unchunk something, too
03:13letronjeok
03:14letronjethnx
03:14letronjewhat does juxt do btw ?
03:15tomojdoesn't it seem like the fact that these problems happen suggests you aren't supposed to do this?
03:15letronje&(map (juxt println identity) [1 2 3 4 5 6 7 8 9 10])
03:15sexpbot⟹ (12345678910[nil 1] [nil 2] [nil 3] [nil 4] [nil 5] [nil 6] [nil 7] [nil 8] [nil 9] [nil 10])
03:15tomojbut how else would you do it?
03:15letronje(loop (recur )) ?
03:16tomojbasically reimplement filter without the chunking.. that doesn't seem right either :(
03:16brehautletronje: it takes n functions and returns a new function; that new function passes all the arguments to all the functions returning a vector of the results
03:16brehautletronje: it juxtaposes the functions :)
03:16brehaut&(juxt inc dec)
03:16sexpbot⟹ #<core$juxt$fn__3661 clojure.core$juxt$fn__3661@1354d59>
03:16brehautsexpbot: thanks
03:16brehaut&((juxt inc dec) 1)
03:16sexpbot⟹ [2 0]
03:17letronjeah
03:17letronjeinteresting :)
03:17letronjewhy use identity ?
03:18letronjeoh ok got it
03:18letronjeso that filter gets the orig value ?
03:18brehaut(defn dechunk [xs] (lazy-seq (when xs (cons (first xs) (dechunk (rest xs)))))) ?
03:18tomojwon't that blow the stack?
03:19brehauttomoj: lazy-seq should avoid that shouldnt it?
03:19tomojer, infinite seq I mean?
03:19tomojneed next instead of rest or (when (seq xs)) or both, I think
03:19brehauttomoj: i dunno thats just a naive first guess
03:19brehautyou are correct
03:20brehautlets go with both.
03:20letronje&(map (juxt inc dec) [ 1 2 3 4 5 6 7 8 9])
03:20sexpbot⟹ ([2 0] [3 1] [4 2] [5 3] [6 4] [7 5] [8 6] [9 7] [10 8])
03:21tomojright, with next but without seq (dechunk []) is (nil)
03:21letronje&(filter (juxt inc dec) [ 1 2 3 4 5 6 7 8 9])
03:21sexpbot⟹ (1 2 3 4 5 6 7 8 9)
03:21letronje&(filter (juxt inc dec) [ 1 2 3 4 nil 5 6 7 8 9])
03:21sexpbotjava.lang.NullPointerException
03:21letronje&(filter (juxt inc dec) [ 1 2 3 4 false 5 6 7 8 9])
03:21sexpbotjava.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Number
03:23brehaut&(letfn [(dechunk [xs] (lazy-seq (when (seq xs) (cons (first xs) (dechunk (next xs))))))] (first (map prn (dechunk (iterate inc 1)))))
03:23sexpbot⟹ 1 nil
03:23brehauthave i dont something to upset sexpbot?
03:23brehauttomoj: that seems to work
03:24brehaut(in terms of not blowing the stack to bits on lazy seqs)
03:24brehautim sure there is something dumb about how it works though
03:24tomojI had thought the unchunker I remembered seeing was more mysterious
03:24brehauttomoj: yeah exactly
03:25tomojonly problem I can think of though is lazy seq overhead which is no problem here
03:25tomojand anyway, how could any unchunker not have that overhead?
03:26tomojsort of the point I guess
03:26brehautim going to dig into joy of clojure
03:27brehauti think chouser has one
03:27brehauttomoj: the unchunker in JoC appears to reify clojure.lang.ISeq
03:27brehauttomoj: and its called seq1 apparently
06:19ZabaQintetesting..
06:28ZabaQwhat's this -SNAPSHOT business in the version names?
06:29angermanI assume it's autogenerated (e.g. on a daily basis) stuff from the head of the dev. branch.
06:29raekthey act as in-between version numbers
06:29waxrosecabalBasically a nightly build?
06:30raekyes
06:30raeka non-snapshot version of a project should not have snapshot dependencies
06:31waxrosecabalDo you know if the clojure-install from Emacs pulls from the snapshot?
06:31raekLeiningen will always check for new versions of a snapshot dependency when doing lein deps, even if there is a version is in the cache
06:31waxrosecabalhmm
06:32raekwaxrosecabal: swank-clojure.el (which contains clojure-install) is old and deprecated
06:33waxrosecabalMan, I think every installation process I've found has been deprecated. :/
06:33raekthese things changed substantially when Leiningen appeared
06:35raekmy emacs installation routine: install clojure-mode, slime and slime-repl using package.el and technomancy's repo (included with emacs-starter-kit)
06:35raekadd [swank-clojure "1.2.1"] to :dev-dependencies and start a swank server with "lein swank"
06:35raekconnect to it from emacs with M-x slime-connect
06:36raek(this assumes you have leiningen and a created a project with it)
06:36raekand that's basically it.
06:36waxrosecabalCool, thanks. I was just a little confused at lein's roll.
06:36raekI use technomancy's durendal to start the swank server nowaday
06:37raekjust run M-c durendal-jack-in when you have a source file of the project open
06:37raek*M-x
06:37raekso that replaces the "lein swank" step
06:38waxrosecabalI'll try that in a little bit. Thanks. Need to update my notes. :P
06:39waxrosecabalDo you have any experience with Clojure on Google App Engine?
06:40waxrosecabalIf so, thoughts?
06:40raeknot yet :)
06:40raekonly ring + moustache + enlive (and a little bit of compojure + hiccup)
06:41raekI've heard that you use the ring stack for the servlet part of a GAE app
06:42waxrosecabalI was going to give Compojure a try first since I've seen a mini guide about it. And yeah, that is what I believe is used.
06:42waxrosecabalmini guide on GAE*
06:44raekthis sums up my workflow with the ring stack: http://groups.google.com/group/clojure/browse_thread/thread/4d8a1fc669a5a2df/9a7551ecfc851309?lnk=gst&amp;q=rasmus+app+engine#9a7551ecfc851309
06:44raeksome of it could be useful for GAE development
06:46waxrosecabalThanks for the link.
06:47waxrosecabalYeah, looks helpful already.
07:01joelrtechnomancy: ping
07:31hsuhdoes the - in (defn -main..) has any meaning to the reader, or its just convention?
07:32clgvit needs to be there in case you create a jar and want it to be the main-method called
07:32hsuhcan it be main instead of -main ?
07:33angerman(or want it to be the entry point for $ lein run -m package.class)
07:33clgvhsuh: I dont think so. you can only specify the namespace that contains -main in leiningen afaik
07:33hsuhok
07:34clgvit doesnt hurt much anyway, I think ;)
07:36hsuhabout that, in my top directory i have src/ and script/, and script/ has run.clj inside, which runs swank and then my -main... but after updating lein, i'm getting "Caused by: java.io.FileNotFoundException: Could not locate script/run__init.class or script/run.clj on classpath"
07:36hsuhi'm trying lein run -m script.run (i used to do lein run script/run.clj)
07:37angermanseems like a classpath issue. no?
07:37angermanlein has a command to show the classpath it thinks is correct. iirc.
07:37angermane.g. $ lein classpath
07:38angermanso that should at least contain "."
07:38hsuhok, but i thought lein was useful exactly because it handled that :)
07:40angermanI don't know what is with your lein. Haven't had a problem myself.
07:40hsuhlein version ?
07:41angerman1.4.2
07:41hsuhok, same here..
07:42clgvI guess it doesnt know about your scrip directory
07:43angermanif script was in src. I assume it would work.
07:43clgvis "script" a default leiningen directory?
07:43clgvyeah then it definitely should
07:47hsuhdoes you run.clj file has a (ns..) declaration? (mine doesnt)
07:48clgvthat might be an issue. shouldnt every regular clj-file have an ns declaration? clojure config files lik project.clj excluded
07:58clgvI am tempted to use some sort of callback function for a deftype. this callback is specific problem dependent behavior which can't be determine by the general implementation. Is there a better or more idiomatic way to do this in clojure?
08:06hsuhangerman, clgv: yeah, adding an ns and putting the file into src/ works, i liked the older organization though.. but its time to be pragmatic .........
08:06hsuhbut ty
08:08raekhsuh: "-" is the default prefix for gen-class. you can override it with the :prefix option: http://clojuredocs.org/clojure_core/clojure.core/gen-class
08:09hsuhoh, interesting... thanks. i wont change it, just wanted to understand where did it came frmo
08:09clgvhsuh: there is  :repl-init-script option for leiningen. see  https://github.com/technomancy/leiningen/blob/stable/sample.project.clj
08:09hsuhgreat, i can develop with lein repl than! thanks!
08:09raekhsuh: leiningen run feature is a bit different (and opinionated) when compared to the lein-run plugin
08:09hsuh8then
08:09hsuh*then
08:10hsuhraek: leiningen also has run? now i dont know if im using the plugin or not...
08:10raekfrom your description it looks like you have the built in one
08:10hsuhthat explains a lot...
08:10raeki.e. lein run takes a namespace as a parameter rather than a file
08:11raekand loads plus calls -main, instead of just loading it
08:11hsuhsure, i get it now.. thats why things "changed" so much.. after updating i stopped using the plugin and started using lein's run...
08:11raekheh
08:20angermanhm. Is there a funtion that takes a list of bool and return if all are true?
08:20angermane.g. (apply and lst) but that doesn't work iirc.
08:20angerman,(apply and [true true true])
08:20clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/and
08:23clgv$findfn [true true true] true
08:23sexpbot[clojure.core/== clojure.core/sequential? clojure.core/second clojure.core/last clojure.core/reversible? clojure.core/distinct? clojure.core/boolean clojure.core/vector? clojure.core/counted? clojure.core/associative? clojure.core/< clojure.core/peek clojure.core/fir... http://gist.github.com/874233
08:24angerman$findfn [true true true false true] false
08:24sexpbot[clojure.core/keyword? clojure.core/chunked-seq? clojure.core/fn? clojure.core/not= clojure.core/nil? clojure.core/string? clojure.core/sorted? clojure.core/false? clojure.core/true? clojure.core/symbol? clojure.core/number? clojure.core/integer? clojure.core/seq? cl... http://gist.github.com/874235
08:24angermanno.
08:24angerman,(every? identity [true true true])
08:24clojurebottrue
08:24clgvhm ok not the appropriate use case for that findfn
08:25clgv,(every? [true true true])
08:25clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$every-QMARK-
08:25angermanevery? expects a predicate
08:25clgv,(find-doc "all")
08:25clojurebot-------------------------
08:25clojurebotclojure.contrib.seq/fill-queue
08:25clojurebot([filler-func & optseq])
08:25clojurebot filler-func will be called in another thread with a single arg
08:25clojurebot 'fill'. filler-func may call fill repeatedly with one arg each
08:25clojurebot time which will be pushed onto a queue, blocking if needed until
08:25clojurebot this is possible. fill-queue will return a lazy seq of the values
08:25clojurebot filler-func has pushed onto the queue, blocking i...
08:27clgv$help findfn
08:27sexpbotclgv: Finds the clojure fns which, given your input, produce your output.
08:28angermanfindfn need more predicates. e.g. given 3 inputs and expected outputs.
08:28clgvyep^^
08:28angermanSomething is weird. My radio clock on the wall is spinning since 9 o'clock.
08:29angermanThere must be some issue with the signal.
09:19angermanJapan looks /really/ bad.
09:19Fossiin general?
09:20angermanwell, about half a week ago, i thought there was a chance that this could end semi-lucky.
09:21angermanbut since then, I'm loosing faith in the success by the hour :/
09:25angermanFossi: and in general, that's going to be a very hard setback for japan. High devastation, radiation, national depth at 200% and rising :(
09:25__name__amalloy_: Is sexpbot FOSS?
09:26Fossiso far the radiation is really low
09:26__name__angerman: *debt?
09:26Fossiif there hasn't been something big happening in the last hour
09:27angermanFossi: I guess the question is where and whom you ask. The graphs near the plant look really bad.
09:27angerman__name__: yes.
09:27angermanFossi: and what are you going to do with the plant's region and it's sourrounding?
09:28Fossiguess it depends on what's "really bad" to you
09:28Fossithe highest reading i heard of was 900mSv
09:29Fossithat won't even cause sustained damage really
09:29Fossiand that was like 3 days ago
09:30angermanFossi: mSv or muSv?
09:30FossimSv
09:31Fossisince you are german: http://www.grs.de/informationen-zur-lage-den-japanischen-kernkraftwerken-fukushima-onagawa-und-tokai
09:31Fossiis a really good summary
09:31angermanFossi: yep, that's what I'm reading.
09:31Fossihighest reading at the frontdoor was something like 12mSv
09:35angermanFossi: yes. But what happens to the particles that got in the air, as far as I understand, depending on what escapes it's halflife is from 8 days to multiple years.
09:36angermanFossi: I understand that there was an elevated radiation level in the athmosphere during the time of atomic bomb tests.
09:40Fossiwell, atomic bomb test are something entirely different from this
09:40Fossiand from the readings it's so far pretty obvious that not a whole lot of radioactive material has "escaped" the containments
09:41Fossithe higher readings are from venting the containment
09:42choffsteinDoes clojure have pattern matching besides multi-methods (e.g. a 'match' method or something similar)?
09:42choffsteinMy google-fu is failing me for a concrete answer
09:43choffsteinBasically, I want my method to do one thing when an input is an empty list, and another when the list has objects in it
09:43wtetzneryou can use cond
09:44raekchoffstein: well, you have cond, case and (unconditional) destructuring, but nothing like matching in Haskell or Scala
09:44wtetzner(cond (empty? lst) do-something :else do-something-else)
09:44choffsteinSo just cond and destructure then?
09:44raekif-let can be useful too
09:45raek...in some cases
09:46choffsteinhmmm, okay, thanks
09:46raekchoffstein: also, check out https://github.com/dcolthorp/matchure
09:47angermanhmm… http://www.brool.com/index.php/pattern-matching-in-clojure ?!
09:47angermanthat's been the first google result for me.
09:54raekI like the syntax of that one
09:54raek(https://github.com/brool/clojure-misc)
09:57angermanit looks a little more like the pattern matching syntax I'm used to then matchure looks.
09:58raekI wonder if it supports [a & d] patterns
10:02raekheh, the documentation does not mention which namespace to use
10:04tmountainif you have a bunch of items in a collection and want to dispatch a function based upon some characteristic of the item, would it be more idiomatic to use protocols and types or something like multimethods?
10:05raekwith protocols, you can only dispatch on the type of the first argument
10:06raekmultimethods can dispatch on anything
10:08raek(use 'pattern-match) (match [1 2 3] [fst & rst] rst) => (2 3)
10:10tmountainare protocols intended more as a Java bridge technology, or are they first-class citizens IRT program design. for some context, I'm messing around with some basic game logic. when the game server "heartbeat" occurs, all entities in the game need to respond
10:11tmountainI could wrap all that up in a protocol and guarantee that the objects can respond to the event, but I wonder if I'm straying too far from FP design principles there...?
10:11angermantmountain: clojure is not pure fp
10:12raekthey are intended to be a more performant, but restricted, variant of multimethods (with grouping of methods)
10:12raekbut they are not a mere interop feature
10:13tmountainangerman: yeah, I know, it's more pragmatic, I just tend to want to treat it as such
10:14tmountainraek: that makes sense, so as long as I'm content with being restricted to dispatching on the first argument, protocols are a good choice?
10:14angermantmountain: my render should be able to render points, edges and faces. So I could either write structmaps or records and multimehtods to allow one method `render' to work for all, or just go the protocol way.
10:14angermanthe letter one looks cleaner.
10:14angermanhttps://github.com/angerman/planarity/blob/master/src/geometry/renderer.clj
10:17raektmountain: I haven't done much design using protocols, so I simply do not know...
10:18raekbut to me it sounds like protocols is a language feature that could indeed be used to solve yout problem
10:18tmountainangerman: what does the _ argument to the protocol method signatures imply?
10:18angermanwell _ is just a throw away place holder.
10:18tmountainraek: no worries, you've been helpful in helping me draw distinctions between strategies
10:18angermantmountain: could be `this' or `self' as well.
10:18tmountainangerman: basically a placeholder for "this" or the first arg
10:18tmountainok
10:19tmountainthanks guys
10:19raekthat name is what you see in the arglist in the docs (or in the minibuffer of emacs)
10:20raek(hrm, don't know whether autodoc actually supports protocols as a doc source)
10:22joelrgood day! how do i find the latest version of composure to depend on?
10:22joelrsame for lein-ring for that matter
10:30raekjoelr: I usually look in the project.clj of the project (if it's on github, for example) or at http://clojars.org/repo/
10:30joelrraek: thanks!
10:33raek(also, do not use SNAPSHOT dependencies when releasing non-snapshot versions of you project)
10:48choffsteinIf I have two lists of maps that are identified by a unique key, like [{:a 5, :b 6} {:a 6, :b 5}] and [{:a 5, :c 7} {:a 6, :c 8}, is there any way to combine them by unique key to get a list that is: [{:a 5 :b 6 :c 7} {:a 6 :b 5 :c 8}]?
11:06joly,(map into [{:a 5, :b 6} {:a 6, :b 5}] [{:a 5, :c 7} {:a 6, :c 8}])
11:06clojurebot({:a 5, :b 6, :c 7} {:a 6, :b 5, :c 8})
11:06jolychoffstein: ^ but I'm not sure that solves the problem you're asking
11:06raek,(map merge [{:a 5, :b 6} {:a 6, :b 5}] [{:a 5, :c 7} {:a 6, :c 8}])
11:06clojurebot({:c 7, :a 5, :b 6} {:c 8, :a 6, :b 5})
11:08clgv,(map merge [{:a 5, :b 6} {:a 6, :b 5}] [{:a 5, :c 7} {:a 7, :c 8}])
11:08clojurebot({:c 7, :a 5, :b 6} {:c 8, :a 7, :b 5})
11:08clgvis that intended or did you look for a join-semantic?
11:09devndamn beat me to it
11:11choffsteinawesome. thanks!
11:15clgvchoffstein: thats ok for you? ##(merge {:a 1, :b 5} {:a 999, :c 8})
11:15sexpbot⟹ {:c 8, :a 999, :b 5}
11:17choffsteinHmm, on second thought, not quite.
11:17choffsteinI need to be able to define the key I am merging on
11:18clgvit's just merging the maps. it has no sql-like join semantics on any of the keys
11:18clojurebotmaps are functions
11:18clgvclojurebot: a cookie for you
11:18clojurebotIt's greek to me.
11:19choffsteini think I might have it
11:19elegant_knight;this may not be a clean way.. do it do the job?
11:19elegant_knight(defn merge-map-lists
11:20elegant_knight "merges the 2 lists of maps"
11:20elegant_knight [list1 list2]
11:20elegant_knight (let [merged (merge (first list1) (first list2))])
11:20elegant_knight (if (or (= (count list1) 1) (= (count list2) 1))
11:20elegant_knight (cons merged [])
11:20elegant_knight (cons merged (merge-map-lists (rest list1) (rest list2)))))
11:22angermanwhy is it `every?' and `some'?
11:22clgvangerman: pure evilness ;)
11:24raekangerman: some not only checks whether there is an element, but can also return it
11:24clgvchoffstein: you could use merge-with I guess ##(doc merge-with)
11:24sexpbot⟹ "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
11:27raekchoffstein: map merge will take the first map of the left list and the first map of the right list and merge them. did you want to merge one the value for a certain key, rather than on the position in the list=
11:27raek?
11:50amalloy(cons foo []) is the same as (list foo)
11:53elegant_knightamalloy:got it!
11:54elegant_knighti have a list of values. i want to find the index of maximum value in that. whats the easiest way to do it
11:54scottjwhy does https://gist.github.com/874276 call shutdown-agents if there's no call to agent in the code?
11:56mrBliss,(let [l [1 2 3 2]] (.indexOf l (reduce max l)))
11:56clojurebot2
11:57mrBliss,(let [l [1 2 3 2]] (apply max-key l (range 0 (count l))))
11:57clojurebot2
11:58mrBlisselegant_knight: ^^
12:00mrBlissThe second one is 3x faster than the first (on my machine)
12:00jkkrameronly works on vectors
12:00mrBlissjkkramer: correct
12:01ouncehi
12:03jkkramerscottj: previous versions appeared to use pmap, which uses futures, which use the agents thread pool
12:06mrBliss,(loop [l '(1 2 3 2), i 0, max -1, max-i -1] (if-let [[head & tail] l] (if (> head max) (recur tail (inc i) head i) (recur tail (inc i) max max-i)) max-i))
12:06clojurebot2
12:06mrBlissUgly loop, but faster than the previous two
12:09scottjjkkramer: ok that's what I thought
12:10elegant_knightmrBliss : thanks. i have a lazy sequence. so the first way of using .indexOf worked just fine.. second one looks elegant!
12:14angermanis there any logic faillure in (defn any? [pred coll] (every? (complement pred) coll)) ?
12:15clgvangerman: yes. you determine "none?" since you have an "and" over all negated predicates
12:15amalloymore of a vocab failure than a logic failure :)
12:16angermanyea right. fail's on me.
12:17clgvyou want to know if not all predicate applications are false?
12:17angermanclgv: as in: (if (none? impossible […]))
12:18angermanhmm that's none? impossible? :D
12:19mrBliss,(find-doc #"not-.+\?")
12:19clojurebot-------------------------
12:19clgvyou'll get true in your definition for the case that at least one predicate is true when you negate the every? like (not (every? ...))
12:19clojurebotclojure.core/not-any?
12:19clojurebot([pred coll])
12:19clojurebot Returns false if (pred x) is logical true for any x in coll,
12:19clojurebot else true.
12:19clojurebot-------------------------
12:19clojurebotclojure.core/not-every?
12:19clojurebot([pred coll])
12:19clojurebot Returns false if (pred x) is logical true for every x in
12:19clojurebot coll, else true.
12:20angermanthere's not-any? wtf.
12:20jkkramer(def any? (comp boolean some))
12:21angerman,(some nil? [nil nil nil])
12:21clojurebottrue
12:22clgvangerman: yeah that logic what functions to include there is a bit inconsistent ;)
12:22angermanclgv: I'm getting confused with them too often :/
12:28clgvwrtie your own "some?" and you are safe ;)
12:47angermanis ^ still the meta reader macro?
12:47angerman,(:foo ^(with-meta 'x {:foo 'y}))
12:47clojurebotMetadata must be Symbol,Keyword,String or Map
12:47fogus`away,(doc meta)
12:47clojurebot"([obj]); Returns the metadata of obj, returns nil if there is no metadata."
12:48angermanok, so I need to use (meta ...)
12:59dakroneis there a way to make a non-seqable string easily?
13:00amalloydakrone: waaaat?
13:00dakroneI'll take that as a "no one needs that so you're doing it wrong"
13:01amalloydakrone: well i don't understand what it is you want
13:02amalloy$mail choffstein see also not-empty for your empty-list-finding needs: (if-let [l (not-empty input)] (do stuff with l) (whoops input was empty))
13:02sexpbotMessage saved.
13:03amalloyyou want a sequence of characters that can't be treated as a sequence of characters, is all i can get from the original question. i'd say maybe use ##(symbol "some-string"), which keeps all the information and makes it non-seqable, but it's a weird thing to do
13:03sexpbot⟹ some-string
13:03raekdakrone: there is no way to have something that is a java.lang.String that noone can call seq on
13:03dakronenevermind, I was doing it wrong, as I suspected
13:03amalloy*chuckle*
13:04raekthe question is, what problem is non-seqable string the solution for?
13:06dakronemissing a [] in a lazy-seq and staring at it too long, that's what
13:45mattmitchelli'm trying to create a wrapper around 2 functions that are together like this: (sql/with-connection db-conn (sql/with-query-results res ["my query"]) ...)
13:46mattmitchellthe problem is that the with-query-results is a macro and creates "res" -- so I'm not sure how to handle it?
13:47mattmitchellas a first try, this doesn't work: https://gist.github.com/874777
13:51amalloymattmitchell: your function will have to be a macro
13:51mattmitchellamalloy: ok i was kinda thinking that
13:52amalloyalso did you intend to throw away the query arg?
13:52mattmitchellamalloy: woops, no
13:53amalloyanyway it probably looks basically like (defmacro wqr [query form] `(sqlwc db/conn (sql/wqr ~'res ~query ~@form)))
13:54raekmattmitchell: you can also do something like this: (defn with-query-results [query f] (... (sql/with-query-results res (f res))))
13:55amalloygood point
13:56mattmitchellraek: right thanks
13:56raekmacros really are contagious... this way you can "kill it to keep it from spreading"
13:57mattmitchellraek: i've just barely scratched the surface of macros, it will be a while until i "get" it :)
13:58mattmitchellthanks amalloy
13:58amalloyhaha
14:42rcadena1
15:08mrBlissk
16:01khaliGhm ive noticed lein uberjar isn't including the jars in lib/dev .. is this normal?
16:03Null-AkhaliG: if I had to guess, yes
16:03khaliGok well that would explain why my jar doesn't work :)
16:04Null-AkhaliG: dev dependencies would be like swank server or lein extensions
16:04khaliGahhh! ok
16:04khaliGso maybe i need to rewrite my project.clj file
16:04Null-Asounds like it
16:04khaliGthank you!
16:04Null-Ayou could probably put testing dependencies in dev-dependencies too
16:09khaliGhm there is one library which i can't move out from dev .. clj-time
16:09khaliGhttp://clojars.org/clj-time .. seems it has to be the snapshot?
16:11raekkhaliG: yup. they should release a stable version.
16:11khaliGah damn, so i can't make a jar until they do :/
16:11raekkhaliG: you can, but your project has to be a snapshot version too
16:11khaliGi see
16:13raekkhaliG: you could also reate an issue for it, so that they become aware of that this is a problem for people
16:13raekhttps://github.com/getwoven/clj-time/issues
16:14khaliGi will do that now cheers
16:15raek(a completely different alternative is to use joda-time directly using java interop. in many cases it's just a matter of calling .fooBarBaz insead of boo-bar-baz, since joda-time is very compatible with the clojure philosophy)
16:18khaliGraek, hm i'd rather not do that, i use it quite heavily :/
16:22khaliGbed time, thanks for the help guys.
16:38technomancywow, clj-time doesn't bother with releases?
16:38technomancythat's like the third library recently I've heard of that does that. what would prompt someone to actually bother bumping the version number if they haven't released?
16:39technomancyboggling.
16:44amalloytechnomancy: so their version number goes straight from 0.1.0-SNAPSHOT to 0.2.0-SNAPSHOT or something?
16:45technomancyamalloy: yes. ಠ_ಠ
16:45raekamalloy: indeed so: http://clojars.org/repo/clj-time/clj-time/
16:47gtrakwith lein test, anyone ever get "Exception in thread "main" java.io.FileNotFoundException: Could not locate robert/hooke__init.class or robert/hooke.clj on classpath:" after adding the :test-selectors map to project.clj?
16:47brehauttechnomancy: at least enlive and moustache have had real released
16:48technomancybrehaut: staying on a snapshot can be forgiven if it's the same snapshot. bumping to another snapshot shows you're at least paying some attention to the version number without getting it right.
16:48gtrakah, nevermind, I found it
16:48technomancygtrak: it should give you a better error message; shoot
16:49gtrakyes, I found I have to add a dev dependency
16:50gtrakthis same issue: http://j.mp/crcQcy
16:50brehauttechnomancy: sure that makes sense
16:51gtrakexcuse me, a different one http://j.mp/hgOgby
16:53technomancygtrak: it shouldn't be a dev dependency
16:54technomancydoes it say dev-dependency somewhere? if so that needs to be fixed.
16:54gtrakthat fixes it for me, same as the issue reporter
16:55technomancyhooke is an implied dev-dependency of every lein project
16:56TimMcAny way to get swank-clojure in all projects by default?
16:56gtrakright, that's what was confusing me, we already are using hooks
16:56gtrakfor some reason 'lein test' didn't care
16:56gtrakthis is 1.4.2
16:56TimMcI see that I can use an init.clj, but I don't know what to put in it.
16:57amalloyTimMc: cake project or lein project?
16:57TimMcWait, nvm. lein plugin should do it
16:57raekTimMc: you can copy the swank-clojure jar to ~/.lein/plugins/
16:58technomancyraek: yeah, lein plugin actually does that
16:58raekoh. :)
16:58TimMcOK, so now from Emacs, how do I get connected to swank?
16:58amalloyM-x slime-connect
16:59amalloyi bound that to C-c s, because i'm clever enough to do that but not clever enough to get it to autoload or manage multiple swank sessions
17:08TimMcI assume the usual usage is to send each top-level form to the REPL as you edit it, yeah?
17:08TimMcHow do I do that?
17:09raekTimMc: the whole file: C-c C-k, the top-level form that encloses the point: C-M-x
17:10TimMcthanks
17:10raekand to change namespace: C-c M-p (requires it to be loaded)
17:12TimMcloaded = eval'd?
17:13raekyes
17:13amalloyraek, TimMc: i use C-c C-c rather than C-M-x. doubt it matters, but i like having all the interesting commands start with C-c
17:14raek(well, the ns form needs to be evaled. otherwise the namespace does not exist and slime will say "no match" or something)
17:17jlfraek: i like ,!p to change namespaces
17:21waxrosecabalraek, I'm still a little confused at how things are connected, so does Lein make it so that projects have clojure and not the actual system?
17:23brehautTimMc: did you have more luck with your parser?
17:23TimMcbrehaut: Working on it.
17:23waxrosecabalTimMc, o/
17:24TimMchey, waxrosecabal
17:24technomancyC-M-x is a elispism
17:24technomancyof sorts
17:24brehautTimMc: cool :)
17:24TimMcTryng to parse numbers.
17:25TimMcI just need pos/neg decimal integers and positive hex
17:25TimMcRight now I'm trying to figure out why my semantics hook isn't being called.
17:27TimMcbrehaut: Any reason why an inline anonymous fn would be called and not a defn'd function? :-/
17:27brehautit'll not be called if the parser fails for some reason
17:27TimMc#(println %&) works fine, as-decimal-number is never called.
17:28brehautotherwise if its not running it should throw an error
17:28brehautTimMc: that's surprising!
17:28TimMcOh... my bad
17:28TimMcForgot to eval that form.
17:28TimMcNew at this interactive development thingy.
17:32brehautoh right :D
17:32waxrosecabal:P
17:35TimMcbrehaut: https://gist.github.com/875176 <-- I've got register numbers being extracted, still figuring out the use of semantics.
17:40brehautTimMc: your use of semantics looks correct to me. you have a bug waiting to trip you up in hex-imm; its using decimal-digit
17:42raekwaxrosecabal: to lein, a version of clojure is "just a dependency" of the project. (does that answer your question?)
17:43waxrosecabalraek, Yeah it does. Just matching sure I understand it correctly.
17:44brehautTimMc: you can replace [[& digit-chars]] with digit-chars in your semantics though i think
17:44raek"the project has a version of clojure" is the case rather than "the system has a version of clojure"
17:44waxrosecabalah
17:48amalloybrehaut: really? i don't think so
17:48amalloyoh i guess so
17:49brehautamalloy: hmm i did remove too many brackets
17:49amalloyhaha
17:49brehautamalloy: destructuring a sequence into just a remainder is an identity operation is it not?
17:49amalloyyeah. that was such a glaring error i didn't even notice it; i knew what you meant
17:50amalloybrehaut: yeah. i think of [:as foo] being equivalent to foo, but never really use & that way
17:50raekhas anyone made a lib that can catch uncaight exceptions at the top level of an application and (offer the user to) send the stacktrace to the application developer?
17:50amalloy(this is a total lie. i'm just trying to justify my clearly incorrect claims)
17:53raekor does anyone know what terms I should search for in order to find such a lib?
17:57xkbHi
17:58xkbCan anybody recommend a current compojure tutorial?
17:58waxrosecabalraek, Thanks for the tips. Got every thing hooked up.
18:00raekhrm, turns out log4j could be used for my need...
18:00raekwaxrosecabal: np.
18:40TimMcbrehaut: Ah, thanks for the digit-chars thing. That was there for hysterical raisins.
18:40brehautTimMc: haha :) no worries
18:40TimMcAnd hex-imm is in progress.
18:48raekanyone have any recommendation for a clojure logging tutorial?
18:50raekalso, does tools.logging include the recent rewrite of clojure.contrib.logging?
18:54technomancyraek: it does
19:10TimMcThe good news: I found out that ##(.intValue (java.math.BigInteger "ffffffff" 16)) works.
19:10sexpbotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
19:10TimMc,(.intValue (java.math.BigInteger. "ffffffff" 16))
19:10clojurebot-1
19:10TimMcThe bad news: All my hex inputs are actually unsigned values. >_<
19:10brehauttimmc use longs
19:11TimMcNah, I don't need them.
19:11TimMcThey're < 32 bit.
19:11TimMcMemory address literals.
19:13brehautTimMc: im not following. is it a problem??
19:13brehauts/?$//
19:13TimMcThe bad news was simply that I didn't have any use for the neat solution.
19:20TimMcjava.lang.ClassCastException: org.timmc.mipsiss.instructions.Instr cannot be cast to org.timmc.mipsiss.instructions.Instr
19:21TimMcThat's a new one for me.
19:22brehautit does appear surprising doesnt it
19:22amalloywrong classloader?
19:23amalloyie if two classloaders load the same class, they'll have the same name but not be the same class (nor even related)
19:24raek,(= "org.timmc.mipsiss.instructions.Instr" "org.timmc.mipsiss.instructions.Instr")
19:24clojurebottrue
19:25TimMcI *am* doing something that is probably naughty. https://gist.github.com/875355
19:25TimMcThe exception is thrown on the last line of code.
19:26TimMcI should probably convert this to a memoized function.
19:29brehautTimMc: you could rewrite #(vector …) as (juxt :name identity)
19:30TimMcI was running a computation involving a defrecord (from the same file) at compile time. :-\
19:30brehautbut btw
19:30brehauterr just
19:30brehautoh
19:30TimMcbrehaut: But then I wouldn't be able to read it!
19:31brehautTimMc: really?!
19:31TimMc,((juxt :name identity) {:name 5})
19:31clojurebot[5 {:name 5}]
19:32TimMcHmm, I suppose. But is it really any clearer?
19:32amalloyyes
19:32brehautTimMc: it juxtaposes your functions
19:32brehautmuch!
19:33amalloyit proclaims to the world "here are two functions! i am calling them both on the same object! next up: the object i will call them on!"
19:33brehaut(caveat: #clojure has a serious juxt fetish)
19:33TimMcbrehaut: I noticed.
19:33amalloywhere is the setting to give me a highlight/notify every time someone does something that should be replaced with juxt?
19:34TimMc/hilight (
19:35brehautamalloy i think the regexp /[/ should cover it
19:35amalloybrehaut: are you crazy? that wouldn't even catch his one case
19:35brehautamalloy: im sorry
19:35amalloy /hilight \.
19:40brehauttalking of naming random small functions, ive been tempted to write (defn arguments [& r] r)
19:40TimMcbrehaut: "unapply"
19:40brehautor alias vec or something
19:41brehautTimMc: hmm. interesting suggestion
19:41TimMcDo you really need that that often?
19:41brehauti have also convinced my self that aliasing vector is wrong
19:41brehautTimMc: often enough
19:46brehautTimMc: i could just use vector most of the time, but i like the clarity of giving it its own name for the purpose
19:46brehautand vector isnt lazy
19:49brehauti have just discovered the seque function and am curious about what it could be used for
19:49brehaut(doc seque)
19:49clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
19:49brehaut,(doc seque)
19:49clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
19:53amalloybrehaut: (def arguments list)
19:54TimMcbrehaut: I notice that the example JSON parser built on fnparse passes a struct around instead of a raw token stream.
19:54brehautamalloy: i dont think thats lazy either
19:55amalloyoh all right. list* if you want lazy
19:55brehaut&(first (apply (fn [ & r ] r) (iterate inc 1)))
19:55sexpbot⟹ 1
19:55brehaut&(first (apply list (iterate inc 1)))
19:55brehautgot a link?
19:55brehautamalloy: ah right
19:55sexpbotExecution Timed Out!
19:55TimMcbrehaut: https://github.com/joshua-choi/fnparse/wiki/Sample-JSON-parser
19:55amalloy&(first (apply list* (range)))
19:55sexpbotjava.lang.StackOverflowError
19:55brehaut&(first (apply list* (iterate inc 1)))
19:55sexpbotjava.lang.StackOverflowError
19:55amalloylol
19:55amalloywhat
19:55brehautdouble fial
19:55amalloy,(first (apply list* (range)))
19:55clojurebotjava.lang.StackOverflowError
19:56amalloywhy would this overflow
20:01brehautTimMc: i suspect its a struct because its older than records and it is more than just {:remainder ... } because it also stores column and line information (for error) using get-info and set-info
20:02brehautTimMc: ah it uses update-info in nb-char and b-char to track that information
20:04TimMcDo I only nee to do something like that if I want debugging info in my parser?
20:04brehautTimMc: if you look at parse-error you'll see its pulling those out of the state
20:05brehautparse-error is called by parse-error
20:06brehautwhat am i say
20:06brehautby expectation-error-fn which is used by failpoint in various places
20:06brehautcorrect
20:08brehautwell, there might be additional state you need for specific parsers (a python or haskell parser would need to track indentation for example)
21:27mec,('m)
21:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol
21:37amalloy&('m '{m 10})
21:37sexpbot⟹ 10
21:37mecinteresting, i thought that was only keywords
21:40amalloymec: keywords are a lot better at it than symbols are
21:42amalloyin that you don't have to quote them, and they're faster
22:13zakwilsonI want to move a symbol that was defined in namespace a, which is used by namespace b to namespace b without restarting Clojure. Doable?
22:16brehautzakwilson: you can reload a namespace in your repl (require 'namespace.b :reload)
22:17zakwilsonbrehaut: thanks
22:17TimMczakwilson: or even better, :reload-all
22:19zakwilsonHmm... that's not working. I still get an IllegalStateException. I should note I'm using Clojure 1.2.
22:35trptcolinok, so i'm re-reading JoC and noticed a sidebar i missed the first time around that says positional destructuring works w/ java.util.regex.Matcher
22:35trptcolin,(let [[a b c] (re-matcher #".*test.*" "this is a test. testing. only a test.")] [a b c])
22:35clojurebot[nil nil nil]
22:35trptcolinwhat am i missing here?
22:38TimMc,(re-matcher #".*test.*" "this is a test. testing. only a test.")
22:38brehaut,(let [[a b] (re-matches #"a(b)c" "abc")] [:a a :b b])
22:38brehautoh my bad
22:38clojurebot#<Matcher java.util.regex.Matcher[pattern=.*test.* region=0,37 lastmatch=]>
22:38clojurebot[:a "abc" :b "b"]
22:39TimMcAh, re-matche*s*
22:40brehautTimMc: yeah i used the wrong func
22:42amalloyzakwilson: you want ns-unmap
22:42amalloy(ns-unmap *ns* 'var-i-want-to-move)
22:42brehauttrptcolin: the matcher i get back from your expression raises 'illegalstateexception:no match found' when i try to call nth on it
22:42trptcolininteresting, seems the regex capture changes the output semantics here
22:42trptcolin,(let [[a b] (re-matches #"abc" "abc")] [:a a :b b])
22:42clojurebot[:a \a :b \b]
22:43zakwilsonamalloy: thanks, that sounds like what I'm looking for.
22:43amalloy&(let [[a b] (re-find #"abc" "abc")] [a b])?
22:43sexpbot⟹ [\a \b]
22:44amalloyfeh. destructuring regex matches seems like such a weird idea it's no wonder the syntax is hard to get right
22:44trptcolinah, because re-groups returns a string when there are no match groups
22:45cemerickamalloy: I think it's a complete misfeature
22:45trptcolinamalloy: word. i saw the sentence and immediately ran to the REPL, because i can't think of a good use case for it...
22:46amalloycemerick: that seems like an overstatement to me. there should be *some* way to destructure a match-like-thing into its groups
22:46brehauttrptcolin: but re-matches returns a vector so destructuring is straight forward, re-matcher returns the actual object you mention
22:46trptcolinyup
22:46phenom_hmmm type hinting is done with the hat right? eg (defn my [^MyType type] ...)
22:46phenom_for clojure 1.3
22:46cemerickamalloy: oh, I thought we were talking about java.util.regex.Matcher objects
22:47amalloycemerick: we probably are
22:47amalloyi can't keep that whole package straight
22:48cemerickamalloy: re-matches returns vectors and strings. re-matcher returns a Matcher object.
22:48brehautcemerick amalloy we were initially, then i screwed up and muddied the water with re-matches
22:48cemerickah, my bad then
22:49trptcolinyeah, the question of whether Matcher actually destructures was my confusion
22:49brehautcemerick: nah i think you were right
22:51brehaut,(let [match (re-matcher #".*test.*" "this is a test. testing. only a test.")] (destructure [['a 'b 'c] match]))
22:51clojurebot[vec__5270 #<Matcher java.util.regex.Matcher[pattern=.*test.* region=0,37 lastmatch=]> a (clojure.core/nth vec__5270 0 nil) b (clojure.core/nth vec__5270 1 nil) c (clojure.core/nth vec__5270 2 nil)]
22:53TimMcphenom_: type hinting like ^String foo works in 1.2 as well
22:55trptcolinok, right, so if nth doesn't work on it, it's not gonna fly.
22:55brehauttrptcolin: if i bind that matcher to a name, call .matches and then call nth it works, but not if omit the .matches
22:56cemerickbrehaut: that's because Matcher is a stateful thing
22:56trptcolinok, so depends on lastmatch being set then
22:56cemerickwhich is why I was saying that the fact that it's destructurable is a misfeature
22:57brehautcemerick: i now understand why you would say that
22:57amalloyhaha
22:57cemericke.g. you can't destructure it twice, etc
22:57cemerickcapture it with :as, and it's useless
22:57cemerick(er, maybe you can reset it or something :-/)
22:57amalloycemerick: the act of destructuring it causes it to call .find()
22:58amalloy?
22:58cemerickamalloy: no, .matches
22:58amalloy$google javadoc regex util matcher
22:58sexpbotFirst out of 2510 results is: Pattern (Java 2 Platform SE v1.4.2)
22:58sexpbothttp://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html
22:58cemerickSequential destructurability is a consequence of something being nth-able, and Matchers are (perhaps rightfully) nth-able
22:59amalloyreally, it calls matches, not find?
22:59cemerickno, *you* need to call .matches
22:59cemericknth works only on a matcher that's been init'ed properly (via find or matches)
22:59cemerick,(nth (re-matcher #".*" "foo") 0)
22:59clojurebotjava.lang.IllegalStateException: No match found
23:00amalloyin that case i don't follow your statement about destructuring it making it become useful
23:00amalloyuseless
23:00cemerick,(nth (doto (re-matcher #".*" "foo") .matches) 0)
23:00clojurebot"foo"
23:00amalloythe destructuring itself has no side effects, you just have to call .matches to make it work
23:00phenom_TimMc for some reason my hints aren't working
23:01amalloyphenom_: hints are not type-checkers
23:01phenom_it still's using reflection (which i see in the stack trace)
23:02cemerickamalloy: ah, sorry -- I was thinking of the scenario where one is using .find and destructuring
23:03cemerickThen the same Matcher object (potentially) destructures into different values as it goes along the input.
23:04amalloyyes. of course if you're doing that sort of thing you should be using re-seq anyway
23:05cemerickanytime someone says "oh, you're just doing it wrong", there's something gone awry in the system
23:06amalloyif there were a system so well-designed as to make mistakes impossible, it wouldn't need us humans
23:06cemerick'course, any j.u.List or j.u.Map is destructurable and potentially mutable too, so I guess I'll go sit quietly elsewhere ;-)
23:06cemerickI've just been so spoiled with immutability that anything else just seems irretrievably broken.
23:07amalloyheh
23:07amalloyit is hard to go back