#clojure logs

2016-01-16

00:23retrogradeorbithey. I need some opinions on style
00:23TimMcYou've come to the right place.
00:24retrogradeorbitwhere is the line between threading macro and just nesting?
00:24retrogradeorbithttps://github.com/retrogradeorbit/geoip/commit/3e79e5adb2384121017ab1aee98136d04af64d8c
00:24retrogradeorbitwhats better?
00:24retrogradeorbitstylistically... before the commit? or after?
00:26justin_smithretrogradeorbit: why do you use ->> twice on lines 35 and 36 instead of using one ->> starting on line 34?
00:26justin_smith(->> d-map (keys) (filter ...) (reduce ...))
00:27retrogradeorbitjustin_smith: nice. yes!
00:28justin_smithretrogradeorbit: similarly on line 26, instead of ->> inside ->, you could just use ->>
00:28retrogradeorbitof course, cause they're all single arity
00:28justin_smith(->> d-map (keys) (sort) (take-while ...) (last) (d-map))
00:31retrogradeorbitso when do you thread, and when do you nest?
00:31retrogradeorbitis there some thinking around this?
00:31retrogradeorbitor is it just do what you want?
00:31justin_smithI nest when it's less than four calls deep, usually - more than three and threading is usually clearer.
00:32justin_smithbut I think this is a preference thing, some prefer never to use threading
00:32justin_smithsometimes let bindings are simpler than threading also
00:42TimMcretrogradeorbit: Also see as->, which expands the number of situations in which threading can be used.
00:47slim_list
03:48sztamashi, is http://dev.clojure.org/jira/secure/Dashboard.jspa the current JIRA page for Clojure? It seems to be unresponsive ATM
03:51hiredmanworks for me
03:53sztamasyes, loaded for me now as well
03:53sztamasthanks for checking
03:56sztamasvery slow though
04:35favetelinguishow can i jump to the source of the error in emacs cider from the error buffer?
05:11WickedShellcan you type hint the content of a delay'd var? IE I always know that when I deref it I will be looking at a object Foo, and currently for interopt reasons I have to hint every location where I deref the var
05:47amalloyno. but you can write a function that derefs the var, and hint that function
05:49TEttingera ha!
05:51TEttinger,(defn ^_^ ^String [a] @a)
05:51clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map>
05:51TEttingeraw
05:52TEttinger,(defn -_- ^String [a] @a)
05:52clojurebot#'sandbox/-_-
05:52TEttinger,(def at (atom "hey"))
05:52clojurebot#'sandbox/at
05:52TEttinger,(-_- at)
05:52clojurebot"hey"
05:53lokienTEttinger, whaat are you doing here?
05:58TEttingertesting what amalloy said
05:59TEttingerI wonder when gfredericks will awaken
05:59lokientoo bad irc doesn't show history
05:59TEttingergfredericks did some neat work regarding splittable immutable PRNGs
06:00TEttingerbenchmarking over here seems to show that the core of SplittableRandom, which is the SplitMix64 algorithm, is really really good on the JVM
06:02lokiensplittable immutable prngs - what does "splittable" mean?
06:03lokien"Splittable
06:03lokienPRNG
06:03lokiens,
06:03lokienin contrast to linear
06:03lokienPRNG
06:03lokiens, allow the creation of two (seemingly)
06:03WickedShellamalloy, valid approach. I really need to learn how to write clojure macro's apparently :/
06:03lokienindependent generators from a given random number generator"?
06:03lokienoh man sorry
06:03lokienI won't ctrl+v into irc ever again
06:05TEttinger1,269,975,332 nanoseconds to generate 1,000,000,000 numbers
06:05TEttingerthat's pretty good
06:06jonathanjif i have a structure like [[1 2] [3] [4 5 6 7] [8]] what's the easiest way to end up with the same result as (+ 1 2 3 4 5 6 7 8)?
06:06TEttingerit's an extremely simple RNG, but yeah that's pretty good
06:06TEttingerI'll benchmark j.u.Random next
06:06lokienflatten and apply +?
06:06jonathanj(reduce + (mapcat identity xs)) is not really very readable
06:07jonathanjlokien: usually mentioning (flatten) gets you lynched
06:07lokienjonathanj: lynched? on #clojure? pff
06:07Bronsa(transduce cat + xs)
06:08jonathanj,(transduce cat + [[1 2] [3] [4 5 6]])
06:08clojurebot21
06:08jonathanjnice
06:08Bronsaonly works on clojure 1.7+
06:09jeayeGiven a 2D array in clojure clr, how can I access/update elements?
06:10jeayeI have a System.Single[,]
06:11TEttingerjeaye: I wondered the same thing, and the uncertainty in the docs made me hesitant
06:12jeayeI'm trying to use Arcadia and Unity is giving me this 2D array.
06:13lokienhow'd we do it in normal clojure?
06:13TEttingerlokien: it turns out java.util.Random is insanely slow generating 64-bit longs
06:13TEttingerbenchmark still running
06:14lokienTEttinger: these random numbers were 64 bit longs?!
06:14TEttinger22,837.146,419 ns to generate 1,000,000,000 longs
06:14TEttingeryes
06:14TEttingerso what one finishes in 1.2 seconds, the other takes 22.8 seconds
06:15TEttingerjeez... I thought LCG RNGs were supposed to be the fastest to make up for their shoddy quality
06:15lokienlet's write a blogpost about how clojure is faster than java :^) /s
06:16TEttingeroh they're both java
06:16TEttingerbut you could in theory rewrite this in clojure
06:16jonathanjjeaye: i think you want aget and aset
06:16jonathanj(at least that's how you'd do it with Java arrays)
06:16lokienTEttinger: ew, I thought it was in clojure already
06:17TEttingerit's easy enough to port
06:17lokienI wonder how much slower it would be
06:19jeayejonathanj: Nah, it's not that simple.
06:19jeayejonathanj: aget fails, saying the array isn't one dimensional.
06:19Bronsain clojure on the jvm aget works for multi dimensional arrays
06:20jeayeAs mentioned above, this is clojure clr.
06:20jeaye,(aget [[0 1] [2 3]] 0)
06:20clojurebot#error {\n :cause "No matching method found: aget"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: aget"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 80]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 80]\n [clojure.lang.Reflector invokeStaticMethod "Reflector.java" 207]\n [sandbox$eval47 invokeStat...
06:20Bronsa,(aget (into-array [(object-array [1 2 3])]) 0 0)
06:20clojurebot1
06:21jonathanj,(aget (to-array-2d [[1 2] [3 4]]) 0 0)
06:21clojurebot1
06:22jeayeRight.
06:22jeayeclojurebot isn't running on clr though.
06:22BronsaTIL to-array-2d
06:22Bronsahttps://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core.clj#L3792
06:22Bronsaclojure-clr's aget works as the clojure-jvm one
06:23jonathanjjeaye: are you passing two indices to aget?
06:23Bronsaoh, I see that comment https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core.clj#L3783
06:23jeayejonathanj: I've tried with both one and two.
06:25lokienanyone here using boot instead of leiningen?
06:25jonathanjthat comment says the author isn't sure how to discern multidim from ragged arrays, but isn't that what Array.Rank does?
06:25jonathanjhttps://msdn.microsoft.com/en-us/library/system.array.rank(v=vs.110).aspx
06:26jonathanjjeaye: can't you do (.GetValue the-array idx1 idx2)?
06:26jeayejonathanj: http://dpaste.com/0XCNMZC
06:27jeayeAh, .GetValue doesn't throw.
06:27jonathanji don't know why the clojure-clr codes doesn't use the .GetValue(Int[]) form
06:28jonathanjjeaye: when in doubt interop
06:28jeayeThank you.
06:39TEttingerlokien: I told you it was going to be ugly, right?
06:39TEttinger,(do (def state (long-array [9000])) (defn splitmix ^long [] (let [z (aset-long ^longs state 0 (unchecked-add (aget ^longs state 0) -7046029254386353132)) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 30)) -4658895280553007687) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 27)) -7723592293110705685)] (bit-xor z (unsigned-bit-shift-right z 31)))))
06:39clojurebot#'sandbox/splitmix
06:39TEttinger,(splitmix)
06:39clojurebot-304103417993225237
06:40TEttinger,(time (dotimes [n 1000] (splitmix)))
06:40clojurebot"Elapsed time: 3.276121 msecs"\n
06:40TEttingernot bad
06:41TEttinger,(time (dotimes [n 1000000000] (splitmix)))
06:41clojurebot#error {\n :cause "Unable to resolve symbol: splitmix in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: splitmix in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: splitmi...
06:41TEttinger,(do (def state (long-array [9000])) (defn splitmix ^long [] (let [z (aset-long ^longs state 0 (unchecked-add (aget ^longs state 0) -7046029254386353132)) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 30)) -4658895280553007687) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 27)) -7723592293110705685)] (bit-xor z (unsigned-bit-shift-right z 31)))))
06:41clojurebot#'sandbox/splitmix
06:41TEttinger,(time (dotimes [n 1000000000] (splitmix)))
06:41clojureboteval service is offline
06:41TEttingergah
06:41lokienD:
06:41TEttingerseriously?
06:41TEttinger,(time (dotimes [n 1000000] (splitmix)))
06:41clojurebot"Elapsed time: 138.176458 msecs"\n
06:42TEttinger,(/ 1.0 7.0)
06:42clojurebot0.14285714285714285
06:42TEttingerstill under a seventh of a second for a million
06:42lokienit hangs in my repl
06:42TEttingeris state defined?
06:43TEttingermaybe dotimes doesn't like a certain number
06:43lokien(time (dotimes [n 1000000000] (splitmix))) -> "Elapsed time: 52572.653161 msecs"
06:43TEttingerhm!
06:43TEttingernot as good, wonder why
06:44lokien1000 000 -> 68.64 msecs
06:45TEttingerI mean, the java code relies on integer overflow all over the place
06:45TEttingerso that's why I needed unchecked variants
06:45lokienumm, how?
06:45TEttingerit's really ugly in clojure
06:45lokienhow can you benefit from that?
06:45TEttingermost RNGs do
06:45lokienTIL programming is spooky
06:46TEttingerit assigns massively higher numbers than can fit in 32 or 64 bits, then it wraps around semi-"randomly" (it's 100% predictable but seems random)
06:47lokienso, pretty much useless for any crypto stuff
06:47TEttingeroh yeah this is not a crypto generator
06:47TEttingerin fact
06:47lokien /dev/urandom is good enough for crypto junkies, I heard
06:47TEttingerI have a function that, given a state, will tell you what state you will have after generating n numbers (or go back to previous states)
06:48lokienTEttinger: what for?
06:48TEttingerin java it's: long skip(long advance)
06:48TEttinger {
06:48TEttinger return state += 0x9E3779B97F4A7C15L * advance;
06:48TEttinger }
06:48TEttingergah
06:48TEttingerthat was one line in my IDE!
06:49TEttingerhowever that constant is too large for a long in clojure, you need
06:49TEttinger,(unchecked-long 0x9E3779B97F4A7C15)
06:49clojurebot-7046029254386353131
06:49TEttingernot sure why Java allows unsigned longs
06:50TEttingerand they even compile to signed ones I think
06:50lokiencan't you use unchecked math at the beginning, once?
06:50TEttingeryou can set it but not in the bot
06:51TEttingerand yes that would help with almost all those long calls
06:51TEttingerunsigned-bit-shift-right is not an unchecked thing, it's the >>> operator in Java
06:51Bronsajava doesn't allow unsigned longs
06:51TEttingertry it Bronsa
06:51Bronsathere's no unsigned type in the jvm
06:51TEttinger0x9E3779B97F4A7C15L
06:51TEttingerI know
06:52TEttingerbut that acts like the sign bit is part of the literal and not as a negative sign
06:52lokienTEttinger: have you seen benchmark game programs in clojure? they're hella ugly
06:52TEttingerin many languages
06:52lokienin every language
06:52lokienit's hand crafting assembly
06:53lokienI wonder how would it look if all languages just used their idiomatic, readable code
07:33lokienhey, how can I treat .boot files as .clj files in vim? it's very frustrating that I don't have any highlighting nor auto indentation in here
07:34lokienI'm using vim-plug if it helps
07:49jeayelokien: au BufNewFile,BufRead *.boot set filetype=clojure
07:53lokienjeaye: thank you very much
07:53jeayeSure.
07:54lokienI was desperate enough to mv build.boot build.boot.clj :(
09:10TMAlokien: also adding this line to the bottom/top several lines of the file helps ; vim: set ft=clojure :
09:14TMAlokien: see :help modeline for details
09:21gfrederickslokien: did TEttinger3 point to https://www.youtube.com/watch?v=u0t-6lUvXHo and https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/random.clj?
09:24lokiengfredericks: no
09:25lokienTMA: I'll check this out
09:26lokienTMA: will this set every file to be a clojurey one?
09:29lokiengfredericks: nice diagrams. I'll bookmark it and watch it after I'm done with cljs intro
09:45lokiennoncom: hello
10:08lokien_gfredericks: I got lost after like 15 minutes
10:09lokien_but it's an interesting talk
10:26gfrederickshaha
10:26gfredericksmy apologies
10:27gfrederickscommunicating is hard
10:30lokien_gfredericks: nah, that's my fault
10:31lokien_I don't get concepts that quickly and I barely know rng stuff
10:43TMAlokien_: the jeaye's method [if put into .vimrc] will make every *.boot file clojurey -- my suggestion will make the file this modeline is in clojurey, but not others
10:44TMAlokien_: the jeaye's method will make all *.boot clojurey just for you, whereas the modeline will make the particular file it clojurey for everyone using vim
10:45TMAlokien_: these are the main tradeoffs
10:45lokien_TMA: okay, I'll use your solution then
10:45TMA*file it is present in
11:06qsysif I have a collection of items and want to turn this into a list of vectors of every first and third item... what's the best/cleanest way to do that? (item1 item2 item3 item4 item5 item6) shoud be transformed into ([item1 item3] [item4 item6])
11:07justin_smith,(map (fn [[a b c]] [a c]) (partition-all 3 (range 1 7)))
11:07clojurebot([1 3] [4 6])
11:08qsyslol, easy, thx!
11:10qsysit's always easier than I think...
11:10justin_smiththe more you use all the core functions, the easier it is to see how to use and compose them to get your result
11:11qsysit's partition-all I couldn't think of :p
11:22justin_smithin case one forgets it exists, it could be something like --
11:22justin_smith,(defn part ([n coll] (part n n coll)) ([n step coll] (when (seq coll) (lazy-seq (cons (take n coll) (part n step (drop step coll)))))))
11:22clojurebot#'sandbox/part
11:22justin_smith,(part 3 (range 1 7))
11:22clojurebot((1 2 3) (4 5 6))
11:27late20hey! i have (() ([1 2]) () ([3 4])) and would need to get ([1 2][3 4]), so need to get rid of the inner lists. can't figure out any good way...
11:27justin_smith,(filter seq ' (() ([1 2]) () ([3 4])) )
11:27clojurebot(([1 2]) ([3 4]))
11:28justin_smithahh, wait
11:28justin_smith,(apply concat ' (() ([1 2]) () ([3 4])) )
11:28clojurebot([1 2] [3 4])
11:28justin_smithlate20: if you got that list via "map", you can just replace "map" with "mapcat" btw
11:37engblomI wonder if refs is the tool I need in this case: I a single state I need want to update in a threadsafe way. The state update function takes a few steps and while it is running, I want reading of the state to be blocked.
11:37justin_smithengblom: there is nothing in clojure that blocks reading while an update is in process
11:37justin_smithengblom: with refs, agents, atoms, you just read the old value while it is mid update
11:38engblomjustin_smith: Is not dosync doing it?
11:38justin_smithno
11:38justin_smithengblom: dosync makes sure they read the old value, or the final one
11:38justin_smithit doesn't block reading
11:38engblomWhat if I wrap the places where it is read also with a dosync?
11:39late20justin_smith: sweet, thanks!
11:39justin_smithengblom: then you'd get retries, and eventually it would return the new value
11:39justin_smithengblom: but it's still not blocking, it's just forcing the code to run again
11:40engblomjustin_smith: So the effect is still that I get the new value and not the old if I wrap the @ with dosync?
11:40justin_smithif there's any overlap, yeah
11:40engblomOk, thanks! That is what I want
11:42engblomMy exact case is this: If I have a stepper motor and its 8 phases that I want to store in a ref. I need to both change the ref and the stepper motor together, so if anything would want to read the state of the motor, it would always be right.
11:48lokien_I'm trying to learn cljs, but I'm spooked by html and css. do we have any wrapper around these?
12:03favetelinguis,(let [a "3"] (case a (str 3) "ETT"))
12:03clojurebot#error {\n :cause "No matching clause: 3"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching clause: 3"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n [clojure.lang.Compiler eval "Compiler.java" 68...
12:03justin_smithfavetelinguis: case only allows literals
12:04justin_smithfavetelinguis: that clause matches str or 3, but not "3"
12:04justin_smith,(case str (str 3) :OK)
12:04clojurebot#error {\n :cause "No matching clause: clojure.core$str@e9ea392"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching clause: clojure.core$str@e9ea392"\n :at [sandbox$eval51 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval51 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval51 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n ...
12:04justin_smithhmm
12:04justin_smith,(case :str (:str 3) :OK)
12:04clojurebot:OK
12:06favetelinguiswhat i want to do is something like this
12:08favetelinguis,(let [in-msg :key2 m {:a :key1 :b :key2}] (case in-msg (:a m) "A" (:b m) "B"))
12:08clojurebot#error {\n :cause "Duplicate case test constant: m"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Duplicate case test constant: m, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "Duplicate case test constant: m"\n :at [clojure.co...
12:08justin_smithfavetelinguis: right, that is impossible
12:08justin_smithuse cond instead
12:08favetelinguisok thanks will look that up ty
12:08justin_smithcase only allows literals
12:13bcoburn_,(let [a "3"] (case a "3" "ETT"))
12:13clojurebot"ETT"
12:14bcoburn_oh I see
12:14bcoburn_Ignore my sillyness
12:15justin_smith,(case 'str (str 3) :OK)
12:15clojurebot:OK
13:01favetelinguisare there any restrictions on how to require records? im trying to require a defrecord but getting the error it cant be found...
13:04justin_smithyou require namespaces, not records
13:04justin_smithyou can import the class, but the class won't exist for importing until the namespace is required
13:07favetelinguishmm i have a prismatic schema required as s then i have a s/defrecord MyTypeSchema in ns a, then in ns b i want to do (s/validate MyTypeSchema in-value)
13:07justin_smiththen you need (:require [a :refer [MyTypeSchema]])
13:08justin_smithor you can do a normal require, and use a.MyTypeSchema
13:08favetelinguisgetting an error when doing that, but then i know it shuld be no problems, must be somthing else then
13:08justin_smithsorry, a/MyTypeSchema
13:09justin_smithfavetelinguis: "an error"
13:09favetelinguisNo such var...
13:13favetelinguisanyone uses cider in emacs here and knows how to jump to file of error from the error buffer? I found M-g s should do this but it does not work...
13:49favetelinguisjustin_smith: no mather what i try im not able to use a record defined in ns a in ns b, im following the recomendations of first require the ns a than explicitly import the record but still the var can not be found, might there be somthing else im missing?
13:58favetelinguisnewer mind i was using it wrong with prismatic schema
14:01justin_smithfavetelinguis: working demo https://gist.github.com/noisesmith/265d375137b842d055dd
14:01justin_smithbut it sounds like you solved it already
14:34favetelinguisjustin_smith: the thing is i wanted to record class and not the constructor function
14:35favetelinguisbut i got it working when i realised that the imported class is accesed using ClassName. not only ClassName :)
14:37favetelinguisif an exception is thrown in a go block will that be propagated and diplayed or will the go block only siliently die?
14:41favetelinguis (timbre/info "HERE")
14:42favetelinguisThis is what i want to do but i want to exeption to be propagated no EX never prints (a/go (Thread/sleep 2000) (println "ONE") (throw (Exception. "EX")) (println "TWO"))
14:43justin_smithfavetelinguis: yes, you need a try catch that prints inside the go block if you want it to print
14:44justin_smithfavetelinguis: also, updated that example https://gist.github.com/noisesmith/265d375137b842d055dd
14:51favetelinguisthanks, however i never go that workign with the prismatic schema defrecord macro, and use it with validate.
16:15lambda-11235When is hasheq used for symbols?
16:57gfredericksprobably when putting them in a hash map?
16:57lokien_what does ^ before a value do? it's hard to google
16:57gfredericks,(hash 'foo)
16:58clojurebot-1385541733
16:58gfredericks,(meta ' ^foo bar)
16:58clojurebot{:tag foo}
16:58gfrederickslokien_: ^ is part of metadata syntax
16:58gfredericksit doesn't go before a value by itself
16:58gfredericks,(meta ' ^a-symbol ^:a-keyword ^{:a :map} the-real-value)
16:58clojurebot{:a :map, :a-keyword true, :tag a-symbol}
16:59gfredericks↑ three had syntaxes
16:59gfrederickss/had/hat/
17:00gfredericks,(set! *print-meta* true)
17:00clojurebot#error {\n :cause "Can't change/establish root binding of: *print-meta* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *print-meta* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval97 invokeStatic "NO_SOURCE_FILE" -1]\n [sandbox$eval97 invoke "NO_SOURCE_FILE...
17:00lokien_gfredericks: why would I need that?
17:00gfredericks,(binding [*print-meta* true] (print-str 'foo))
17:00clojurebot"foo"
17:00gfredericks,(binding [*print-meta* true] (print-str '^a-symbol ^:a-keyword ^{:a :map} foo))
17:00clojurebot"foo"
17:01gfrederickshrmph
17:01MordusIs it an antipattern to use an input channel and output channel when using something like Chord? The documentation talks about the channels being two way, but I can't wrap my head around how to use the channel in both directions
17:01gfrederickslokien_: it's mostly used for compiler flags & annotations
17:01gfrederickse.g., type-hints
17:02lokien_ ^{:key item} - it's from reagent intro.
17:03gfrederickswhenever you see a form like that, it's attaching metadata to the next thing
17:03gfredericksso if we did this:
17:03lokien_it says something about unique keys to every item
17:03gfredericks,^{:key item}
17:03clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:03gfrederickswe'd get a syntax error since there was nothing to add the metadata to
17:03lokien_so we'd need item declared earlier, right?
17:04gfredericksyeah that too
17:04gfredericks,^{:key item} [:still-won't-work]
17:04clojurebot#error {\n :cause "Unable to resolve symbol: item in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: item in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: item in this co...
17:04lokien_(why would it work anyway?)
17:15justin_smithlokien_: reagent uses metadata before items in collections in order to track the "identity" to know how items should move if the list is altered
17:15justin_smithlokien_: since the object identity isn't helpful with clojure, it needs some other marker to know which entry is which in a table or list etc.
17:17lokien_justin_smith: well, thanks. is there any good tut about reagent besides intro?
17:17lokien_I hate how clojure tutorials assumed I know java, and now cljs tutorials assume I know js and html
17:18ridcully_i dont use reagent, but "the others" usually allow the :key just fine with the attributes
17:19lokien_ridcully_: kay, I'll take this approach
17:19ridcully_at least give it a try. e.g. [:td {:key ...} "zerg"]
17:20Deraenlokien_: Re-frame has good Reagent tutorials: https://github.com/Day8/re-frame/wiki#reagent-tutorials
17:20lokien_I don't know with what, I don't understand a word from this weird code :^)
17:21lokien_Deraen: you saved my life. they're kind of short though
17:22DeraenAnd yes, Reagent allows key attribute. Metadata is useful when the element is another component, ^{:key 1} [list-item item]
17:34austrinusW abh-
17:40princesohow do we name it when we do this (:key {:key 1}), im calling it like 'left key call'
17:41justin_smithinvoking a keyword
17:41justin_smithcalling a keyword
17:41justin_smithif it's not on the left, you aren't calling it
17:41justin_smith,(:ho :ho :ho)
17:41clojurebot:ho
17:42lokien_and what does @ do, before a value?
17:42kwladykaWhat is the point of "complement" function? Personally i feel this is a first step to make unnecessary functions in Clojure.
17:42justin_smith,'@foo
17:42clojurebot(clojure.core/deref foo)
17:42justin_smithlokien_: ^
17:43justin_smithkwladyka: it's extremely useful
17:43justin_smith,(def not-zero? (complement zero?))
17:43clojurebot#'sandbox/not-zero?
17:43kwladykajustin_smith why not "not" instead? :)
17:43justin_smith,(not-zero? 1)
17:43clojurebottrue
17:43justin_smithkwladyka: try doing that with not
17:44justin_smithkwladyka: not is for negating a single result, complement is for creating the opposite predicate
17:44justin_smiththese are not the same thing
17:46lokien_justin_smith: eww, all these complicated words in docs.. why can't I just (println "hello world") till my program builds itself
17:49princesojustin_smith : thx . :D
17:49kwladykajustin_smith ok it makes a few lines less but the true value will be if editors could show parameters from inner function
17:49justin_smithlokien_: in my experience some programming concepts are not useful until you make the terrible mistakes that go with not understanding them yet
17:52justin_smithlokien_: you can consider each big word you don't get an attempted solution for a mistake you haven't made (or maybe made but didn't understood) yet
17:53lokien_justin_smith: I'll read "clojure for the brave and true" chapter about it, so I won't do this mistake (which I didn't do) again
17:53justin_smithheh
17:54Glenjaminthe trick when learning programming (imo), is to realise that mistakes don't really cost anything
17:54Glenjaminyou can just try stuff, and if it doesn't work, try something else
17:54justin_smithGlenjamin: depends on what time's worth, yeah
17:54Glenjaminit's not like building a bridge, or a wall
17:55lokien_anyway, does anyone know where is j-pb? he promised to help me and now he's gone
17:55bcoburn_I find that I waste less time making mistakes than I do worrying about all the mistakes I might be making
17:55kwladykalokien_ i really recommend watch clojure inside out if you are learning and want to understand what is and what not is Clojure
17:56lokien_kwladyka: is it a talk or something?
17:56kwladykalokien_ video
17:56kwladyka"clojure inside out" - the title
17:56lokien_kwladyka: another sleepless night, thanks
17:57kwladyka;)
17:57lokien_Glenjamin: I don't like any of this cljs stuff, how do I build a website in clojure? :^)
17:59kwladykalokien_ there you have courses http://www.purelyfunctional.tv , one of them is about ClojureScript and OM
17:59kwladykaand generally they will help you to learn faster
18:00lokien_kwladyka: are they free? this site is so ugly on mobile
18:00lokien_welp, they aren't
18:00kwladykalokien_ no, you have to pay but it is worth that
18:00kwladykagenerally things where you have to pay are better...
18:00lokien_the problem is, I have like four dollars
18:01lokien_which is kinda good, since I had three last week
18:01kernasilokien_, that website looks like shit even on a pc with a big screen :)
18:02lokien_kernasi: why would I pay them then /:
18:02lokien_I know, I know, maybe courses are okay
18:02kernasiheh
18:02kwladyka4clojure.com <- this is free place where you can learn a lot
18:03kwladykajust add the best users to fallow they solutions
18:03kwladykaand after do task you can compare your solution with they
18:03kwladykaand learn a lot
18:03kernasikwladyka, that's useful, thanks
18:04lokien_kwladyka: I knew that it existed, I just want to learn how to use react :^(
18:04kernasieww :P
18:05kernasikwladyka, nice, now I know how I can waste my weekend :)
18:05kwladykalokien_ just choose Rum, Om or another tool and start doing it :)
18:06lokien_kernasi: have you seen advent of code? :^)
18:06lokien_kwladyka: right now I'm trying to get reagent to work, kind of
18:07kernasilokien_, no, just projecteuler
18:07lokien_kernasi: check it out
18:10FrozenlockIs there a situation where 'with-test' is acceptable? It seems I always only see separate test namespaces.
18:42gfredericksone question you might find relevant is if `lein test` supports it out of the box
19:25lrctrying to reify a ConvergenceChecker from http://goo.gl/7B5Q4q. Clojure can't find matching method, and none of my attempts to hint the types have worked either. Is the use of <PAIR> complicating things, I wonder...
19:28justin_smithyou shouldn't need to hint the method, does your reify provide "this"? because that's manditory and not providing it can make it look like an invalid method
19:29justin_smith(reify ConvergenceChecker (converged [this iteration previous current] ...))
19:30lrcyup, my code looks just like that. It gets a reflection warning in lein check, though. (Maybe that's not authoritative?)
19:32lrcactually, hold on a moment. The reflection warning is actually further in the method. Maybe I have to hint the call.
19:34lrcthat was it. When I got reflection warnings further along, I tried to include the type hint in the parameter list, but then Clojure couldn't match the method for reify.
19:34lrcAdding a type hint at the call site for those last two params has done the trick. Thank you!
19:34justin_smithnp, glad you got it sorted out
21:49MordusI just started an app using chord, and I'm noticing some strange behavior, I can only send 128 messages through my websocket. Anyone experience this? Is there a setting that's not right or something?
21:54hiredmanwell, there are three places to check, the producing side, the consuming side, and the middle
21:54hiredmanthe first thing to check is, are their errors in any of those three places
21:55hiredmanstacktraces, exceptions, entries in the console log or however you find errors in the browser
21:57Mordushiredman, I'm an idiot. Thank you. Websockets were timing out
22:00hiredmango forth and debug
22:01pilnegosh darn it, finding a color theme in atom that will hilight & is proving to be quite difficult
23:11lambda-11235Does comparing symbols have a time complexity of O(1)?
23:14justin_smithlambda-11235: worst case is two uninterned symbols, that are long and differ at the end I think...
23:14justin_smiththis might be where hashCode comes in...
23:20lambda-11235justin_smith: But symbols are interned in clojure, and compared using this fact, right?
23:21lambda-11235It's hard to tell looking at Symbol.java.
23:25justin_smithlambda-11235: I am not certain they are all interned - if they are the overhead is all aborbed at symbol creation time of course
23:25justin_smithlambda-11235: I'm going to do a microbenchmark....
23:31lambda-11235Symbol.intern doesn't appear to actually do anything, what am I missing?
23:32justin_smithlambda-11235: looks like ~O(n) imperically https://gist.github.com/noisesmith/2abff5c61244452835b4
23:32justin_smithempirically, however we spell that
23:32justin_smithsorry, I mean O(1)
23:34justin_smithlambda-11235: I assume you are looking here? https://gist.github.com/noisesmith/2abff5c61244452835b4
23:36lambda-11235justin_smith: At the site you just posted, yeah.
23:36justin_smithoops, I didn't mean to paste my gist twice
23:37justin_smithI meant to link to here https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Symbol.java#L58
23:38lambda-11235justin_smith: That, and the method right above it.