2015-11-29
| 00:36 | TEttinger | ,(expt 2N 18446744073709551616N) |
| 00:36 | clojurebot | #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:37 | TEttinger | right, I imported the numeric tower lib |
| 00:39 | TEttinger | I think that's uh a rather large number |
| 00:46 | Jinxit | is there any good online quick start to clojure? I'm familiar with functional programming |
| 00:46 | Jinxit | but not really any lisps |
| 01:05 | TEttinger | Jinxit: brave clojure, 4clojure exercises, clojuredoc |
| 01:05 | TEttinger | ~brave clojure |
| 01:05 | clojurebot | Titim gan éirí ort. |
| 01:05 | TEttinger | clojurebot: brave is http://www.braveclojure.com/ |
| 01:05 | clojurebot | c'est bon! |
| 01:06 | justin_smith | Jinxit: 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:06 | TEttinger | good ol' grimoire |
| 01:07 | Jinxit | alright, thanks all |
| 02:05 | Seraf | Hello 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:06 | Seraf | I 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:51 | douglarek | how can i stop an execution in cider repl ? |
| 03:51 | douglarek | such as : i entered (cycle [1]) |
| 03:54 | Seraf | Hello 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:43 | ben_vulpes | how 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:55 | TEttinger | ben_vulpes: apply |
| 04:56 | TEttinger | ,((fn [& args] (clojure.string/join "," args)) "hey" "clojure" "people") |
| 04:56 | clojurebot | "hey,clojure,people" |
| 04:57 | TEttinger | ,((fn [& args] (apply str args)) "hey" "clojure" "people") |
| 04:57 | clojurebot | "heyclojurepeople" |
| 04:57 | ben_vulpes | TEttinger: myeah, i got hung up on non-optional args. |
| 04:58 | ben_vulpes | was shooting for (apply (partial my-func arg1) [:optional :args]) |
| 04:59 | TEttinger | do what I do in this situation |
| 04:59 | TEttinger | hope justin_smith is awake |
| 05:00 | ben_vulpes | hahahaha |
| 05:00 | ben_vulpes | 's not a big deal. |
| 05:38 | Glenjamin | Seraf: group-by takes a function, have that function do the date formatting |
| 05:54 | Seraf | Glenjamin, thanks for the answer, I finally found a solution, it's working well |
| 06:59 | donbonifacio | why is equality with persistent data structures so efficient? Why is there no need to perform a deep compare? |
| 07:35 | kungi | donbonifacio: because they are immutable. therefore no deep compares are required |
| 07:36 | donbonifacio | I'm checking out the core, and deep compares may happen |
| 07:36 | donbonifacio | it's very optimized true, but it can happen |
| 07:58 | TimMc | One 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:58 | TimMc | or just the whole thing, I guess |
| 07:58 | TimMc | If a map hasn't been altered, the object identity is the same, so an equality check is really fast. |
| 07:59 | TimMc | In 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:03 | beaky | hello |
| 08:03 | beaky | how do i printf a list |
| 08:03 | beaky | or vector or map |
| 08:05 | TimMc | beaky: Not re what precisely you're having trouble with. What's a sample input and output that you want? |
| 08:05 | TimMc | *Not sure |
| 08:05 | beaky | ,(printf "%s\n" []) |
| 08:05 | beaky | i wat that to be [] |
| 08:05 | clojurebot | []\n |
| 08:05 | beaky | oh |
| 08:05 | beaky | nvm :D |
| 08:05 | beaky | ,(printf "%s\n" [1 2 3]) |
| 08:05 | clojurebot | [1 2 3]\n |
| 08:13 | TimMc | beaky: Do you know the pr/print distinction? |
| 08:22 | beaky | TimMc: no whats the diference |
| 08:22 | beaky | ,(pr [1 2 3]) |
| 08:22 | clojurebot | [1 2 3] |
| 08:23 | beaky | ,(pr "1 2 3") |
| 08:23 | clojurebot | "1 2 3" |
| 08:23 | jeaye | ^ that |
| 08:23 | beaky | (print "1 2 3") |
| 08:23 | beaky | ,(print "1 2 3") |
| 08:23 | clojurebot | 1 2 3 |
| 08:23 | beaky | ah |
| 08:24 | beaky | no " in print |
| 08:27 | jonathanj | can i iterate an Iterable<X> in Clojure? |
| 08:30 | Bronsa | you can reduce over it |
| 08:59 | justin_smith | ben_vulpes: (apply str "a" ["b" "c"]) |
| 08:59 | justin_smith | ,(apply str "a" ["b" "c"]) |
| 08:59 | clojurebot | "abc" |
| 09:11 | TimMc | beaky: In general, print prints the contents of data, and pr prints in a way that can be read back through read-string. |
| 09:12 | TimMc | Strings are the only thing that comes to mind at the moment as printing differently. |
| 09:13 | TimMc | beaky: 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:14 | justin_smith | ,(pr (map char (range))) |
| 09:14 | clojurebot | (\ |
| 09:14 | justin_smith | ,(print (map char (range))) |
| 09:14 | clojurebot | ( |
| 09:14 | justin_smith | hmmm |
| 09:15 | justin_smith | ,(print (map char (range (int \a) (int \z))) |
| 09:15 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 09:15 | justin_smith | ,(print (map char (range (int \a) (int \z)))) |
| 09:15 | clojurebot | (a b c d e ...) |
| 09:15 | justin_smith | ,(pr (map char (range (int \a) (int \z)))) |
| 09:15 | clojurebot | (\a \b \c \d \e ...) |
| 09:15 | justin_smith | ,(str (map char (range (int \a) (int \z)))) |
| 09:15 | clojurebot | "clojure.lang.LazySeq@9013fb8c" |
| 09:16 | justin_smith | sad trombone |
| 09:20 | Bronsa` | j |
| 09:24 | beaky | ah |
| 09:30 | wmealing | this 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:30 | wmealing | http://hastebin.com/cihewahuhu.pl |
| 09:31 | wmealing | i had tried with an array-map (see line 16) |
| 09:31 | justin_smith | wmealing: "Application Error" |
| 09:31 | justin_smith | wmealing: map doesn't ever change the order relative to the input |
| 09:32 | justin_smith | wmealing: it's not map changing the order, it's array-map |
| 09:32 | wmealing | ok, so what.. or how should I be doing that ? |
| 09:33 | wmealing | i'm 100% sure this is my fault.. i know that |
| 09:33 | justin_smith | wmealing: 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:34 | justin_smith | wmealing: I was wrong, it's amalloy/ordered https://github.com/amalloy/ordered |
| 09:34 | justin_smith | wmealing: 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:35 | wmealing | which is likely what i'm seeing there |
| 09:35 | justin_smith | yes, that is exactly what's happening - note how the processing happens in order, verified by your printing |
| 09:35 | justin_smith | it's the storage that goes out of order |
| 09:36 | wmealing | is there a better/alternative way to be doing what i'm doing |
| 09:36 | wmealing | i guess i could just pull them out in order when i extract them from the map |
| 09:36 | justin_smith | wmealing: an ordered map makes sense if you want to preserve insertion order and also look things up by key |
| 09:37 | wmealing | thanks justin_smith. |
| 09:37 | justin_smith | wmealing: 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:38 | wmealing | right. just one of the choices i have to make |
| 10:26 | Glenjamin | i'd probably suggest a sorted-map here |
| 10:26 | Glenjamin | rather than relying on correct insertion, since the keys do have a well-defined sort order |
| 10:28 | Glenjamin | some combination of (sorted-map-by), a map of month->index and (compare) would do it |
| 10:36 | jonathanj | is there some way i can use with-open with a collection of streams? |
| 10:37 | jonathanj | something like: (with-open [streams (fetch-multiple [uri1 uri2 uri3])] ...) |
| 10:49 | justin_smith | jonathanj: a multi-arity with-open that expands to nested with-open calls would be a nice intermediate macro writing challenge |
| 11:06 | jonathanj | nested? |
| 11:07 | jonathanj | i'm not sure they have to be nested, they just have to be unrolled, surely? |
| 11:07 | justin_smith | with-open manages a single stream |
| 11:07 | justin_smith | what do you mean by unrolled? |
| 11:07 | jonathanj | with-open calls close on all of the bindings |
| 11:08 | justin_smith | (doc with-open) |
| 11:08 | clojurebot | "([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:08 | justin_smith | oh, it takes multiple streams anyway, never mind |
| 11:09 | justin_smith | so no, you can't do it with a macro |
| 11:09 | justin_smith | unless the collection is known at macro expansion time, which is part of the compilation process |
| 11:09 | justin_smith | so you could do it with eval, but that's gross |
| 12:19 | Glenjamin | $source with-open |
| 13:32 | justin_smith | Glenjamin: 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:35 | devn_ | I can't brane good today. |
| 15:36 | devn | I am using environ, and I have a function that pulls values out of the environ map. |
| 15:37 | devn | This function raises if a particular configuration value is not found. |
| 15:37 | devn | I'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:38 | devn | so (get environ-map :foo) will throw if :foo doesn't exist |
| 15:38 | justin_smith | easier to write the alternate get, but sure |
| 15:38 | devn | well, i'd like to destructure, for example |
| 15:39 | devn | (let [{:keys [a b c]} environ-map] ...) |
| 15:39 | devn | justin_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:39 | devn | or? |
| 15:39 | clojurebot | or is there another way to upload it |
| 15:41 | justin_smith | devn: 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:41 | justin_smith | devn: but maybe it would be simpler to use prismatic/schema to check the map when it's created? |
| 15:43 | devn | justin_smith: maybe... |
| 15:43 | devn | or maybe try out structural typing |
| 15:43 | devn | https://github.com/marick/structural-typing |
| 15:44 | devn | justin_smith: when you say "all the relevant methods" |
| 15:44 | justin_smith | devn: interesting, looks like it tries to do some of the same stuff prismatic/schema tries to do |
| 15:45 | devn | i should just need a couple of arities for `get` (m k) (m k not-found), and `get-in` right? |
| 15:45 | justin_smith | devn: 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:45 | justin_smith | or just implement only and exactly the methods you plan on anyone ever calling, I guess |
| 15:46 | devn | yeah, that seems gross, ive done that before by using potemkin |
| 15:46 | devn | to use deftypefn i think it's called |
| 15:47 | devn | justin_smith: i think i like this structural typing business quite a bit |
| 16:05 | kenrestivo | is there a cond with fallthrough? |
| 16:05 | kenrestivo | ah, nevermind :else |