#clojure logs

2013-12-31

00:01alewrovar: (as-> x (get-in x bar [:users "root" :items]) (vals x) (mapcat vals x) (apply (partial merge-with list) x))
00:01rovarnot familiar with either of those, I'll go look them up.
00:02rovarwhere does one find as-> ?
00:02justin_smithclojure 1.5
00:02rovardoesn't seem to be in clojure.core, and google isn't much help
00:03justin_smithit is in clojure.core in 1.5+
00:03rovar,(help as->)
00:03clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:03alewI used it wrong slightly
00:03TEttinger,(doc as->)
00:03clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
00:03justin_smith,(doc as->)
00:03clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
00:03rovarno clojuredocs for 1.5?
00:03alewshould be (as-> <stuff to thread> <var> ... <forms>)
00:03justin_smiththe source of as makes it very clear
00:03justin_smith$source as->
00:03lazybotSource not found.
00:03TEttingerclojuredocs hasn't been updated since 1.3
00:03justin_smith:(
00:05rovarhuh
00:05rovarthat's kind of cool
00:06justin_smithhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6832
00:06justin_smithvery simple macro
00:06justin_smithkind of beautiful actually
00:06lsdafjklsdit just allows you to place the argument?
00:06justin_smithyeah
00:06lsdafjklsdinstead of ((expr))
00:06lsdafjklsdall the time
00:06justin_smithin each step the magic symbol gets a new value
00:07justin_smithright
00:07justin_smithbut it is more verbose, because you have to always explicitly paste the threaded value
00:07justin_smithand you always need the full parens because of that
00:09rovarmm.. unsupported binding form for (get-in x [:blah])
00:10justin_smithas-> expr name
00:10justin_smiththat trips me up
00:10justin_smith( would expect as-> name expr
00:10justin_smith*I
00:11hiredmanif you want to use as-> in the middle of a -> you need the expr to come first
00:11radixis #(identity ...) a common pattern, or is there some more concise spelling?
00:11seancorfieldbecause it expects to be used inside (-> ...) ;; yeah, what hiredman said
00:12radixI mean, (fn [] ...) is shorter I guess...
00:12rovar(as-> (get-in x bar [:users "root" :items]) x (vals x) (mapcat vals x))
00:12hiredmanradix: your question doesn't make sense
00:12radixhm.
00:12seancorfield(-> stuff (as-> x (vals x) (mapcat vals x)))
00:12radixI found myself writing #(identity ...) and was wondering if that's something that's normally acceptable.
00:13rovarom nom
00:13hiredmanidentity requires one arg, args in side #() are always % so #(identity ...) has to be #(identity %) which is just identity
00:13radixummm
00:13hiredmanthe (fn [] ...) you gave doesn't have an arg, so it can't be identity
00:13radixI didn't use % anywhere
00:13radixso, let me use a more complete example
00:13radix#(identity "foo")
00:14seancorfield(constantly "foo") perhaps?
00:14hiredman,(doc constantly)
00:14clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
00:14radixok, cool, that helps :)
00:15TEttingerhm. before my friend spends countless hours running this code, can anyone tell me if there is something I'm missing about this line? https://gist.github.com/nlacasse/4630592#file-dbpedia-clj-L39
00:15TEttingerhe wants to run it over a DB of the wikipedia dump
00:15TEttingerbut (atom (transient {})) shouldn't work if he never calls persistent! right?
00:17justin_smithget works on transients, so it should all work from a quick scan
00:17radixI'm looking through my code and now I found an #(identity ...) that did use an argument -- what about something like #(identity [:foo %]) ?
00:17radixis that pretty normal, or is there a better spelling for that?
00:18justin_smith#(vector foo %)
00:18justin_smithwell make foo a keyworkd, but you know
00:21hiredman#(identity [:foo %]) almost certainly means you should be using for instead of map
00:21TEttingerjustin_smith, just tried it, it does not work because atoms can call in a different thread
00:22TEttinger,(let [id-map (atom (transient {}))] (swap! id-map #(assoc! % :foo "bar"))) ;; this works because they share scope
00:22clojurebot#<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@322765>
00:22hiredmanTEttinger: a transient is a sort of mutable thing, but it inside a reference type doesn't make sense
00:23TEttingeryeah.
00:23TEttingerthat's what I don't understand
00:23hiredmanTEttinger: so don't do that
00:23TEttingerit isn't my code!
00:23hiredmanso don't use that code
00:24TEttingerI'm thinking of enclosing the area that uses that transient in one larger fn
00:25TEttingerso it is guaranteed to stay in the same thread and not need an atom
00:27zerokarmaleftanyone have an example of mocking an friend/authenticated ring request?
00:29justin_smithzerokarmaleft: a ring request is a map, so if you put in the appropriate parameters you should be able to pass that to the handler and verify it responds properly
00:29justin_smiththe body should be an input stream, you can make one out of a string
00:31zerokarmaleftjustin_smith: I'm using ring.mock.request, I just added authentication and I'd like to be able to test around that
00:33justin_smithtest around it as in test the things without the authentication step?
00:33zerokarmaleftjustin_smith: right, to mock it out
00:33justin_smithin that case your best bet is likely to break the code into pure functions where you know their expected inputs and outputs
00:33justin_smithand commpose those into your handlers for the app
00:38zerokarmaleftI suppose I'm not understanding how friend handles a currently authenticated user
00:40justin_smithhave you checked if it puts anything in :session ?
00:42zerokarmaleftjustin_smith: here's a bit more context => https://www.refheap.com/22330
00:44justin_smithI see wrap-authenticate defined, and then a call to wrap-authenticated
00:45zerokarmaleftsorry, typo pasting it refheap
00:45justin_smithand where is request defined? is that ring.mock/request?
00:46zerokarmaleftyea, ring.mock...following the trace I'm not sure why current-authentication is called with nil
00:47zerokarmaleftor rather, why *identity* is never set to anything
00:47zerokarmaleftI suspect it's because I'm bypassing an actual workflow, but I'm not sure
00:48justin_smithI've been meaning to figure out how friend works, but frankly I don't get most of it, sorry
00:49zerokarmaleftjustin_smith: yea
00:50zerokarmaleftjustin_smith: we should have jackets made
00:50justin_smithhah
00:50justin_smiththe "I don't get friend" gamg
00:54rovar,((apply comp '(inc inc inc inc)) 0)
00:54clojurebotnil
00:54rovar:(
00:55rovarwhat I do wrong?
00:55justin_smith,((apply comp [inc inc inc inc]) 0)
00:55clojurebot4
00:55justin_smith,(map class '(inc inc inc inc))
00:55clojurebot(clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Symbol)
00:55rovarah
00:55rovarright
00:55justin_smith,(map class [inc inc inc inc])
00:55clojurebot(clojure.core$inc clojure.core$inc clojure.core$inc clojure.core$inc)
00:56rovar,((apply comp (list inc inc inc inc)) 0)
00:56clojurebot4
00:56dnolen,((apply comp [inc inc inc]) 0)
00:56clojurebot3
00:56zerokarmaleft,(nth (iterate inc 0) 4)
00:56clojurebot4
00:58zerokarmaleft@seen cemerick
00:59justin_smith$seen cemerick
00:59lazybotcemerick was last seen quitting 6 hours and 10 minutes ago.
01:00radixhiredman: sorry, missed your response. actually it's in the context of a :content handler in the Lucuma clojurescript library
01:00radixbut I'll just use (fn)
01:12jonasenWhat's a good clojure library for running shell script (which reads from stdin and writes to stdout)?
01:22ddellacostajonasen: does conch do what you want? https://github.com/Raynes/conch I've found it useful.
01:26jonasenddellacosta: I think so. Thanks!
01:26ddellacostajonasen: any time!
01:27justin_smithjonasen: I have had good luck with the ProcessBUilder class
01:27justin_smithgood fine-grained control of what to do with STDIN STDOUT STDERR of a shell process
01:28justin_smithoh, I see he uses ProcessBuilder in conch
01:33ddellacostayeah, it's pretty handy, you can get all the different output and data about the operation in a hash-map if I recall correctly
01:40jonasenddellacosta: justin_smith: conch worked great!
01:40ddellacostajonasen: excellent. :-)
01:43justin_smithcool
01:48marcopolo`conch looks pretty cool, is there anything like it for cljs+node?
02:56seriously_randomis this reduce totally wrong? http://pastebin.com/eb6bjVke
03:04marcopolo`seriously_random: on line 7 it looks like you are trying to treat the seq returned from my-map as a function
03:05marcopolo`I think what you want is a loop/recur
03:05marcopolo`,(doc loop)
03:05clojurebot"([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target."
03:06marcopolo`This page explains it a bit better http://clojuredocs.org/clojure_core/clojure.core/loop
03:10andyfseriously_random: The first one in my-map-one, or the second one?
03:11andyfIf the first, my guess would be that since concat is lazy, it would either cause very deep stack usage if called on a long sequence, and even if it did not blow up the stack it might use O(n^2) time
03:13andyfThe second reduce seems like it cannot do what you wish it to (i.e. cause f to be called with 2 or more arguments), because the call to (my-map f a-seq) will always call f with 1 arg.
03:15seriously_randomandyf, reasonable would to write f for two sequences?
03:25turbopapeHi guys,
03:25turbopapeSorry If I already asked,
03:25turbopapeBut did anyone use http-kit as a heavy load reverse proxy ?
03:29chinmoyHow can i make parallel http requests in clojure?
05:20bitemyappTimMc: what is a "string" to a TCP socket?
05:21bitemyappTimMc: if I pass the straight binary of a "string" from a Golang client directly into a TCP socket to a Java TCP server, what happens?
05:28Clomewhat does N mean in clojure, example 3N
05:28TEttingerClome, BigInteger
05:28TEttingeror BigNumber
05:29TEttinger,(class 1N)
05:29clojurebotclojure.lang.BigInt
05:29TEttinger,(class 1M)
05:29clojurebotjava.math.BigDecimal
05:29Clometnx
05:29TEttingerBigDecimal is very handy when you use with-precision
05:30TEttinger,(with-precision 4 (/ 2M 3))
05:30clojurebot0.6667M
07:20seriously_randomneed some hints for why the nestedness is happening: http://pastebin.com/Jn04vE19
07:27justin_smith(cons (f (first seq-1) (first seq-2)) (my-map-two f (rest seq-1) (rest seq-2)))
07:28justin_smithit conses the result of the function on the first two, to the recured value
07:28justin_smithI think that would do it
07:30sbhuiyanhello, got an interesting issue trying to use not-any? in a REPL, if I try (not-any? nil? ("test" nil)) I get false which is as expected. But if I have a (def account nil) and try (not-any? nil? '("test" account)), I get true
07:30justin_smith,(map class '("test" account))
07:30clojurebot(java.lang.String clojure.lang.Symbol)
07:30justin_smitha quoted list does not get its contents evaluated
07:31justin_smithtry (list "test" account) or ["test" account]
07:32sbhuiyangreat
07:34sbhuiyanThanks Justin. I was going for a list but guess didn't understand '() vs list. I do now
08:05seriously_randomjustin_smith, excuse my impatience, but where did I make a mistake here: http://pastebin.com/Y9sxySRT
08:12justin_smith(f (first-of-all seqs)) should likely be (apply f (first-of-all seqs))
08:18seriously_randomjustin_smith, I seem to have hit infinite loop.
08:21seriously_randomlight table is kinda buggy with stopping infinite loops
08:24justin_smithseqs in my-map-helper won't be empty
08:24justin_smith(empty? [() () ()])
08:24justin_smith,(empty? [() () ()])
08:24clojurebotfalse
08:24justin_smiththat is the case you are missing
08:25seriously_randomchanged to (empty? (first seqs)), still hitting nullpointer
08:26justin_smithwell, clearly we fixed one bug and hit another!
08:28justin_smithalso, just a little thing - (defn my-map-one [f a-seq] (reduce #(conj % (f %2)) [] a-seq))
08:28justin_smithmuch simpler, does the same thing
08:30seriously_randomjustin_smith, the bug has to be something simple http://pastebin.com/RSzBPHQ5
08:32seriously_randomjustin_smith, looks like end condition is incorrect
08:32justin_smithvery likely, yeah
08:33justin_smithare you familiar with let?
08:33justin_smithusing let to break things down into steps can help
08:35ClomeNested :keys destructing is not allowed on a map?
08:35pyrtsaClome: How would you nest it?
08:36mrhankyanybody tried iterating with a for-loop over js localstorage on window.load ?
08:37Clome[{:keys [{:keys [x1 y1 z1]} v1 v2 v3]} triangle] something like this ?
08:37seriously_randomjustin_smith, my base case should be if rest-of-all is empty. But that doesn't explain why vector works
08:37pyrtsaClome: But what key would x1, y1 and z1 be found on?
08:38Clomex1 y2 z1
08:38Clome [{:keys [{x1 y1 z1} v1 v2 v3]} triangle] or at least something like this?
08:38pyrtsaOh, I see. That doesn't seem like nesting, more like merging to me.
08:38justin_smith,(let [{{a :a} :b} {:b {:a 0}}] a)
08:38clojurebot0
08:39Clomei meant [{:keys [{x1 y1 z1} v2 v3]} triangle]
08:39justin_smith:keys is not written in a way that would make that work
08:39Clomeok
08:39justin_smithbut you can use regular map destructuring, as I show above
08:40justin_smithor you could destructure in steps
08:40Clomebut it is tedious :/
08:41pyrtsaClome: What does triangle look like, as a data structure?
08:41justin_smith,(let [{:keys [b]} {:b {:a 0}} {:keys [a]} b] a)
08:41clojurebot0
08:42Clome(defrecord Triangle [v1 v2 v3]) (defrecord Vertex [x y z r g b a s t p])
08:43justin_smiththere is also get-in, as another option
08:43pyrtsa(let [{{x1 :x y1 :y z1 :z} :v1, :keys [v2 v3]} triangle) ...)
08:44pyrtsaYou can only use :keys if the local names end up being the same as the names of the keys. But in your case the keys are :x, :y, and :z, and you want to use the bindings x1, y1, and z1.
08:45justin_smith,(get-in {:b {:a 0}} [:b :a])
08:45clojurebot0
08:46seriously_randomjustin_smith, fixed. http://pastebin.com/N4jFUNBn
08:46Clomeoh right, I will try that
08:47pyrtsaClome: Another option: (let [[x1 y1 z1] (select-keys (:v1 triangle) [:x :y :z]), ...] ...)
08:48pyrtsaOr simply (let [{x1 :x, y1 :y, z1 :z} (:v1 triangle), ...] ...)
08:48pyrtsaAnd likewise for :v2 and :v3.
09:06ClomeHow come a protocol name is not a verb instead of a noun? Fly => Flying ? Does not sound better? It is a protocol about flying after all.
09:07justin_smithFly is a verb
09:07justin_smithFlying is a conjugated verb
09:07pyrtsaFly is a noun too. :)
09:07llasramA... participle even?
09:07justin_smithactually it is the adjectival form
09:08justin_smithpyrtsa: I doubt in that context Fly is being used in its noun form, though a codebase where every protocol was the animal exemplifying its action may be fun to see
09:08pyrtsa:)
09:09justin_smith(defprotocol HoneyBadger [] (not-give-a-shit ...))
09:09ddimadamn, I also thought about badger, but a WildBadger ;)
09:09pyrtsaFlies may be related to zippers too. :)
09:09justin_smithlol
09:09justin_smithtrue enough
09:11justin_smithI guess a zipper, or a button, or a velcro could all implement the Fly protocol
09:12pyrtsaI'm experimenting with a stuartsierra'esque REPL setup, and one trouble I think I managed to solve is that a protocol gets replaced, while I've still got a "defonce" instance of it I'd like to clean up after the reload.
09:13justin_smithso you want defonce to be more like def-when-reload?
09:13pyrtsaThe way I managed to get around it was by wrapping the defprotocol inside another defonce: (defonce App (defprotocol App ...)). But on a scale from zero to one, how stupid or dangerous this might be?
09:14pyrtsaWell, the problem was that the protocol defined a (stop [this]) method, and calling (stop app) after the reload errors telling that app doesn't satisfy the protocol (which is right, because it's a different protocol now).
09:14justin_smithit is definitely a hack
09:14pyrtsaYep
09:14justin_smithmaybe you could look at the source of defonce and construct do-once out of it?
09:14pyrtsaAt least Sam Aaron was playing with the hack like decades ago: https://groups.google.com/d/msg/clojure/SYYYwZIrFiY/xm_0CaARLywJ
09:15pyrtsajustin_smith: At least that'd make it even more explicit, with little benefit though.
09:16justin_smiththe trick with do-once would be making a unique identifier that would be the same identifier on each reload
09:16justin_smithI think explicitness is a huge benefit
09:16Clomeso no points for me for "conjugated verbs" :)
09:16pyrtsajustin_smith: Me too.
09:16justin_smiththe only drawback of the above is the non-conventional usage of defonce where the thing defined is a throwaway
09:16pyrtsaI'm just thinking defonce is pretty explicit already.
09:17justin_smithmaybe add throw-away or place-holder to the name of the thing defonced :)
09:17justin_smiththe problem is def is being used in a weird way there, and do-once would more clearly describe the intention of the code
09:18pyrtsaAh, I see what you mean.
09:35justin_smithpyrtsa: maybe something like this? https://www.refheap.com/22340
09:42mrhanky,(for [res ["a", "b", "c"]] (println res))
09:42clojurebot(a\nb\nc\nnil nil nil)
09:44mrhankywhats wrong with the above one? works in my web repl but not in compiled cljs files Oo
09:44justin_smith,(dorun (for [res ["a", "b", "c"]] (print res \space))) ; slightly cleaner for bot interaction
09:44clojurebota b c
09:44justin_smithmrhanky: for is lazy
09:44justin_smith,(do (for [res ["a", "b", "c"]] (print res \space)))
09:44clojurebot(a b c nil nil nil)
09:44justin_smitherm...
09:44mrhankyoh
09:45hyPiRionuse doseq instead, if you only do side effects
09:45justin_smithanyway, because it is lazy, if you don't use the result, it shouldn't be counted on to do anything
09:45justin_smith,(do (for [res ["a", "b", "c"]] (print res \space)) nil) ; actually showing laziness this time
09:45clojurebotnil
09:45justin_smiththe value was not used, so nothing was done
09:47mrhankystill not working in compiled code
09:47justin_smithmrhanky: a common beginner (and even sometimes intermediate) mistake in clojure is forgetting that the repl's print stage forces laziness, whereas your code may not
09:48justin_smithmrhanky: did you try doseq or wrapping the for in dorun?
09:49mrhankyah
09:49mrhankydorun does the trick
09:50justin_smithreplacing the for with doseq should work too, in most cases
09:51justin_smithand doall instead of dorun will return the results of whatever you do (if you care for those)
09:55mrhankyi dont get it Oo
09:55mrhanky(dorun (for [res ["consize.clj", "bootimage.txt", "prelude.txt"]] (io/file-read (str "consize/" res))))
09:55mrhankywhat am i doing wrong?
09:55jcromartiemrhanky: "dorun" is strictly for side effects, "doall" is for evaluating and returning the whole seq
09:55mrhankyoh
09:56jcromartiedorun doesn't return anything
09:57jcromartieI'd rewrite that as: (doall (map #(io/read-file (str "consize/" %)) ["consize.clj", "bootimage.txt", "prelude.txt"]))
09:57jcromartiebut for is nice too
09:58jcromartiethe fact that it's called "for" is a little confusing though :)
09:58justin_smith(doall (map (comp io/read-file (partial str "consize/")) ...)) would work too
09:58justin_smithjcromartie: it's not our fault all the algol family languages do for the wrong way :P
09:59justin_smithin all seriousness yeah, given everyone learns an algol language first, for is a bad name choice
09:59jcromartiethough I can't think of a better name :|
09:59justin_smithcartesian
10:00jcromartiea-la-descartes
10:00justin_smith,(do (def cartesian for) (cartesian [a [0 1 2] b [3 4 5]] [a b]))
10:00clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/for, compiling:(NO_SOURCE_PATH:0:0)>
10:00justin_smithmmm
10:00jcromartie:P
10:01jcromartiebut I know what you mean
10:02jcromartieI don't think clojurebot likes defn or defmacro
10:02jcromartiedoes it?
10:02jcromartie,(do (defmacro cartesian [& args] `(for ~@args)) (cartesian [a (range 3) b (range 3)] [a b]))
10:02justin_smith,(do (def a 0) a)
10:02clojurebot0
10:02clojurebot([0 0] [0 1] [0 2] [1 0] [1 1] ...)
10:02jcromartiehey, cool
10:02jcromartiethat's pretty permissive :)
10:03justin_smithjcromartie: that is what I was going for, thanks man
10:03jcromartiefor a bot
10:03justin_smith(inc jcromartie)
10:03lazybot⇒ 6
10:05justin_smithit is pretty permissive, I think there is a full env reload on some timer
10:05jcromartienow how about a macro that aliases a macro the way you wanted to
10:05justin_smithso better to put your def and the code that uses it in one do block
10:05justin_smithhmm
10:11rovarjustin_smith: did you work on jiraph?
10:11justin_smith,(do (defmacro alias-macro [new old] `(defmacro ~new [& args#] `(~'~old ~@args#))) (alias-macro unless when-not) (unless false (print "OK")))
10:11clojurebotOK
10:12justin_smithrovar: nope
10:12justin_smithjcromartie: I think I wrote that macro, see above
10:12justin_smithfirst time I have ever had to use `(~'~ in my code
10:12rovarthat looks dirty
10:13justin_smithit's just nested syntax quote
10:13justin_smithI always liked the name unless better than when-not
10:14mdrogalistbaldridge: Your Conj talk was awesome. :)
10:16rovarwhen-not is generally more clear for most people than unless
10:16rovari'm used to unless because I coded in ruby for a bit
10:16ddellacostahappy new years everyone
10:16rovarddellacosta: right back atcha
10:17ddellacostarovar: :-)
10:17mullrHappy conj-ing in the happy new year!
10:17jcromartiejustin_smith: nice
10:17justin_smith(swap! year inc)
10:17jcromartiejustin_smith: mine was way uglier
10:17mullr(inc justin_smith )
10:17lazybot⇒ 1
10:18mullrTIL the current year is mutable
10:18justin_smithheh
10:18justin_smithtil my name has a space in it :)
10:18justin_smith(inc inc)
10:18lazybot⇒ 5
10:18justin_smith(inc inc )
10:18lazybot⇒ 1
10:18mullrwoah
10:19mullr(inc justin_smith)
10:19lazybot⇒ 24
10:19mullrbetter
10:19justin_smithta
10:19justin_smith$karma juxt
10:19lazybotjuxt has karma 4.
10:19justin_smith(inc juxt)
10:19lazybot⇒ 5
10:19justin_smithI could swear I had already done that
10:19jcromartielazybot just revealed his dirty little secret: he's actually written in Perl and is just a massive collection of nasty regexes
10:20justin_smithso it seems
10:20ddellacostathat would be so hilarious
10:20justin_smiththe only known instance of cljprl
10:21justin_smith$@&clj
10:21justin_smithsomething like that
10:22ddellacosta$_ =~ eval(/()/${func_name}()/) or something
10:22ddellacostaforgotten all my perl
10:22ddellacostamercifully
10:22justin_smithwell that would be a funny name for a clojure port, but it is appropriate
10:26jcromartiehow extensively do you all use pre/postcondition maps in your defns?
10:26jcromartieI am finding myself using them a lot in important functions, but there's some discussion about turning them on or off in production etc.
10:26justin_smithjcromartie: really often I find the need to level up from a precondition to an assert
10:26jcromartieI don't see any reason to turn them off
10:26justin_smithespecially since assert has an optional string as the last arg, helps quite a bit
10:26jcromartiehm, yeah
10:26jcromartieI see
10:27justin_smith,(assert false "this always fails")
10:27clojurebot#<AssertionError java.lang.AssertionError: Assert failed: this always fails\nfalse>
10:27jcromartiebut a lot of times the precondition is explanation enough
10:27justin_smithassertions can also be turned off
10:27jcromartieyeah
10:27jcromartiebut why?
10:27jcromartieunless you were talking about really performance sensitive code
10:28justin_smithI guess some people use assertions in real code instead of unit tests
10:28hyPiRionthat's like, the whole reason why. Sometimes assertions are expensive
10:28justin_smithsometimes the property you want to assert is expensive to verify
10:28jcromartiesuer
10:29jcromartiesure
10:29jcromartieso long as I don't use expensive assertions though
10:29jcromartieor if it's for rarely-used functions, like data model functions or external API calls
10:29justin_smithand there is always "(when (bad-state?) (Throw (Exception. "WTF")))
10:29justin_smith"
10:29jcromartiethat's 99% of where I use them now: interfacing with external systems or for posterity
10:33justin_smith,(when false (throw (Exception. "WTF")))
10:33clojurebotnil
10:33justin_smith,(when true (throw (Exception. "WTF")))
10:33clojurebot#<Exception java.lang.Exception: WTF>
10:35justin_smithso when you really need to check some state you can use a when / throw type combo, and assertions are more for dev time code correctness
10:35justin_smithwhich is a little odd I think, but the ability to turn assertions off kind of forces the issue
10:36zerokarmaleft,(dec zerokarmaleft)
10:36clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: zerokarmaleft in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:36zerokarmaleft(dec zerokarmaleft)
10:36lazybotYou can't adjust your own karma.
10:36zerokarmaleftbargle
10:36justin_smith$karma zerokarmaleft
10:36lazybotzerokarmaleft has karma 1.
10:36justin_smithyo uwant that dec'd?
10:36zerokarmaleftit's only fitting :P
10:36justin_smith(dec zerokarmaleft)
10:36lazybot⇒ 0
10:37justin_smith$karma zerokarmaleft
10:37lazybotzerokarmaleft has karma 0.
10:39gdev_away(inc zerokarmaleft )
10:39lazybot⇒ 1
10:40zerokarmaleft$guards
10:40lazybotSEIZE HIM!
10:41gdev(dec zerokarmaleft )
10:41lazybot⇒ 0
10:42justin_smithman that sucks, lose all your karma and ascend to etherial enlightenment, only to have it be put on you again
10:42justin_smithoh good, he is back in his nirvana
11:27justin_smith(dec netsplit)
11:27lazybot⇒ -1
11:27mdrogalis~anaphoric
11:27clojurebotI don't understand.
11:28justin_smith~anaphora
11:28clojurebot<rhickey> anaphora == bad
11:29gfredericksclojurebot: anaphoric |are| &env and &form
11:29clojurebotYou don't have to tell me twice.
11:29justin_smith~it
11:29clojurebotit is for clojure.pprint/cl-format :)
11:29gdevwhatis anaphora
11:29justin_smithclojurebot: it is anaphoric
11:29clojurebot'Sea, mhuise.
11:29mdrogalisI just want to make clojurebot talk about barking spiders again. :/
11:29gdevlazybot, whatis anaphora
11:29lazybotanaphora is "the use of an expression the interpretation of which depends upon another expression in context"
11:29patrickodanyone here use sqlkorma and transactions with their test suite? having trouble using use-fixtures with transactions at the moment
11:30gfrederickspatrickod: what's the trouble?
11:31patrickodgfredericks I have a fixture that wraps the test in a transaction, and another which is used in *some* tests that adds a row to a table such that the test can use it
11:31patrickodbut the second one fails on teh second run because it violates a unique index on insert
11:32gfredericksyou're rolling back at the end of the test?
11:32patrickodI guess I could make it into a :once for these tests instead of :each now that I think about it
11:32gfredericksin a finally?
11:32patrickodgfredericks https://gist.github.com/patrickod/3acf16cd1b1f1807046a like so
11:33gfredericksa bit safer to do (try (t) (finally (rollback))), but if you first test isn't throwing anything that shouldn't be your problem at the moment
11:35patrickodthe exception that's stopping the test suite is thrown by the second fixture
11:35rovar,(help defalias)
11:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:35rovar,(where defalias)
11:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: where in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:36rovarclojurebot: I never liked you.
11:36clojurebotI don't understand.
11:36rovarclojurebot: how could you understand? you're not real.
11:36clojurebotIt's greek to me.
11:37rovarIt would have never worked between us.
11:37justin_smithrovar: doc
11:37justin_smith(doc defalias)
11:37clojurebotGabh mo leithscéal?
11:37justin_smith,(doc defalias)
11:37clojurebotPardon?
11:37justin_smithweird
11:37justin_smith,(do (use 'clojure.repl) (doc defalias))
11:37clojurebotI don't understand.
11:37patrickodgfredericks unless I've misunderstood though, it should be possible to have multiple fixtures set to :every?
11:38rovarit's not in core or contrib
11:38patrickods/every/each
11:38gfrederickspatrickod: yep; they probably run in the order they're added
11:38rovari'm trying to figure out where tf it is
11:38gfrederickspatrickod: use-fixtures is variadic even so you can do it in one call
11:40patrickodmaybe it's that the first fixture only wraps the test and not the second fixture?
11:40justin_smithhttps://groups.google.com/forum/#!topic/clojure/LhidPSlvX_Q rovar
11:41gfrederickspatrickod: that sounds plausible
11:41gfrederickseasy to figure out the ordering w/ debug msgs
11:42rovarso instead of making a proper defalias macro they just complained about it and left it out.
11:48patrickodhuh they overwrite each other apparently, using multiple (use-fixtures :each) in the same namespace
11:48rovar(seen amalloy_ )
11:59rovaris there some sort of moral equivalent to cond-let around?
12:00rovarI guess with lazy collections, it's not that horrible to simply build all of the potential cases and then use cond..
12:05tommo_i'm new to clojure and im having a bit of a problem, why does this not work? (def myfuture (.bind bootstrap 8080))
12:05mockerHoly crap, finally solved 4clojure #22: https://www.refheap.com/22346
12:05mockerNot pretty, but it works
12:06tommo_Cannot cast java.lang.Long to io.netty.channel.ChannelFuture
12:06tommo_by that logic .bind would evaluate to a long would it not?
12:08mockerHow should something like https://www.refheap.com/22346 be indented? Or should it just stay on one line?
12:09ddellacostamocker: a bit simpler way-- ,(reduce (fn [i _] (inc i)) 0 '(1 2 3 3 1))
12:09ddellacostawhoops
12:09ddellacosta,(reduce (fn [i _] (inc i)) 0 '(1 2 3 3 1))
12:09clojurebot5
12:10mocker,(reduce (fn [i _] (inc i)) 0 "Hello World)
12:10clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
12:10mocker,(reduce (fn [i _] (inc i)) 0 "Hello World")
12:10clojurebot11
12:10mockerNice
12:11ddellacostamocker: yeah, although, for 4clojure the struggle of doing it yourself is definitely very useful
12:11mockerddellacosta: But implementation aside (because I know mine isn't great) should it be indented?
12:11ToBeReplacedmocker: the important step in the thought process needed to be "i'm looking at a sequence, what can i do to operate on a sequence?"
12:11ddellacostawhere? I think your formatting was fine
12:11mockerOk, just not sure in clojure where/when to put newlines at.
12:12justin_smithI often like to line up the args to reduce
12:12justin_smithsince it has an optional arg that is not the last arg
12:13ddellacostamocker: yeah, for something like that, if you find it is reasonable on one line it's fine. Usually if my reduce function starts getting complex it's a smell that I should just break it out into a separate function.
12:14justin_smithalso, while the replace / map {} thing is a bit silly, you can do it more succinctly (though just as silly) with (comp {nil 1} {})
12:14justin_smith(map (comp {nil 1} {}) (range))
12:14justin_smith,(map (comp {nil 1} {}) (range))
12:14clojurebot(1 1 1 1 1 ...)
12:14ToBeReplacedmocker: indentation https://www.refheap.com/22348
12:15ddellacostajustin_smith: nice
12:15ddellacostaoh, wait
12:15ddellacostahmm
12:15justin_smithit is of course effectively (constantly 1)
12:15mockerjustin_smith: I started w/ solving the '(1 2 3 3 1) by taking each one (+ 1 (* 0))
12:15justin_smiththe whole thing is silly, like I said
12:15mockerAnd it just was a downward spiral from there to get a sequence of 1s from a string.
12:15justin_smithright
12:16mockerToBeReplaced: Thank you.
12:16TimMcbitemyapp: http://clojure-log.n01se.net/date/2013-12-30.html#23:49
12:16justin_smithmocker: also that call to vec doesn't do anything
12:17justin_smithmap already forces its last arg to a seq
12:17mockerOh, nice.
12:19justin_smith,(apply str (map (comp char inc int) "hello"))
12:19clojurebot"ifmmp"
12:21justin_smith,(apply str (map (comp char inc int) "IBM"))
12:21clojurebot"JCN"
12:21justin_smitherr
12:21justin_smith,(apply str (map (comp char inc int) "HAL"))
12:21clojurebot"IBM"
12:21justin_smiththat's what I meant
12:23lsdafjklsdIf I want to keep my route definitions and dispatch constrained to a namespace.routes file, what is the best way to include / initiate that into a namespace.core file?
12:24lsdafjklsdhave one public function that i call in the core file?
12:24lsdafjklsdand that function sets everything up
12:28mockerCrap, I've been doing the 4clojure stuff by number and not by order on the site.
12:28mockerI wonder if doing them in site order would prepare me better for upcoming questions.
12:35whompis there any way to see what line of my source code caused the problem? the stack trace is difficult to parse
12:36justin_smithwhomp: if the function was defined in a file, it will show the file/line
12:36whompohh i see it, it was in yellow lol
12:36whompty
12:36justin_smithwhomp: first thing I do is look for namespaces that are mine
12:36justin_smithreading a clojure stack trace is basically a new language you have to learn
12:36justin_smitha sucky one
12:45pandeirohow does one iterate over list items with om?
12:45zerokarmalefthttp://java.dzone.com/articles/reading-clojure-stacktraces <= a good post on mentally filtering the noise
12:46zerokarmaleftwhomp: ^
12:46whompzerokarmaleft, thanks!
12:46whompthis channel is awesome lol
12:59dnolenspecify is sweet https://github.com/clojure/clojurescript/commit/f55bb020fd27c140011fef1bd1f0c933a1719dd3
13:00bbloomdnolen: got it working?!
13:00dnolenan optimization would be to allow specify to use earlier defined functions, would save function allocations, but at 1000000 allocations ~130ms, ain't slow
13:00dnolenbbloom: already released 2138 has it
13:01ior3kdnolen: nice exchange with Avdi Grimm on twitter
13:01lsdafjklsddnolen: no idea what JS fusion reactors are.... but I like it!!
13:03dnolenior3k: it's always interesting to see smart OO folks poking around at FP, puts things into perspective
13:03dnolenlsdafjklsd: heh, just that JS engines can optimize such patterns
13:03dnolenlsdafjklsd: would be hard to make that work on the JVM
13:04ior3kdnolen: at least they're not dismissing it outright. Well, some of them aren't
13:04pandeirodnolen: can you point me to info on "Each child in an array should have a unique key prop"? I'm trying to use om/build-all to iterate over and output a list of buttons... Probably doing it wrong?
13:05lsdafjklsddnolen: nice! that's exciting as a JS dev who's work targets the browser... I mainly use clojurescript
13:06dnolenpandeiro: React wants a key, opts can take :key option to use something in your data as the key, for example :id or whatever
13:09dnolenpandeiro: I suppose I could support :keyfn which would take the index and you can generate one based on that
13:09dnolenpandeiro: if you don't want to invent one on the data itself.
13:09dnolenpandeiro: the other option is to just generate for if you not supplied
13:09dnolens/for if you/for you
13:10pandeirodnolen: no the :key :whatever in the final arg is fine for me...
13:11pandeirobut iteration being such a basic thing maybe this should make it to the README?
13:11pandeiro(just a suggestion)
13:11dnolenpandeiro: no there yet
13:11dnolenpandeiro: and probably won't be for a while
13:12dnolenmaintaing docs for this is the pits
13:12pandeirostill stabilizing stuff first i imagine
13:12dnolenso for now the goal is for the code to be approachable
13:12dnolenusers can read it, it's not that complicated :)
13:12pandeirosure, and it is; i was just impatient
13:12pandeirobtw docstrings for cljs in cider would be great
13:22whomphow can i view output from println? i don't see any buffer which has it
13:30zerokarmaleftwhomp: are you using emacs?
13:30whompzerokarmaleft, yes
13:30zerokarmaleftwith cider?
13:34zerokarmaleftthat may not matter...I believe depending on which thread is writing to stdout, nrepl will send stdout to the repl buffer or *nrepl-server ...*
13:41whompzerokarmaleft, i am using cider and i checked all of the buffers (nrepl, nrepl-server, nrepl-connection, messages, etc.) and didn't find anything
13:41lsdafjklsdwhew, set my OM project up with austin, half the day gone :D
13:44pandeirolsdafjklsd: austin is the browser repl thing?
13:45lsdafjklsdpandeiro: ya
13:45noncomcan anyone recommend a library to fuzzy-search strings? i've googled a few, but it maybe someone has some personal experience with any?
13:45lsdafjklsdpandeiro: I made a lein template to get it up and going
13:45pandeirolsdafjklsd: nice what's it called?
13:46pandeiroi am finally working through the om examples for the first time
13:47pandeirodnolen: there's a tiny bug in 'counters', just one missing (put! ...) on one of the button handlers
13:47lsdafjklsdpandeiro: it's not published on clojars, but you can clone it and install it locally here https://github.com/lsdafjklsd/haywood-austin
13:47lsdafjklsdi spent like, 3 hours just studying the counters code :-P
13:47lsdafjklsdsad
13:48pandeirolsdafjklsd: i'm on hour one but 3 sounds about right :)
13:48lsdafjklsdpandeiro: haha, good stuff!
13:51dnolenpandeiro: where?
13:52pandeirothe '-' button's click handler
13:52pandeirodnolen: ^
13:52pandeiro(put! (:last-clicked chans) (.-path data))
13:52dnolenpandeiro: what's wrong w/ that?
13:52lsdafjklsdI figured that was deliberate
13:52pandeiroit's missing on mine
13:52lsdafjklsdit only counts if you do plus
13:52pandeiro+ has it, - doesn't
13:53pandeiroyeah, ah is that deliberate?
13:53dnolenpandeiro: oh right
13:54dnolenpandeiro: thx fixed
13:55pandeirodnolen: :onChanged only works if you implement some protocol yeah?
13:55dnolenpandeiro: what do you mean?
13:55pandeiro(om/component (dom/h1 #js {:onChanged #(js/alert "hi")} "hello")) <- should alert?
13:56dnolenpandeiro: onChanged doesn't work on h1 tags
13:57pandeirodnolen: sorry maybe something else tripping me up; but dom/button with :onChange should 'just work' right?
13:58dnolenpandeiro: I don't think onChange applies to buttons either
13:58dnolenpandeiro: onChange is only for changeable form elements
13:58dnoleninput, textarea, select
13:58pandeirohttps://github.com/swannodette/om/blob/master/examples/counters/core.cljs#L25
13:58dnolenpandeiro: that's *onClick*
13:59pandeirogah
13:59pandeiroman
13:59pandeirosorry
13:59dnolenpandeiro: np
13:59lsdafjklsddude, you blew it
14:02pandeirolsdafjklsd: was lein cljsbuild auto <build-id> broken for you with the examples btw?
14:02lsdafjklsdpandeiro: no
14:02lsdafjklsdpandeiro: let me try again
14:02pandeiro'once' works but 'auto' is entering a crazy loop
14:03pandeirojust curious, no big
14:04lsdafjklsdpandeiro: yea just tested again, lein cljsbuild auto counters worked fine
14:04jcromartiePROTIP: Rebind your Mac's command key to be meta and option to be option so you can input funky unicode chars in Emacs again
14:05jcromartie(setq mac-command-modifier 'meta) (setq mac-option-modifier nil)
14:07technomancyputting meta somewhere that isn't next to space is just asking for RSI
14:08gfredericksPROTIP: rebind OSX to linux
14:08pandeirolsdafjklsd: are you using r2138 by chance?
14:08jcromartiegfredericks: I'm with you on that one
14:08jcromartiethis is my work machine :)
14:08lsdafjklsdpandeiro: in my current project?
14:08gfredericksyeah I got forced into a mac @work too
14:09gfredericksit's like the new windows
14:09lsdafjklsdpandeiro: I'm using 2134
14:09pandeirolsdafjklsd: no with the cljsbuild auto issue?
14:09jcromartieI can't complain that they gave me a $3K laptop but I have a soft spot for Fedora on my Thinkpad…. need to spend more quality time with it
14:09jcromartiemy $400 craigslist computer runs Clojure just as fast as the beastly MBP
14:10pandeirogfredericks: i did too and struggled 2 days to put archlinux on it; loving it
14:10lsdafjklsdpandeiro: nope, using cljs 2134.. that's what you're asking right?
14:10gfrederickspandeiro: I've been using virtualbox for over a year now but I intend to try vmware
14:11pandeirogfredericks: why not dualboot?
14:11technomancyI have a work mac too =(
14:11gfrederickspandeiro: I'm a wuss?
14:11pandeirogfredericks: is it a macbook air?
14:11technomancyluckily they only make me use it for HR type stuff
14:11gfrederickslol
14:11gfredericksthe HR machine
14:12gfrederickspandeiro: pro
14:12gfredericksI use OSX mostly for printing
14:12technomancywell it also works well for checking my hair on account of the glossy screen
14:12technomancyhandy for right before a video conference
14:12pandeiroi see; i have a step-by-step org-mode file for how i got it working; just need to post it to github one of these days... but it's for a 2013 air setup w/ os x and arch dual booting
14:12pandeirotechnomancy: yeah the gloss is incredible on these things
14:13technomancyit's a real face-palm
14:13lsdafjklsdLOL
14:13technomancyremember when computers used to get better all the time?
14:13lsdafjklsd(inc technomancy)
14:13lazybot⇒ 88
14:13pandeirojust smudge it up with sweaty palms
14:13pandeirokinda works
14:14pandeirotechnomancy: i dunno i'd say it's the best machine i ever had, even with its issues
14:14pandeirobattery life is 3x what the equivalent lenovo gets
14:14pandeirothat alone puts it in a different category for me
14:15technomancyah. I just got a thinkpad with a low-voltage chipset.
14:16pandeirotechnomancy: how many hrs battery?
14:16jcromartiemine lasts about 3 hours on a good day :)
14:16jcromartiei7
14:16jcromartietechnomancy: did you get the latest Intel chipset?
14:16pandeirojcromartie: yeah that's what i was used to... my air is getting 8
14:16technomancyjcromartie: "just" meaning "in 2009" in this case
14:16jcromartieI really just use it around the house though
14:17technomancypandeiro: 5 hours with the 6-cell battery, then I swap in the 9-cell battery and haven't ever run that one all the way down. =)
14:17pandeirotechnomancy: swappable ftw, that's great
14:18technomancyyup, that's why I haven't upgraded to an X1
14:18pcnThe new macbook pros with ssds, etc will last an entire workday running a few virtualbox VMs (though not cranking them the whole time)
14:18pandeirotechnomancy: my ideabook isn't swappable either :( sucks
14:18pcnSSDs make a huge difference.
14:19pandeiro...but it has a great non-reflective screen
14:19pandeiropcn: yeah ssd must be helping; i do have a small issue with the computer "freezing" though and i suspect it has to do with the ssd
14:23whompzerokarmaleft, any ideas about the println issue?
14:24GreduanHi! Anybody available to help me out with CLJS + Node.js integration?
14:24rovaranyone feel like code golf?
14:24rovarhttps://www.refheap.com/22351
14:24rovaris there a better or more idiomatic way to do this?
14:25rovarGreduan: what do you need exactly?
14:26lsdafjklsdrovar: there is a monad that you can use which protects against nils in each step of a -> macro
14:26lsdafjklsdrovar: derp, nm
14:27Greduanrovar: I've been trying to figure out how to integrate CLJS + Node.js + node-webkit in a way that works, but I've been having trouble just with integrating CLJS and Node.js. What's an updated way to call Node.js from CLJS? All I've found is old blog posts...
14:27dnolen,(doc some->)
14:27clojurebot"([expr & forms]); When expr is not nil, threads it into the first form (via ->), and when that result is not nil, through the next etc"
14:27rovarlsdafjklsd: sort of like a apply-not-if-nil or something
14:28dnolenGreduan: hrm, that's a pretty specific question, obviously possible since that's how LightTable works
14:28dnolenGreduan: you may want to ask that on the ClojureScript mailing list too if nobody can respond at the moment.
14:28Greduandnolen: Right. I would like to study Light Table but the source isn't available yet.
14:28Greduandnolen: Will do. Thanks. :)
14:28zerokarmaleftwhomp: sorry, no ideas beyond that :(
14:28rovardnolen: that's not exactly what I want, I wish to have a list of candidate objects against which I wish to run a function, when I find the first non-nil, I stop.
14:28seangrovednolen: Are javascript fusion reactors a thing, or just something that sounds cool?
14:28jcromartierovar: don't you just want to call the first non-nil function?
14:29dnolenseangrove: just a funny phrase from one of the ex-core V8 devs
14:29dnolenseangrove: mraleph
14:29seangrovePhew, ok
14:29seangroveThought maybe they were something generator-related
14:29jcromartie(runverb (first (filter not-nil? verbs)))
14:29jcromartieer I mean the first non-nil value
14:30seangroveor just (remove nil? verbs)
14:30rovarfusion reactors sounds like something that would run a list of event handlers in haskell.
14:31rovarjcromartie: that'll do. I keep forgetting filter is lazy
14:31jcromartielazy or not, it'd do the same thing
14:31justin_smithor a thread pool that mutates every var in your vm if you don't monitor it closely
14:31rovarwell no need to recreate an entire list if you're going to run the first item
14:32jcromartierovar: sure
14:32jcromartielaziness is usually a boon, but sometimes a bane
14:32jcromartie:P
14:34rovarI like clojure's balance.
14:34rovarlazy collections, strict everything else, also a few options for synchronization points.
14:34rovarso far I've not had the problems with laziness that I had with Haskell sometimes.
14:35rovare.g. I've not blown the heap with thunks yet :)
14:37lsdafjklsddnolen: Whats the recommended way to share `app-state` between cljs files e.g. router.cljs / core.cljs
14:38dnolenlsdafjklsd: lift it up into a higher namespace probably simplest
14:39lsdafjklsddnolen: yea, like state.cljs which has the atoms for the app and require them in the files
14:39dnolenlsdafjklsd: yep
14:39lsdafjklsddnolen: thanks
14:39rovarIMO people seem to like to complain about namespaces in clojure. Frankly I don't see the problem. I've got a few dozen namespaces in my app and they don't seem to cause me problems :)
14:40rovarnot yet at least..=
14:41ClomeHappy new year and happy coding :D
14:44rovar(for [x '(happy)] [y '(new-year coding)] prn x y)
14:44rovar,(for [x '(happy)] [y '(new-year coding)] prn x y)
14:44clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: core/for>
14:44rovar,(for [x '(happy)] [y '(new-year coding)] (prn x y))
14:44clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/for>
14:45rovar,(for [x '(happy) y '(new-year coding)] (prn x y))
14:45clojurebot(happy new-year\nhappy coding\nnil nil)
14:45rovarmeh
14:45justin_smith,(doseq [x '(happy) y '(new-year coding)] (prn x y))
14:45clojurebothappy new-year\nhappy coding\n
14:46justin_smith,(doseq [x '(happy) y '(new-year coding)] (pr x y))
14:46clojurebothappy new-yearhappy coding
14:49dnolenrovar: people like easy, I don't have a problem with them either
14:51justin_smithI think usually the complaints about namespaces come from an idea (which I will withold judgement about) that the API provided to users of a library should be arbitrarily distinct from the structure of the implementing code
14:51gdevit's funny when I was teaching Clojure to some Java devs at my company namespaces totally threw them for a loop until I told them they were less like class definitions and more like package definitions
14:52gdevthey were trying to organize their project like (ns myapp.person) (get-name [person] ...)
14:53gdevwe've come a long way since then though
14:55gdevalso, the beauty of being a Java developer when I was learning Clojure is that I wasn't used to things being easy so to me Clojure was simple and easy. My friends who were ruby devs had a harder time
14:55bbloomgdev: that package vs class distinction is a big hurdle for a lot of folks
14:56bbloomgdev: you should totally write up your experiences w/ whatever magic words made it click for people :-)
14:56algalI think what's tricky about namespaces, for people new to the language, is that you're not learning just about namespaces. You learn about namespaces while also learning the distinction between name vs symbol vs var vs value. And that's actually subtle.
14:56algalAnd then there's load vs require vs use.
14:56justin_smith(inc algal)
14:56lazybot⇒ 1
14:56log0ymxmalgal: the key is to start with something horrendous like elisp so you don't have to worry about namespaces
14:56justin_smithvery good point
14:56algalSo there are a lot of distinctions flying around there, like bats.
14:57whomplol if you want to cheat at clojure, just have a rand-nth function with the solutions to the unit tests
14:57whompafter about 6 tries you'll get it right
14:57whomp*4clojure code golf
14:58gdevbbloom, funny you should say that because that's what I'm trying to do. I want to at least do a lightning talk about it at one of the big conferences
14:58zerokarmaleftwhomp: iirc, chouser had something similar where he gamed the tests, so one solution would work for every problem
14:59whomphaha nice
14:59algalgdev: There's a pretty good video on line about namespaces, but I can't remember the title. I think it ended with "oh my".
15:00algalgdev: But I think what would REALLY explain them all well is just a big honking diagram, with arrows clearly showing the mappings.
15:00zerokarmaleftwhomp: that would usually be considered self-defeating, but he's kind of been around awhile => http://clojure-log.n01se.net/date/2008-02-01.html
15:01gdevalgal, yeah I was thinking of doing an experience report style talk. what worked, what hasn't. I haven't had luck with diagrams yet
15:01algalThe REPL does "name" to symbol to var to value for you, so it's easy to miss the intuition that there's a sequence of differnet kinds of dereferencing going on under the hood.
15:01zerokarmaleftthat early exchange always makes me chuckle
15:03gdevOnce I'm done implementing this pharmacy system in datomic I'm going to take another crack at my clojure-quest game. I think I have a good design for a HUD that shows everything that is going on in the background of the repl
15:03whomphaha nice
15:04algalgdev: Clojurequest? HUD? background of the REPL? Is this cruel practical joke designed to drive me wild with curiosity, or a real thing?
15:04gdevalgal, it will be a real thing in the Spring of 2014
15:04gdevwatch this repo https://github.com/gdeer81/clojure-quest
15:06gdevit was originally my Lisp in Summer Projects project, but I had a rough summer to say the least, so I didn't make it past the hammock phase
15:07algalI guess the hammock phase is at least a step beyond the mattress phase.
15:09gdevthat's the only drawback to hammock driven design. you need a clear head
15:10justin_smithgdev: free idea - make a map of the world that is a 1:1 projection of the project source code
15:10justin_smithfunction calls being exits to access other places
15:11gdevjustin_smith, yeah that's what I had in mind, thanks
15:12justin_smiththrow statements as traps
15:12justin_smithwhat would treasure / monster be...
15:13gdevjustin_smith, my original idea was "escape from the dungeon of nouns" the only reward is that by the end of the game you're thinking at a more functional level
15:14algalIs the Monad an enchanted mirror? Because everyone looks at it and thinks it looks like something different?
15:14gdevlike literally level one is pulling yourself out of the muck of java interop
15:14seangrove~monad
15:14clojurebotmonad is functors that map a category to itself.
15:14philedEndofunctors?
15:14seangroveclojurebot: monad is VERBOTEN!
15:14clojurebotOk.
15:14seangrove~monad
15:15clojurebotmonad is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell
15:15gdevno, monads will be burritos that you can eat, but it takes two weeks to digest
15:15gdevunless you have a youtube powerup
15:15gdevand find some stackoverflow scrolls
15:17gdevthen it only takes like week to digest the burrito
15:18justin_smithgdev: and when you are done with digesting the burrito you are cursed to rewrap your poop as a new burrito and make others eat it
15:19justin_smithscratch that, too gross, sorry
15:19justin_smiththere must be some way to represent the monad curse though
15:20gdevjustin_smith, it might just be an abstract idea like something that delays your progress
15:20gdevthere will be a lot of yaks along the way
15:20justin_smithyaks should hand out fedex quests
15:21gdevlike if you're on level one and you try to learn emacs, that's gonna set you back a few weeks
15:21algal:)
15:21gdevthe goal is to also make it out of the dungeon in 20 weeks
15:21gdeverr months rather
15:29gdevman my youtube app is letting me down, four videos were posted to clojuretv and I didn't get a single notification.
15:48gdevlazybot, whatis Buddha
15:48lazybotBuddha is "Ping-ting comes for fire!"
15:48gdevI am enlightened
15:57jcromartiecomes *from* fire
15:57jcromartieno?
15:57clojurebotno is tufflax: there was a question somewhere in there, the answer
15:58jcromartieoh my
16:09gdevjcromartie, no Ping-tang comes *for* fire
16:12jcromartiegot it
16:23algalclojuretv! didn't know about this! cool.
16:25gdevalgal, infoq.com and skillsmatter have some good videos as well if you haven't seen those
16:26algalThose I knew, but the UIs a pita on those pages sometimes.
16:28asdf1Nonetheless, STOP spamming your site on HackerNews
16:31gdevis Zeder not open source yet?
16:32technomancythey need to start making that a qualification for accepting talks
16:32technomancyif it's not OSSed when the talk is submitted, it needs to be at least before the talk ends
16:33technomancygiven that this has happened twice already
16:33gdevtechnomancy, what was the other one?
16:34technomancygdev: longbottom and chas's bayesian lib
16:38gdevwell +1 for only OSS talks
16:38technomancyI don't mind talks about internal things as long as they're up-front about it
16:40gdevor the library should at least be available to use even if its closed
16:40gdevI can't find source or binary for Zeder 0_o
16:47andrew-deanquit
16:53gdevgah I was told to go home 4 hours ago. Clojure gives you a notion of time, but you sometimes lose your sense of time
17:04coventryIt seems as though in a compojure defroute the output from println statements and the like don't go to the repl. Is there any way to change that, or should I just spit to a file?
17:09gdevcoventry, i think that's called logging which is usually preferred over printing
17:12coventryYeah, using a logging framework is definitely better than spitting to a file, but both are a bit heavy when you're just exploring how something is working.
17:12gdevcoventry, agreed. didn't mean to sound snarky =)
17:13technomancycoventry: they'll probably go to the root binding of *out*
17:13gdevcoventry, so you're calling println inside of defroutes?
17:14coventrygdev: Not anymore, since it didn't work. :-)
17:14coventrytechnomancy: Yes, *out* is set to a different value. Thanks.
17:15gdevcoventry, if you want to see whats going on, macroexpand your defroute form
17:16technomancyio has nothing to do with defroute; the same thing would happen with any arbitrary ring handler
17:49jacksonngiven (1 2 3) (4 5 6) what would be the most idiomatic way of getting ((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6)) ?
17:50Bronsa,(for [a [1 2 3] b [4 5 6]] [a b])
17:50clojurebot([1 4] [1 5] [1 6] [2 4] [2 5] ...)
17:50jacksonnthanks
17:54dnolenOm Time Travel - http://swannodette.github.io/2013/12/31/time-travel/
17:55red00does anyone know if there is a simple openid auth (google) that works well with luminus template?
17:56CaptainLexIs this an appropriate venue for clojurescript discussion? #clojurescript is almost never active
17:56red00nope, not using clojurescript, purely clojure
17:57CaptainLexred00: Sorry, that was not directed at you!
17:57CaptainLexThat sounded terribly passive aggressive, I'm very sorry!
17:57CaptainLexAnd sadly I do not know an answer for your question
17:58ToBeReplacedCaptainLex: yeah, lots of cljs discussion in here -- i'd try first in #clojurescript though -- seems like we should be pushing more for that
18:00CaptainLexOkay, cool. So, are there any resources for a good, like, general overview of front-end architecture best practices? I'm not sure if I'm asking the question clearly...
18:00zerokarmaleftred00: take a look at friend-oauth2
18:00zerokarmaleftoh, sorry, openid
18:01zerokarmaleftred00: https://github.com/cemerick/friend-demo/blob/master/src/clj/cemerick/friend_demo/openid.clj
18:01coventryCaptainLex: No, people are still feeling their way through those questions.
18:01jacksonnI am getting back to clojure after some abstinence. is emacs + slime still the prefered way of doing programming in clojure?
18:01CaptainLexcoventry: How compelling!
18:01ToBeReplacedCaptainLex: take a look at dnolen's blog posts-- he covers a lot of ground and i found it very helpful
18:01zerokarmaleftjacksonn: most emacsen use nrepl/cider these days
18:01justin_smithjacksonn: nope, now it is cider (or nrepl, some of still use that)
18:02jacksonnthanks, checking it out
18:02CaptainLexjacksonn: What they have said, but I wouldn't overlook LightTable if you are interested in experimenting
18:02red00thanks for the help!
18:02coventryCaptainLex: There are a lot of exciting approaches, but no best practices at this point.
18:07CaptainLexcoventry: What a fun time to be involved with a language!
18:13UltimateEyePatchAimHere, ping
18:14UltimateEyePatchAimHere, so ehh, what do you think of Clojure's macro system
18:14UltimateEyePatchIt isn't fullyy hygienic like scheme's right?
18:14AimHereNah; but there's ways in which hygiene is encouraged
18:15AimHereI seem to recall that for anaphoric macros you have to quote and unescape the variable, to keep you honest, and stuff of that ilk
18:16justin_smithin practice making macros that capture is a bit harder, by default symbols get namespaced in quasiquote forms
18:17KeithPMI am having a problem with a helper function I am writing to count up frequencies of occurrence of elements in a sequence. May I post the code for comments? It's about 6 lines of code
18:17justin_smithKeithPM: did you know that frequencies is already a function?
18:18justin_smithKeithPM: use refheap or a github gist
18:18KeithPM: justin_smith yes. I am writing my own as an exercise
18:19KeithPMOK... I'll have to figure those out, are there instructions somewhere?
18:19UltimateEyePatchAimHere, is it possible to get full hygiene that can't ever be broken with them though
18:19justin_smiththey are just paste sites
18:19KeithPMOK... Cool thanks
18:19UltimateEyePatchLike, scheme doesn't enforce it but you can get full referential transparency that can't ever be broken
18:19justin_smithKeithPM: you can upload your code into a paste, and then share the URL here
18:20KeithPMOK thanks justin_smith
18:22KeithPMHere is a link to the code https://www.refheap.com/22356
18:23UltimateEyePatchAimHere, hmm, sweetie?
18:23justin_smithKeithPM: if you use recur instead of a self-call, it will still work, and be faster / use less stack space
18:24AimHereI'd be inclined to use 'reduce' instead of loop/recur, meself
18:24AimHereUltimateEyePatch, yes, what is it now?
18:24KeithPMOK, thanks...
18:24justin_smithKeithPM: also you could avoid the inner if statement by using the optional "not found" arg to get
18:24UltimateEyePatchAimHere, like I asked, is it possible to get full hygiene
18:25AimHereUltimateEyePatch, I'm sure it's possible to tweak the clojure code to do that; but it's not something I'd be equipped to do myself in a hurry
18:26justin_smithKeithPM: that is to say (freqs a-key) is the same as (get freqs a-key) and you can add a default / not found value of 1 as an extra arg
18:26justin_smith,(get {} :a 1)
18:26KeithPMRight... Are you saying that if I perform a get on freqs and item is not found, I can perform the insertion?
18:26clojurebot1
18:26justin_smith,({} :a 1)
18:26clojurebot1
18:26justin_smithyou would insert either way
18:26justin_smiththe switch is that it either returns the current count, or 1
18:26justin_smithactually, you want 0
18:26justin_smithbecause you would inc it :)
18:27AimHereTo get rid of the (if ... (assoc ) (assoc)), I'd likely do (merge-with freqs {a-key 1} inc) instead
18:27KeithPMOh cool, I did not know that, I thought it just 'returned' that default value
18:27UltimateEyePatchAimHere, are you not the worlds most renowned expert on clojure.
18:27UltimateEyePatchTHen point me to who is.
18:27KeithPMWow, cool... That sounds interesting
18:27KeithPMthe merge
18:28AimHereUltimateEyePatch, sadly I am not. There's a bloke called Rich Hickey who claims to know more than anyone else, feel free to troll him instead!
18:28justin_smithAimHere: I think you mean (merge-with {a-key 0} freqs)
18:28justin_smithyou want the pre-existing to override if it is there
18:28AimHereThat's just 'merge' you're talking about isn't it?
18:28KeithPMYes that is correct justin
18:29justin_smithAimHere: could be I am confused
18:29AimHeremerge updates the second; I want to increase the pre-existing one if there's a clash
18:29AimHereSo 'inc' might be (fn [a b] (inc a)) in what I did
18:30UltimateEyePatchAimHere, you always call me a troll.
18:30UltimateEyePatchWe have known each other for years now
18:30UltimateEyePatchand you still call me a troll
18:30justin_smithAimHere: yeah, it gets two args
18:30UltimateEyePatchI will tell molly about this
18:30AimHereI don't know who Molly is, I figure she might know you're a troll too!
18:31KeithPMWow there's so much opportunity for style in this language.
18:32KeithPMLet me try to get rid of the inner if and to use recur or starters. I am interested in the 'reduce' approach as well ( I think I am more comfortable recursing up than down, it's closer to mathematical induction :) )
18:33UltimateEyePatchAimHere, you know molly right?
18:33UltimateEyePatchAs in, molly`
18:33AimHereThe name is only vaguely familiar
18:35justin_smith,(update-in {:a 1} [:b] (fnil inc 0)) ; AimHere, KeithPM
18:35clojurebot{:b 1, :a 1}
18:36justin_smith,(update-in {:a 1} [:a] (fnil inc 0))
18:36clojurebot{:a 2}
18:36UltimateEyePatchAimHere, why does everyone always think me to be a troll?
18:37AimHereI'd guess it's because you turn up in random places on IRC and accost people with interminable and irrelevant conversations for your own amusement; but you'd have to ask the other guys what they think to be sure about that.
18:42UltimateEyePatchAimHere, how is it irrelevant in clojure to ask about its macro systems?
18:42UltimateEyePatchYou wound me madam
18:42KeithPMjustin_smith: update-in looks interesting
18:42AimHereI think the vast bulk of this conversation hasn't been about clojure macro hygiene!
18:43UltimateEyePatchAimHere, because you refused to answer and called me a troll
18:43UltimateEyePatchthereby insulting mine honour.
18:43UltimateEyePatchI have told people about this you know.
18:43UltimateEyePatchI have friends in high places.
18:43KeithPMthe get seems to have gotten rid of the innermost if. I am using 0 as the default since the inc is accepting the value before passing to assoc.
18:45UltimateEyePatchKeithPM, you stand idly by as AimHere insults my honour?
18:45bbloomUltimateEyePatch: if you are a troll, you're a pretty bad one, so give up now. if you're not a troll, you might want to take stock of your style of communication and think about why people perceive you as a troll. b/c quite frankly, you seem like a troll to me
18:46KeithPMLOL... Sorry guys, I was a little consumed with my challenges...
18:51UltimateEyePatchbbloom =(
18:51UltimateEyePatchI have been an upstanding member of this channel for 5 years.
18:52UltimateEyePatchI was here when Chousuke still posted
18:52UltimateEyePatchAnd you treat me like dirt.
18:53AimHereFamiliarity breeds contempt!
18:54UltimateEyePatchAimHere, I have been here longer than you
18:54UltimateEyePatchOr Molly
18:55justin_smithlet's make a version of IRC /ignore that turns someones words into gibberish instead of just making them disappear
18:55UltimateEyePatchIt's actually better
18:56UltimateEyePatchBecause it doesn't look like others are talking to nothing
18:56UltimateEyePatchAnyway, explain to me exactly the operative model of clojure's macro system
18:56UltimateEyePatchbecause I don't get it
19:08SegFaultAXUltimateEyePatch: What don't you get?
19:09SegFaultAXUltimateEyePatch: Macros are something like compile-time functions in the sense that they take *uncompiled lisp forms* as arguments and return new lisp forms as values.
19:10SegFaultAXAs an example, if I have a macro foo, the expression (foo (+ 1 2 3)) is evaluated at compile time, and foo receives exactly (+ 1 2 3), not the /result/ of (+ 1 2 3).
19:11technomancyhttps://twitter.com/mukeshsoni/status/417917145180147713 kind of a good point
19:12gdevtechnomancy, that's like saying whoever named automobiles "cars" is responsible for my hernia because they are definitely not cariable
19:12SegFaultAXtechnomancy: The term is confusingly overloaded in this case. Vars aren't variable in the same way as other languages.
19:12justin_smithgdev: carriage, duh
19:13SegFaultAXBut they are still variable.
19:13justin_smithor does carriage come from carriable somehow, hmm...
19:13gdevjustin_smith yes probably because it carries the riders
19:13justin_smithnope, carriable seems to come from carriage actually
19:13justin_smithyeah, there we go
19:14justin_smithanyway, that is just pedantry, my appologies
19:14technomancywhy not call them yeah-you-can-reload-your-code-you-can-thank-me-for-avoiding-ml-forward-change-visibility-only-later
19:15SegFaultAXtechnomancy: I'd RT that. :)
19:15technomancybrb opening a jira
19:16gdevyou could just write a macro that lets you use that long name and then creates a var under the covers
19:17gdevtechnomancy, that's going to get rejected for being goofy
19:26UltimateEyePatchSegFaultAX, yeah, I know that,
19:26UltimateEyePatchI don't get how the hygiene works
19:26UltimateEyePatchthe whole 'qualifies symbols with namespace'
19:26UltimateEyePatchLike ehh
19:26UltimateEyePatchSay I have a macro which uses + in its form and I use it inside (let [+ 3] ... )
19:26UltimateEyePatchDoes that break the macro?
19:27hiredman,`(+ 1 2)
19:27clojurebot(clojure.core/+ 1 2)
19:27hiredman,(= '+ 'clojure.core/+)
19:27clojurebotfalse
19:28AimHere,(= + clojure.core/+)
19:28clojurebottrue
19:30technomancytias?
19:30clojurebottias is try it and see
19:32technomancytl;dr: the problem that hygenic macros are intended to solve do not happen in CLojure unless you go out of your way to perform variable capture
19:35marcopolo`I'm playing around with core.matrix, and it's not letting me multiple a 2x1 with a 1x2, anyone have any experience with this?
19:36UltimateEyePatchhiredman, that doesn't actually answer me though
19:36UltimateEyePatchBut ehh
19:36UltimateEyePatchNonon, that doesn't work
19:36marcopolo`s/multiple/multiply
19:37UltimateEyePatchAimHere, how about a yes or no, say I have a macro which uses + and I use it inside (let [+ 3] ...), does it break or not?
19:40arrdem(inc bitemyapp) ;; fastmail just worked
19:40lazybot⇒ 14
19:41arrdem... what happened to lazybot? technomancy has karma 0. the end has come.
19:42justin_smith$karma techonmancy
19:42lazybottechonmancy has karma 0.
19:42justin_smithoverflow?
19:43arrdemI doubt it... everyone I checked is zeroed. except for bitemyapp.
19:44justin_smith$karma justin_smith
19:44lazybotjustin_smith has karma 24.
19:44arrdemwhat the whaaaa....
19:45arrdemthere's something funky going on... looks like lazybot lies in /msg
19:45UltimateEyePatchhiredman, hmm?
19:45justin_smithI noticed earlier that lazybot had forgotten I inc'd juxt
19:45arrdem$karma justin_smith
19:45lazybotjustin_smith has karma 24.
19:45arrdem$karma arrdem
19:45lazybotarrdem has karma 12.
19:45justin_smith$karma technomancy
19:45lazybottechnomancy has karma 88.
19:45arrdemokay it's a /msg related issue
19:45justin_smithI had a typo above
19:45arrdeminteresting.
19:45justin_smith(inc juxt)
19:45lazybot⇒ 6
19:47marcopolo`for posterity: http://stackoverflow.com/questions/19982466/matrix-multiplication-in-core-matrix
19:47gdevarrdem, I knew we needed to deploy our own irc bot just for karma. Cloutjure is never gonna happen is it?
19:47arrdemgdev: shhhhh
19:48arrdemgdev: I had the realization that if we could put together a generic karma source API that half of our architecture problems go away :/
19:48arrdemgdev: then we just hammer out a source specific client exposing a standard api
19:48arrdemgdev: no need to do crazy crap with a single sentient, omnicient graphdb
19:49arrdemgdev: yeah cloutjure may not happen until the next clojure cup tho :/
19:50gdevarrdem, I'm getting better at Datomic so that will be an option by the time clojure cup comes around again =)
19:51arrdemgdev: I see all this cool stuff about datomic and datalog floating around... sooner or later I'm gonna break down and do something with it myself
19:51arrdembut until then I'm content writing hardware simulators :P
19:54alewis clojure cup like ludum dare for clojure?
19:54gdevalew it doesn't have to be a game though
19:54gdevalew its more like rails rumble or node knockout
19:55alewAh ok
19:55alewsounds fun
19:55gdevalew it is if you have a good team
19:55alewSounds like you had a bad experience :P
19:55arrdemhaving worked with the people before is a huge pluss
19:56arrdemalew: it coulda been worse :P
19:56gdevalso not having to drive an hour to meet your team helps
19:56arrdemgdev: that's your own darn fault :P
19:57alewOh wow, significant prizes
19:57gdevthere were prizes?
19:57gdevlol I didn't even notice that part
19:57arrdemgdev: thanks for the ride again tho, it was fun that you made it up
19:57arrdemalew: link? I knew there were prizes but I didn't know what...
19:58gdevarrdem, although I think next year a game might be a better option
19:59arrdemgdev: really? oh right you were talking about a windjammers clone
19:59alewhttp://clojurecup.com/prizes.html
20:00arrdemdaaaaang
20:00arrdemI knew that there were bragging rights on the table, but I woulda lost some more sleep if I'd known the prizes were that good :P
20:01gdevoh cool that means Normand and his team got a Raspberry Pi board
20:01gdevwow the public favorite awards are better than 2nd and 3rd place
20:02arrdemgdev: do me a favor.. ping io@arrdem.com
20:05gdevarrdem ping timed out on port 25
20:06arrdemgdev: I meant email.
20:08arrdem$google urban dictionary ping
20:08lazybot[Urban Dictionary: ping] http://www.urbandictionary.com/define.php?term=ping
20:13gdevhttp://clojurecup.com/blog lol arrdem we're the first picture
20:14arrdempffft
21:19philllA recent cljs announcement said "Implement specify, instance level protocol extension for ICloneable extenders"... what's that mean?
21:34gdevphilll, js objects are fully dynamic and clojurescript had no mechanism to exploit that for protocol implementation
21:35gdevphilll, the specify macro does something similar to what extend-type does in Clojure
21:36philllah. protocol extension worked on prototypes? Now I get it. Thank you. Hopefully natural language algorithms aren't training on cljs release announcements.
21:40gdevphilll, Jira usually has the most details
21:44gdevphilll:) http://dev.clojure.org/jira/browse/CLJS-414
21:45gdevlol if you look at the open and close date of that issue, it took exactly one year
22:49cheesusWoah big channel
23:11justin_smith I just mentioned HDD to a friend, who naively assumed it must involve a hammock for each function you write
23:11justin_smithmapping 1:1 with TDD of course
23:13zerokarmaleftthat's a lot of naps
23:14justin_smithseriously
23:14justin_smiththough, really, I do think I could do it!
23:17cheesusHDD?
23:17justin_smithhammock driven development
23:18justin_smitha period of inactivity involving hard thinking, and sleeping on it, before realizing a design
23:18justin_smithbest thing to come out of the clojure community, or best thing ever? you decide
23:19ddellacostasometimes, for practices, I just take naps in a hammock
23:19ddellacosta*practice
23:20ddellacostait really helps build your skills
23:27KeithPMHi justin, I was abe to get the my-frequencies-helper to work using reduce but for some reason the recursive method ends up returning an empty map. Any ideas? I actually tried the update-in and had it work one time through.
23:28justin_smithKeithPM: have you edited the original paste / made a new one?
23:29KeithPMI made a new one, once sec...
23:30KeithPMThis one works https://www.refheap.com/22358
23:32justin_smiththe equivalent update-in for that assoc is (update-in counts [x] (fnil inc 0))
23:32justin_smithI think
23:33justin_smithI think reduce is better than recur when it is possible anyway, but it couldn't hurt for learning purposes to see what went wrong with the looping version
23:33KeithPMhttps://www.refheap.com/22364 Here is one with update-in that fails
23:34KeithPMYes. I was happy with the reduce, that is actually how they implement frequencies in the code. But I am uncomfortable with this failure though.
23:34justin_smithyou have some extra parens there that don't make any sense
23:34KeithPMLemme check... I have been messing around so much...
23:35justin_smithremember that unlike an algol family language, you cannot just add an extra () around any set of statements to group them
23:36KeithPMThe extra pair around the update is to form the else portion for the if... I need to call the function again.
23:36justin_smith'() always creates a sequence, () stands for an empty sequence, (foo) calls foo
23:36justin_smithmaybe you want do
23:37justin_smithtwo things: (do ...) groups a sequence of things by doing each one and returning the result of the last
23:37TEttinger,(doc do)
23:37clojurebotGabh mo leithscéal?
23:37TEttinger(doc do)
23:37clojurebotCool story bro.
23:37TEttingerwhat
23:37justin_smithupdate-in does not change its argument, it makes a new thing with the update
23:37TEttinger&what
23:37lazybotjava.lang.RuntimeException: Unable to resolve symbol: what in this context
23:37TEttinger##(doc do)
23:37lazybot⇒ "Special: do; Evaluates the expressions in order and returns the value of\n the last. If no expressions are supplied, returns nil."
23:37justin_smithif you do not use the return value, it is gone
23:37KeithPMOK lee me have a look... So do to form a 'block'
23:38justin_smithbut I think you actually want let here
23:38KeithPMAH... THAT is probably the problem there... That is the behaviour I am seeing
23:38justin_smithbecause you have the update-in and you need to use or bind the result somehow
23:38justin_smithlet is a binding form followed by an implicit do
23:38justin_smith,(let [a 0 b 1] a b)
23:38clojurebot1
23:39justin_smithit assigns some values to symbols, and returns the last thing in the body
23:39TEttingerso do forms a block for something like if, where you need one form (like the then form or else form) and can't have more
23:39justin_smithright
23:39justin_smithbut the next step is that update-in does not mutate the input
23:39justin_smithso you need to bind the result of update-in somehow to use it
23:40justin_smithwhich is where let comes in
23:43KeithPMYes I have used the let to bind. Let me try to bind the updated map then recurse with that
23:44justin_smithyou didn't know it but you were already using do - both fn (defn) and let have an implicit hidden do at the end
23:52KeithPMOK... hidden in the macro somewhere? :)
23:53justin_smithbasically
23:58justin_smithcome to think of it, in common lisp or scheme the form would evaluate to have a do in it after all the expansions, but it may not actually do that in clojure - but regardless, it acts that way
23:59KeithPMIf I use the let to bind, I think that also allows me to execute multiple expressions right?
23:59justin_smithof course
23:59justin_smitheach binding has an expression, and you can have any series of forms in the body