#clojure logs

2015-11-29

00:36TEttinger,(expt 2N 18446744073709551616N)
00:36clojurebot#error {\n :cause "Unable to resolve symbol: expt in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: expt in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: expt in this co...
00:37TEttingerright, I imported the numeric tower lib
00:39TEttingerI think that's uh a rather large number
00:46Jinxitis there any good online quick start to clojure? I'm familiar with functional programming
00:46Jinxitbut not really any lisps
01:05TEttingerJinxit: brave clojure, 4clojure exercises, clojuredoc
01:05TEttinger~brave clojure
01:05clojurebotTitim gan éirí ort.
01:05TEttingerclojurebot: brave is http://www.braveclojure.com/
01:05clojurebotc'est bon!
01:06justin_smithJinxit: also, http://conj.io is a good reference to the core language of clojure, and most functions there should be somewhat familiar if you have used functional languages
01:06TEttingergood ol' grimoire
01:07Jinxitalright, thanks all
02:05SerafHello everyone. I'm a bit loss: I'm trying to group-by date my results : http://pastebin.com/BhMLZXJw I'm using cljs-time. The problem is that I can't group-by directly on my data as the datetime is too much precise so I would like to convert it to YYYY-MM-DD to have a "logic" group-by. So I need to transform my map before applying a group by on it (but I also don't want to loose the original data as I would like to use it).
02:06SerafI tried a :date_finished on the group-by, but if I apply my cljs-time function on the keyword, it isn't a function anymore then it doesn't work :(
03:51douglarekhow can i stop an execution in cider repl ?
03:51douglareksuch as : i entered (cycle [1])
03:54SerafHello everyone. I'm a bit loss: I'm trying to group-by date my results : http://pastebin.com/BhMLZXJw I'm using cljs-time. The problem is that I can't group-by directly on my data as the datetime is too much precise so I would like to convert it to YYYY-MM-DD to have a "logic" group-by. So I need to transform my map before applying a group by on it (but I also don't want to loose the original date as I would like to use it further).
04:43ben_vulpeshow would one go about passing &args to a downstream function in such a way that it doesn't wrap them in a list itself?
04:55TEttingerben_vulpes: apply
04:56TEttinger,((fn [& args] (clojure.string/join "," args)) "hey" "clojure" "people")
04:56clojurebot"hey,clojure,people"
04:57TEttinger,((fn [& args] (apply str args)) "hey" "clojure" "people")
04:57clojurebot"heyclojurepeople"
04:57ben_vulpesTEttinger: myeah, i got hung up on non-optional args.
04:58ben_vulpeswas shooting for (apply (partial my-func arg1) [:optional :args])
04:59TEttingerdo what I do in this situation
04:59TEttingerhope justin_smith is awake
05:00ben_vulpeshahahaha
05:00ben_vulpes's not a big deal.
05:38GlenjaminSeraf: group-by takes a function, have that function do the date formatting
05:54SerafGlenjamin, thanks for the answer, I finally found a solution, it's working well
06:59donbonifaciowhy is equality with persistent data structures so efficient? Why is there no need to perform a deep compare?
07:35kungidonbonifacio: because they are immutable. therefore no deep compares are required
07:36donbonifacioI'm checking out the core, and deep compares may happen
07:36donbonifacioit's very optimized true, but it can happen
07:58TimMcOne really simple case is where you pass someone a nested map, they may or may not do something to it, and they pass you back another version of it and you want to compare some of the submaps.
07:58TimMcor just the whole thing, I guess
07:58TimMcIf a map hasn't been altered, the object identity is the same, so an equality check is really fast.
07:59TimMcIn Java-land, you'd probably want to do a deep copy to make sure mutation is controlled, and then you'd lose that shortcut.
08:03beakyhello
08:03beakyhow do i printf a list
08:03beakyor vector or map
08:05TimMcbeaky: Not re what precisely you're having trouble with. What's a sample input and output that you want?
08:05TimMc*Not sure
08:05beaky,(printf "%s\n" [])
08:05beakyi wat that to be []
08:05clojurebot[]\n
08:05beakyoh
08:05beakynvm :D
08:05beaky,(printf "%s\n" [1 2 3])
08:05clojurebot[1 2 3]\n
08:13TimMcbeaky: Do you know the pr/print distinction?
08:22beakyTimMc: no whats the diference
08:22beaky,(pr [1 2 3])
08:22clojurebot[1 2 3]
08:23beaky,(pr "1 2 3")
08:23clojurebot"1 2 3"
08:23jeaye^ that
08:23beaky(print "1 2 3")
08:23beaky,(print "1 2 3")
08:23clojurebot1 2 3
08:23beakyah
08:24beakyno " in print
08:27jonathanjcan i iterate an Iterable<X> in Clojure?
08:30Bronsayou can reduce over it
08:59justin_smithben_vulpes: (apply str "a" ["b" "c"])
08:59justin_smith,(apply str "a" ["b" "c"])
08:59clojurebot"abc"
09:11TimMcbeaky: In general, print prints the contents of data, and pr prints in a way that can be read back through read-string.
09:12TimMcStrings are the only thing that comes to mind at the moment as printing differently.
09:13TimMcbeaky: It's not just the quotes; "a\nb" will print as a and b on two lines but pr as six chars: "a\nb"
09:14justin_smith,(pr (map char (range)))
09:14clojurebot(\
09:14justin_smith,(print (map char (range)))
09:14clojurebot(
09:14justin_smithhmmm
09:15justin_smith,(print (map char (range (int \a) (int \z)))
09:15clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
09:15justin_smith,(print (map char (range (int \a) (int \z))))
09:15clojurebot(a b c d e ...)
09:15justin_smith,(pr (map char (range (int \a) (int \z))))
09:15clojurebot(\a \b \c \d \e ...)
09:15justin_smith,(str (map char (range (int \a) (int \z))))
09:15clojurebot"clojure.lang.LazySeq@9013fb8c"
09:16justin_smithsad trombone
09:20Bronsa`j
09:24beakyah
09:30wmealingthis is probably a rookie mistake, I'm a little stuck on how to ensure that when mapping over and ordered list, that the returned data is in the same order.. my example is here
09:30wmealinghttp://hastebin.com/cihewahuhu.pl
09:31wmealingi had tried with an array-map (see line 16)
09:31justin_smithwmealing: "Application Error"
09:31justin_smithwmealing: map doesn't ever change the order relative to the input
09:32justin_smithwmealing: it's not map changing the order, it's array-map
09:32wmealingok, so what.. or how should I be doing that ?
09:33wmealingi'm 100% sure this is my fault.. i know that
09:33justin_smithwmealing: if you need the data to be ordered, you shouldn't be using a hash-map or array-map. There is an insertion ordered map from flatland, flatland/ordered-map iirc.
09:34justin_smithwmealing: I was wrong, it's amalloy/ordered https://github.com/amalloy/ordered
09:34justin_smithwmealing: it might seem like array-map would have preserved the order, but if you conj onto an array-map of a certain size, it returns a hash-map
09:35wmealingwhich is likely what i'm seeing there
09:35justin_smithyes, that is exactly what's happening - note how the processing happens in order, verified by your printing
09:35justin_smithit's the storage that goes out of order
09:36wmealingis there a better/alternative way to be doing what i'm doing
09:36wmealingi guess i could just pull them out in order when i extract them from the map
09:36justin_smithwmealing: an ordered map makes sense if you want to preserve insertion order and also look things up by key
09:37wmealingthanks justin_smith.
09:37justin_smithwmealing: another alternative would be mapping the months to indexes in a vector via a hash-map, then putting the data in a vector by those indexes, but of course that is less convenient and direct
09:38wmealingright. just one of the choices i have to make
10:26Glenjamini'd probably suggest a sorted-map here
10:26Glenjaminrather than relying on correct insertion, since the keys do have a well-defined sort order
10:28Glenjaminsome combination of (sorted-map-by), a map of month->index and (compare) would do it
10:36jonathanjis there some way i can use with-open with a collection of streams?
10:37jonathanjsomething like: (with-open [streams (fetch-multiple [uri1 uri2 uri3])] ...)
10:49justin_smithjonathanj: a multi-arity with-open that expands to nested with-open calls would be a nice intermediate macro writing challenge
11:06jonathanjnested?
11:07jonathanji'm not sure they have to be nested, they just have to be unrolled, surely?
11:07justin_smithwith-open manages a single stream
11:07justin_smithwhat do you mean by unrolled?
11:07jonathanjwith-open calls close on all of the bindings
11:08justin_smith(doc with-open)
11:08clojurebot"([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order."
11:08justin_smithoh, it takes multiple streams anyway, never mind
11:09justin_smithso no, you can't do it with a macro
11:09justin_smithunless the collection is known at macro expansion time, which is part of the compilation process
11:09justin_smithso you could do it with eval, but that's gross
12:19Glenjamin$source with-open
13:32justin_smithGlenjamin: I could see doing it with a recursive function that takes streams as a list and an N arg function to apply to the streams, and for each recursive call it creates a try/catch/finally for the next stream and adds it to the list for applying...
15:35devn_I can't brane good today.
15:36devnI am using environ, and I have a function that pulls values out of the environ map.
15:37devnThis function raises if a particular configuration value is not found.
15:37devnI'm thinking that I'd like to make a new type of map that does this, so I don't have to call the function
15:38devnso (get environ-map :foo) will throw if :foo doesn't exist
15:38justin_smitheasier to write the alternate get, but sure
15:38devnwell, i'd like to destructure, for example
15:39devn(let [{:keys [a b c]} environ-map] ...)
15:39devnjustin_smith: what's the best way to do what im trying to do here? do i want to reify and define get on this particular map instance?
15:39devnor?
15:39clojurebotor is there another way to upload it
15:41justin_smithdevn: yeah, you could use reify and implement all the relevant methods, referring to the original object for everything but get, where you have the throw?
15:41justin_smithdevn: but maybe it would be simpler to use prismatic/schema to check the map when it's created?
15:43devnjustin_smith: maybe...
15:43devnor maybe try out structural typing
15:43devnhttps://github.com/marick/structural-typing
15:44devnjustin_smith: when you say "all the relevant methods"
15:44justin_smithdevn: interesting, looks like it tries to do some of the same stuff prismatic/schema tries to do
15:45devni should just need a couple of arities for `get` (m k) (m k not-found), and `get-in` right?
15:45justin_smithdevn: by that I mean check out (supers {}) or (supers (class {})) or whatever it is, and get all their methods, and implement them all by delegating to your hash-map
15:45justin_smithor just implement only and exactly the methods you plan on anyone ever calling, I guess
15:46devnyeah, that seems gross, ive done that before by using potemkin
15:46devnto use deftypefn i think it's called
15:47devnjustin_smith: i think i like this structural typing business quite a bit
16:05kenrestivois there a cond with fallthrough?
16:05kenrestivoah, nevermind :else