2015-03-27
| 00:00 | TEttinger | the way I do it, because I don't use editor fanciness other than paren matching and syntax highlighting, is press ) until I'm matched |
| 00:01 | Jaood | ;) |
| 00:04 | chr15m | that just takes you to the brace though, right? doesn't actually gather them. |
| 00:08 | bendlas | hm, I see that issue all the time when shoulder surfing people coding. and I remember it from my pre-paredit days. seems like some OSS clout to be had in releasing a cool editor plugin for that |
| 00:09 | bendlas | especially since in clojure there's typically a mix of ), } and ] |
| 00:09 | Jaood | chr15m: looks like we understood you differently |
| 00:09 | chr15m | @bendlas so you can do it with paredit? i have paredit. |
| 00:10 | bendlas | or maybe I understood you wrong; you didn't mean inserting all the nessecary closing parens? |
| 00:14 | chr15m | no i mean if there are loose parens hanging around on lines after the main one |
| 00:14 | chr15m | main one = the one you are working on |
| 00:15 | chr15m | (fn [x] ... |
| 00:15 | chr15m | ) |
| 00:15 | bendlas | oh, you mean spurious white space between you closing parens |
| 00:15 | chr15m | i want a single keystroke to gather that single brace back onto the last line it can go to |
| 00:15 | chr15m | yep |
| 00:16 | scottj | chr15m: in paredit in emacs pressing ) will do that for all closing brackets. (if by last line you mean previous line) |
| 00:16 | chr15m | scottj: good to know, thank you. i am in vim. |
| 00:17 | bendlas | scottj: cool, good to know that |
| 00:17 | chr15m | scottj: WAIT. paredit in vim also does this. |
| 00:17 | chr15m | you are truly legendary sir! |
| 00:17 | chr15m | thank you! |
| 00:17 | bendlas | I always used to jump outside of the last closing paren and press backspace until they were tidy |
| 00:17 | scottj | just repeating what everyone before said :) |
| 00:18 | chr15m | lol |
| 00:18 | chr15m | my hubris chooses to ignore the fact it took three attempts to explain the obvious to me |
| 00:18 | chr15m | i am great |
| 00:19 | bendlas | seconded ^^ |
| 00:19 | elvis45261 | is there any rule about namespaces ? |
| 00:19 | elvis45261 | does it have to follow the folder hiearchy ? |
| 00:20 | bendlas | elvis45261: yes, plus have at least one parent folder |
| 00:20 | bendlas | i.e two segments |
| 00:20 | elvis45261 | alright ty |
| 00:21 | bendlas | yw |
| 00:25 | freddd | does anyone have any idea if dissoc-in will ever make it to core from core.incubator? |
| 00:53 | elvis4526 | There is really no way to write macro with only clojurescript ? |
| 00:54 | elvis4526 | if that's the case, is it okay that the clojure file for the macros live in the same place as my cljs files or there should be some "separation" ? |
| 00:56 | joe124 | hi I am currently working through clojure for the brave and true, is buyign the early access ebook worth it? |
| 00:57 | bja | chr15m: go to the line to collect on and hold J |
| 00:57 | bja | it'll bring up the previous line every time you hit J |
| 00:57 | bja | (which if you have a bunch of parens, just collects those) |
| 00:58 | chr15m | bja ah yes, nice |
| 00:58 | chr15m | bja although with paredit hitting ) seems to work better |
| 00:58 | bja | I use vim-sext |
| 00:58 | bja | vim-sexp |
| 00:58 | chr15m | ah ok |
| 00:58 | chr15m | that is tpope's plugin right? |
| 00:58 | bja | guns |
| 00:59 | chr15m | ah yes |
| 00:59 | joe124 | is using atom for making clojure programs bad? |
| 00:59 | chr15m | it is in the 0.01% of vim plugins not written by tpope |
| 00:59 | gws | tpope has this one which works on top of vim-sexp (i use it) https://github.com/tpope/vim-sexp-mappings-for-regular-people |
| 00:59 | bja | joe124: do you want it to be bad? |
| 01:00 | joe124 | no |
| 01:00 | bja | then it's not bad |
| 01:00 | joe124 | awesome i feel great now! |
| 01:00 | bja | if you want to really level up, consider using ed to write your clojure |
| 01:01 | bja | ed combined with your usual shell and repl for fg/bg abilities and maybe a good mouse with copy/paste |
| 01:01 | bja | it'll really change you |
| 01:02 | joe124 | i have a question why is lisp and such not popular |
| 01:02 | joe124 | is it because lisp languages are harder to learn? |
| 01:04 | joe124 | what is the difference between {:a 5} and (def a 5) |
| 01:17 | amalloy | joe124: honestly the differences so outnumber the similarities that they're difficult to list. the two expressions you gave do totally different things; the main similarity is that they both involve the number 5 |
| 01:19 | joe124 | amalloy i just was wondering because in both the number 5 is bound to a |
| 01:19 | amalloy | not really |
| 01:19 | amalloy | in the second, you create a global var named a, and make its value be 5 |
| 01:20 | amalloy | in the second, you create a hashmap, with the single key :a and the corresponding value 5 |
| 01:20 | amalloy | there's no binding or assigning of anything in the second one, just a map with a key and a value |
| 01:21 | joe124 | but isnt a map kind of like assigning |
| 01:21 | gws | no a map is a data structure |
| 01:22 | freddd | joe124: a map is also known as a hash or dictionary in other languages if that helps you understand at all. |
| 01:27 | joe124 | yah thanks guys i guess i just noticed a similarity was wondering if there was anything more to it |
| 01:30 | elvis4526 | I am confused. How can you make a "global" js variable in cljs ? |
| 01:31 | elvis4526 | I would have expected that (def js/myGlobal val) would work |
| 01:34 | elvis4526 | oh nvm |
| 02:38 | Igor | How can I close http connection with http-kit? (close channel) doesn't work |
| 02:46 | vas | @Igor it doesn't automagically close? |
| 03:32 | Seylerius | Hmm... I'm kinda stuck on 4clojure #31 |
| 03:33 | Seylerius | Pack a sequence... |
| 03:33 | Seylerius | Anyone got a hint? |
| 03:50 | ordnungswidrig | Seylerius: "packing" = "grouping" |
| 03:52 | ordnungswidrig | Seylerius: a better hint would be "partitioning", I guess |
| 04:13 | Seylerius | ##(= [1 2 3] |
| 04:13 | Seylerius | ##(= [1 2 3] '(1 2 3)) |
| 04:13 | lazybot | ⇒ true |
| 04:30 | dysfun | is there a 'funcall' equivalent? i.e. apply, but doesn't take a list as arg? |
| 04:31 | opqdonut | #(%1 %2) ? |
| 04:32 | ordnungswidrig | ,(apply prn [1 2 3]) |
| 04:33 | clojurebot | 1 2 3\n |
| 04:33 | ordnungswidrig | ,(apply prn [[1 2 3]]) |
| 04:33 | clojurebot | #error{:cause "Unable to resolve symbol: in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: in this context", :at [clojure.lang.Ut... |
| 04:33 | ordnungswidrig | hmmmm |
| 04:34 | ordnungswidrig | ,(apply prn [[1 2 3]]) |
| 04:34 | clojurebot | [1 2 3]\n |
| 04:34 | ordnungswidrig | dysfun: simple wrap the arg in a vector for apply. |
| 04:41 | dysfun | ordnungswidrig: yes, it's just that if said function already existed, it would mean no need to embed a lambda in a (filter) |
| 05:09 | borkdude | what are good reasons to choose immutant over embedded jetty or undertow (except for clustering, which I don't need)? |
| 05:17 | dysfun | it's quite fast. it's worth testing the performance vs other things |
| 05:17 | dysfun | it fits nicely into the j2ee stack if you're of that persuasion (i'm not) |
| 05:19 | borkdude | do people use embedded jetty a lot in production? |
| 05:20 | oddcully | what's the key here "embedded" or "jetty"? |
| 05:21 | borkdude | jetty |
| 05:21 | oddcully | and from immutants homepage, i'd say, that if you don't need quartz, hornet, ... then maybe don't bother with the extra baggage |
| 05:22 | oddcully | http://www.techwars.io/fight/jetty/tomcat/ no ;P |
| 05:23 | spinningarrow | super stupid question guys - what does the result of the (doc ...) function mean? for example, if it says `(read-csv input & options)`, what exactly does `input & options` mean there? |
| 05:23 | borkdude | spinningarrow check out http://clojure.org/functional_programming |
| 05:24 | borkdude | spinningarrow especially http://clojure.org/special_forms#fn |
| 05:25 | borkdude | spinningarrow basically & options means options is a variadic list of parameters |
| 05:25 | borkdude | spinningarrow like in +, you can call it with an arbitrary amount of params: (+ 1 2 3 4 5 6) |
| 05:26 | oddcully | spinningarrow: above from the docs then is: ([] [x] [x y] [x y & more]) |
| 05:27 | oddcully | (the last one) |
| 05:34 | mpenet | borkdude: jetty is fine in production |
| 05:35 | mpenet | borkdude: ex: prismatic runs on it I believe |
| 05:36 | borkdude | mpenet cool |
| 05:38 | oddcully | i also use jetty embeded and not. had not problems so far (saising fist to universe to dare) |
| 05:49 | f3ew | What's the clojure model equivalent of the Unix pipeline pattern? |
| 05:53 | mpenet | f3ew: comp or the -> functions I guess |
| 05:55 | mpenet | ,(-> {:a {:b {:c [1]}}} :a :b :c first inc) |
| 05:55 | clojurebot | 2 |
| 05:59 | oddcully | f3ew: or core.async |
| 06:12 | Seylerius | ,(defn dup [coll] (loop [remainder coll result []] (if (empty? remainder) result (recur (rest remainder) (conj result (repeat 2 (first remainder))))))) |
| 06:12 | clojurebot | #'sandbox/dup |
| 06:13 | Seylerius | ,(dup [1 2 3 4]) |
| 06:13 | clojurebot | [(1 1) (2 2) (3 3) (4 4)] |
| 06:13 | Seylerius | Oh, of course |
| 06:14 | Seylerius | (defn dup [coll] (loop [remainder coll result []] (if (empty? remainder) result (recur (rest remainder) (concat result (repeat 2 (first remainder))))))) |
| 06:15 | Seylerius | ,(defn dup [coll] (loop [remainder coll result []] (if (empty? remainder) result (recur (rest remainder) (concat result (repeat 2 (first remainder))))))) |
| 06:15 | clojurebot | #'sandbox/dup |
| 06:15 | justin_smith | Seylerius: or apply conj |
| 06:16 | Seylerius | (dup [1 2 3 4]) |
| 06:16 | Seylerius | ,(dup [1 2 3 4]) |
| 06:16 | clojurebot | (1 1 2 2 3 ...) |
| 06:16 | noncom | f3ew: what do you mean? |
| 06:16 | noncom | ,(conj {} '(1 2)) |
| 06:16 | clojurebot | #error{:cause "java.lang.Long cannot be cast to java.util.Map$Entry", :via [{:type java.lang.ClassCastException, :message "java.lang.Long cannot be cast to java.util.Map$Entry", :at [clojure.lang.APersistentMap cons "APersistentMap.java" 42]}], :trace [[clojure.lang.APersistentMap cons "APersistentMap.java" 42] [clojure.lang.RT conj "RT.java" 610] [clojure.core$conj__4067 invoke "core.clj" 85] [sa... |
| 06:16 | Seylerius | noncom: It wants a vector, not a list. |
| 06:16 | justin_smith | that error message is so funny |
| 06:16 | noncom | yaeh, and that seemed strange to me |
| 06:17 | noncom | ,(conj {} '(:eval '(me "ok"))) |
| 06:17 | clojurebot | #error{:cause "clojure.lang.Keyword cannot be cast to java.util.Map$Entry", :via [{:type java.lang.ClassCastException, :message "clojure.lang.Keyword cannot be cast to java.util.Map$Entry", :at [clojure.lang.APersistentMap cons "APersistentMap.java" 42]}], :trace [[clojure.lang.APersistentMap cons "APersistentMap.java" 42] [clojure.lang.RT conj "RT.java" 610] [clojure.core$conj__4067 invoke "core.... |
| 06:17 | justin_smith | ,(conj {} '([] [])) |
| 06:17 | clojurebot | #error{:cause "clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry", :via [{:type java.lang.ClassCastException, :message "clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry", :at [clojure.lang.APersistentMap cons "APersistentMap.java" 42]}], :trace [[clojure.lang.APersistentMap cons "APersistentMap.java" 42] [clojure.lang.RT conj "RT.java" 610] [clojure.core$conj__... |
| 06:17 | justin_smith | that message is factually false |
| 06:17 | justin_smith | persistentvector can be cast |
| 06:17 | noncom | :D |
| 06:17 | noncom | also: |
| 06:17 | justin_smith | it's just complaining about the type of the wrong item |
| 06:17 | noncom | ,(conj {} (:eval '(+ 1 2))) |
| 06:17 | clojurebot | {} |
| 06:17 | noncom | haha! |
| 06:18 | noncom | i know what happens, but funny still |
| 06:18 | noncom | yeah, and your example with [] is even more fun i think :) |
| 06:19 | Seylerius | justin_smith: Weirdly enough, my function isn't working, despite producing a good result. |
| 06:19 | Seylerius | ,(dup [1 2 3]) |
| 06:19 | clojurebot | (1 1 2 2 3 ...) |
| 06:19 | justin_smith | ,((`~`~get `~`~`~`~get `~`~`~`~`~`~`~get `~`~`~`~`~`~`~`~`~`~`~get) [:a :b :c :d :e] 42 :OK) |
| 06:19 | clojurebot | :OK |
| 06:19 | justin_smith | Seylerius: what's wrong with that result? |
| 06:20 | Seylerius | It's failing #32 |
| 06:20 | Seylerius | Can clojurebot be coerced into providing a little more of the result? |
| 06:20 | hyPiRion | oh sure |
| 06:20 | Seylerius | ,(dup [1 2]) |
| 06:20 | clojurebot | (1 1 2 2) |
| 06:20 | hyPiRion | call it with str or something |
| 06:21 | hyPiRion | ,(str (dup [1 2 3 4])) |
| 06:21 | clojurebot | "clojure.lang.LazySeq@34932041" |
| 06:21 | hyPiRion | ,(pr-str (dup [1 2 3 4])) |
| 06:21 | clojurebot | "(1 1 2 2 3 ...)" |
| 06:21 | Seylerius | Heh |
| 06:21 | ordnungswidrig | ,(take 10 (dup [1 2 3 4])) |
| 06:21 | clojurebot | (1 1 2 2 3 ...) |
| 06:21 | hyPiRion | ,(binding [*print-length* 1000] (pr-str (dup [1 2 3 4]))) |
| 06:21 | clojurebot | "(1 1 2 2 3 3 4 4)" |
| 06:21 | justin_smith | ,(apply str (dup [1 2 3 4])) |
| 06:21 | clojurebot | "11223344" |
| 06:21 | ordnungswidrig | (into [] (take 10 (dup [1 2 3 4]))) |
| 06:21 | ordnungswidrig | ,(into [] (take 10 (dup [1 2 3 4]))) |
| 06:21 | clojurebot | [1 1 2 2 3 ...] |
| 06:22 | Seylerius | We clearly now have the information we need. |
| 06:22 | ordnungswidrig | grr |
| 06:22 | hyPiRion | perhaps pr is better actually |
| 06:22 | Seylerius | And yet it's still failing #32. |
| 06:22 | hyPiRion | 4clojure #32? |
| 06:22 | Seylerius | Yep |
| 06:23 | hyPiRion | What is it failing on? |
| 06:23 | Seylerius | Okay, now that's fscking weird. |
| 06:23 | Seylerius | I didn't change a single paren, and now it's passing. |
| 06:23 | justin_smith | Seylerius: when I paste the most recent def, it solves 32 |
| 06:23 | Seylerius | 4clojure is stupid sometimes. |
| 06:23 | hyPiRion | Seylerius: might've been a timeout issue? |
| 06:24 | justin_smith | also, (concat result (repeat 2 (first remainder))) is objectively worse than (conj result remainder remainder) |
| 06:24 | justin_smith | also, (concat result (repeat 2 (first remainder))) is objectively worse than (conj result remainder (first remainder) (first remainder)) that is |
| 06:24 | justin_smith | heh |
| 06:24 | Seylerius | Noted. |
| 06:25 | hyPiRion | If 4clojure hasn't been restarted in a while, then some alright solutions may timeout. |
| 06:25 | justin_smith | oh that was still wrong :( (conj result (first remainder) (first remainder)) |
| 06:26 | Seylerius | Hah |
| 06:26 | f3ew | noncom: the equivalent of a cat file |grep string | tee >(command) | some_other_command > file2 |
| 06:26 | Seylerius | And the advantage of repeat becomes clear in #33, where I need to do it an arbitrary number of times. |
| 06:26 | justin_smith | Seylerius: (apply conj coll (repeat n val)) |
| 06:27 | Seylerius | apply conj beats concat? |
| 06:27 | justin_smith | definitely, I'd say. If you have a vector |
| 06:27 | noncom | f3ew: ummm, well, clojure is a jvm-based programming language, so i am not really sure about what you're asking, but for interacting with bash you can use the conch library and for piping functions, well, yes, there are facilities |
| 06:27 | Glenjamin | is (apply conj) prerrable to (into) ? |
| 06:28 | justin_smith | Glenjamin: into is likely better than apply conj, yeah |
| 06:29 | Seylerius | Oooh. Shiny. |
| 06:29 | hyPiRion | and hey, if you need an eager concat on vectors, then I can recommend (defn catvec [& vecs] (reduce into vecs)) |
| 06:30 | f3ew | noncom: I'm not interacting with bash, I have clojure functions I would like to chain up in a similar style |
| 06:30 | oddcully | f3ew: so you want to read a file, filter some limes, send the lines down to another process and save them also into a file? so you want to use closure _instead_ of a shell, right? |
| 06:30 | justin_smith | oddcully: he just wants the syntactic style |
| 06:30 | justin_smith | which is -> or ->> |
| 06:30 | f3ew | oddcully: s/file/event stream/, and process that event stream |
| 06:31 | noncom | f3ew: also https://github.com/rplevy/swiss-arrows |
| 06:32 | justin_smith | f3ew: oh, if it's explicitly a stream with new items coming in async, then core.async |
| 06:33 | f3ew | justin_smith: I'm writing riemann configs, so the reading bit is handled for me |
| 06:34 | justin_smith | f3ew: yeah, so you want one of those arrows, probably -> with the occasional nested ->> / some-> / some->> etc. |
| 06:37 | Seylerius | ,(defn ranger [a b] (if (< a b) (conj [a] (ranger (inc a) b)) [])) |
| 06:37 | clojurebot | #'sandbox/ranger |
| 06:37 | Seylerius | ,(ranger 1 4) |
| 06:37 | clojurebot | [1 [2 [3 []]]] |
| 06:37 | Seylerius | Ah, right. |
| 06:38 | Seylerius | ,(defn ranger [a b] (if (< a b) (into [a] (ranger (inc a) b)) [])) |
| 06:38 | clojurebot | #'sandbox/ranger |
| 06:38 | Seylerius | ,(ranger 1 4) |
| 06:38 | clojurebot | [1 2 3] |
| 06:38 | Seylerius | Yep |
| 06:45 | justin_smith | ,(def ranger (constantly 'Strider)) |
| 06:45 | clojurebot | #'sandbox/ranger |
| 06:57 | egli | borkdude: immutant is just a nicely package if you want web, messaging, transactions, etc |
| 06:58 | egli | it's very industrial strength but you have to dig jboss xml config files |
| 06:59 | noncom | ,ranger |
| 06:59 | clojurebot | #error{:cause "Unable to resolve symbol: ranger in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: ranger in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: ranger in this context", :at [... |
| 07:26 | Seylerius | ,(defn mixer [seqa seqb] (loop [one seqa two seqb result []] (if (apply or (map empty [one two])) result (recur (rest one) (rest two) (conj result (first one) (first two))))) |
| 07:26 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 07:32 | justin_smith | Seylerius: you can't apply or |
| 07:33 | justin_smith | ,(some? empty [[1] [2]]) |
| 07:33 | clojurebot | #error{:cause "Wrong number of args (2) passed to: core/some?", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (2) passed to: core/some?", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 36] [sandbox$eval47 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 67... |
| 07:33 | justin_smith | ,(some empty [[1] [2]]) |
| 07:33 | clojurebot | [] |
| 07:33 | Empperi | or is a macro, thus you can't use apply with it |
| 07:33 | Seylerius | justin_smith: wound up just manually or-ing it. |
| 07:34 | Seylerius | The real problem was a missing paren. Emacs catches those so much better, what with highlighting matches. |
| 07:34 | justin_smith | ,(some empty? [[1] [2]]) |
| 07:34 | clojurebot | nil |
| 07:34 | justin_smith | that's what I wanted |
| 07:35 | justin_smith | Seylerius: if you aren't specifically sharing with us all, you can use /msg to talk to clojurebot |
| 07:35 | Seylerius | Shiny. |
| 07:35 | Seylerius | Although I do value y'all's opinions a fair bit on this stuff. |
| 07:35 | Seylerius | It's rather handy. |
| 07:36 | Seylerius | All of you clever and more experienced clojure-folks are good to talk to. |
| 07:36 | justin_smith | Seylerius: sure, but I don't think you need our help with unmatched parens :) |
| 07:36 | Seylerius | :p |
| 07:36 | Seylerius | Other than the or bit, what d'you think of the method in that one? |
| 07:37 | justin_smith | Seylerius: looks decent enough, it would be clearer as a reduce |
| 07:37 | justin_smith | generally, loop is low level, and it's good to convert to one of the higher level constructs when applicable |
| 07:38 | Seylerius | Right... |
| 07:39 | justin_smith | something like (defn mixer [a b] (reduce into [] (map vector a b))) |
| 07:40 | justin_smith | it does the same thing, but much less verbosely |
| 07:40 | Seylerius | Oh that's nice. |
| 07:40 | Seylerius | I forget about map being able to pull from multiple sources. |
| 07:40 | justin_smith | ,(defn mixer [a b] (reduce into [] (map vector a b))) |
| 07:40 | clojurebot | #'sandbox/mixer |
| 07:40 | justin_smith | ,(mixer [:a :b :c :d] [1 2 3 4 5]) |
| 07:40 | clojurebot | [:a 1 :b 2 :c ...] |
| 07:40 | justin_smith | that's what it should do, right? |
| 07:40 | Seylerius | Yep |
| 07:41 | Seylerius | ,(map vector [1 2 3] [:a :b :c]) |
| 07:41 | clojurebot | ([1 :a] [2 :b] [3 :c]) |
| 07:41 | Seylerius | Right. |
| 07:41 | justin_smith | oooh |
| 07:41 | justin_smith | ,(defn mixer [a b] (mapcat vector a b)) |
| 07:41 | clojurebot | #'sandbox/mixer |
| 07:41 | justin_smith | ,(mixer [:a :b :c :d] [1 2 3 4 5]) |
| 07:41 | clojurebot | (:a 1 :b 2 :c ...) |
| 07:41 | Seylerius | Oh goodness. |
| 07:42 | justin_smith | much better! don't even need reduce |
| 07:42 | justin_smith | ,(def mixer (partial mapcat vector)) |
| 07:42 | clojurebot | #'sandbox/mixer |
| 07:42 | Seylerius | mapcat. fscking mapcat... |
| 07:42 | Seylerius | Wait... partial? |
| 07:42 | justin_smith | ,(mixer [:a :b :c] [1 2 3] '(l m n o p)) |
| 07:42 | clojurebot | (:a 1 l :b 2 ...) |
| 07:42 | justin_smith | partial makes it varargs :) |
| 07:42 | Seylerius | I gathered that. |
| 07:43 | Seylerius | I'm looking that up on the cheatsheet now for the w1n it's apparently made of. |
| 07:43 | Empperi | partial creates a new function where it already has n parameters given |
| 07:43 | Empperi | thus that would turn to: (mapcat vector <rest of the parameters here>) |
| 07:44 | justin_smith | Seylerius: still blows my mind that your loop can be redefined to three functions in one sexp :) |
| 07:45 | Seylerius | That makes two of us. |
| 07:45 | justin_smith | hopefully you followed along - tried to do it step by step |
| 07:45 | clgv | is there a best practice tutorial for tagged literals and data readers somewhere? |
| 07:48 | Seylerius | Indeed. |
| 07:55 | Seylerius | I officially love partial. |
| 07:55 | Seylerius | It's made of win. |
| 07:56 | justin_smith | Seylerius: yeah, I'm a fan |
| 07:56 | AeroNotix | my only gripe is that it's quite a long name, so sometimes using #(...) is shorter anyway |
| 07:58 | ordnungswidrig | AeroNotix: ,(def ∂ partial) |
| 07:58 | clgv | AeroNotix: but `partial` documents the intent better ;) |
| 07:59 | ordnungswidrig | ,(def ∂ partial) |
| 07:59 | clojurebot | #'sandbox/∂ |
| 07:59 | ordnungswidrig | .((∂ + 2) 4) |
| 07:59 | ordnungswidrig | ,((∂ + 2) 4) |
| 07:59 | clojurebot | 6 |
| 08:01 | AeroNotix | clgv: the first time you read it, yeah |
| 08:01 | AeroNotix | ordnungswidrig: but that's not widely used, partial is its name. |
| 08:01 | ordnungswidrig | AeroNotix: sure, but you were complaining about the length of the name :-) |
| 08:02 | clgv | AeroNotix: I meant the intent of the dev using partial. #(...) (fn ...) could be anthing - with `partial` you know, it is just that first function plus some fixed params. so you can skip to that function immediately to read up what it does |
| 08:02 | AeroNotix | I am yeah |
| 08:02 | Seylerius | ordnungswidrig: What greek letter was that? |
| 08:02 | AeroNotix | it's a trivial thing |
| 08:03 | clgv | Seylerius: delta |
| 08:03 | ordnungswidrig | Seylerius: not greek a curly d. |
| 08:03 | ordnungswidrig | http://www.fileformat.info/info/unicode/char/2202/index.htm |
| 08:03 | clgv | looks like a delta ;) |
| 08:04 | ordnungswidrig | ∂ vs. ∂ |
| 08:04 | clgv | ordnungswidrig: with that context it is a different styled delta ;) |
| 08:05 | ordnungswidrig | well, YMMV. The uppercasing behaviour of that codepoints is different |
| 08:05 | ordnungswidrig | (I guess) |
| 08:06 | Seylerius | ,(defn poser [a coll] (mapcat vector coll (repeat a))) |
| 08:06 | clojurebot | #'sandbox/poser |
| 08:06 | Seylerius | ,(poser 0 [1 2 3]) |
| 08:06 | clojurebot | (1 0 2 0 3 ...) |
| 08:07 | Seylerius | Ah |
| 08:07 | michaelr` | err |
| 08:08 | michaelr` | What would be a good way to use react.js components from om? |
| 08:08 | michaelr` | more specifically with sablono, if possible |
| 08:09 | Seylerius | ,(defn poser [a coll] (butlast (mapcat vector coll (repeat a)))) |
| 08:09 | clojurebot | #'sandbox/poser |
| 08:09 | Seylerius | ,(poser 0 [1 2 3]) |
| 08:09 | clojurebot | (1 0 2 0 3) |
| 08:10 | michaelr` | yeah, with sablono - how to use react components with sablono? |
| 08:15 | edbond | michaelr`, sounds like a question for #clojurescript |
| 08:16 | edbond | michaelr`, sounds like a question for #clojurescript room |
| 08:16 | AeroNotix | is there an echo in here |
| 08:16 | AeroNotix | is there an echo in here |
| 08:16 | michaelr` | what? |
| 08:16 | michaelr` | what? |
| 08:16 | clojurebot | what is this |
| 08:16 | clojurebot | what is cells |
| 08:17 | AeroNotix | haha |
| 08:17 | edbond | haha |
| 08:17 | slipset | re partial, I know emacs, and I think Intellij can use different glyphs for partial, fn et al |
| 08:18 | AeroNotix | slipset: heathen |
| 08:19 | slipset | https://github.com/hackscience/purty-mode |
| 08:19 | michaelr` | edbond: thanks, I think that I got the answer.. |
| 08:19 | slipset | I think I've seen tbaldridge use the lambda glyph for anonymous functions |
| 08:20 | tbaldridge | slipset: yep, it's from Emacs Live |
| 08:21 | slipset | and jay fields http://blog.jayfields.com/2013/05/emacs-lisp-font-lock-for-clojures.html |
| 08:22 | slipset | and he found that in emacs-live it seems |
| 08:42 | elvis4526 | How do you bind a function to a js symbol in cljs ? |
| 08:42 | elvis4526 | (def $scope.submit (fn [])) ain't doing it. :-( |
| 08:43 | edbond | elvis4526, there is a #clojurescript room for cljs questions |
| 08:44 | elvis4526 | ty |
| 08:44 | lewis1711 | so what's the deal with using java8 libs from clojure? looking to use one that makes use of lambdas a lot |
| 08:50 | thheller | lewis1711: lamdas are basically just syntax sugar, so it just works. |
| 09:02 | brianwr | Hi, having a problem recurrent problem with clojurescript/reagent/re-frame compiling error: sometimes i get i error like: "referred var ... does not exist at line ..." I know that is an error somewhere, but i am unable to find the origin of it using the stack trace. Any tips? |
| 09:06 | brianwr | Oh, forgot to mention that im using figwheel too ;) |
| 09:21 | Beamed | [i0jefqo'efqipj'rvjip |
| 09:21 | Beamed | sorry, cat |
| 09:25 | danlentz | i wonder why there is not more buzz about dunaj. I havent spent time to study in detail, but some of the ideas sound very good to me. |
| 09:29 | arrdem | I agree that a bunch of the ideas sound good, but I don't think anyone has really had time to try it out yet. |
| 09:29 | danlentz | yeah |
| 09:29 | danlentz | its overwhelming |
| 09:30 | arrdem | agreed. |
| 09:30 | danlentz | but there are only 4 people in the #dunaj group right now |
| 09:30 | danlentz | somehow that does not seem appropriate level of interest |
| 09:30 | danlentz | and one of them is me and the other is the author |
| 09:30 | arrdem | I mean... #oxlang is just me and cemerick |
| 09:31 | arrdem | just kinda comes with being a fork / blue sky projec.t |
| 09:32 | tbaldridge | the fork bit is probably the hardest, mostly because you have to compete in the same space |
| 09:32 | arrdem | Right. I think the one sales pitch which dunaj has failed to explicitly make so far is that it is a _drop in replacement_ for Clojure built on top of Clojure that you can try out now. |
| 09:33 | danlentz | it is indeed unclear |
| 09:33 | arrdem | which is just a bandaid over the fact that grats, you're now competing with Core. |
| 09:33 | danlentz | i kindof see it as a proving ground for new ideas rather than a replacement |
| 09:34 | arrdem | agreed, but being a proving ground implies more than just experimental use IMO |
| 09:34 | cemerick | arrdem: s/fork// |
| 09:34 | danlentz | he said he hasnt gotten any feedback at all from cognitect |
| 09:35 | arrdem | cemerick: I'd merge it |
| 09:35 | cemerick | oh, but tbaldridge said this already basically |
| 09:35 | cemerick | arrdem: what, dunaj? |
| 09:35 | arrdem | cemerick: your sed |
| 09:35 | cemerick | heh |
| 09:36 | cemerick | there's plenty of room for more languages, but not for alt-clojures |
| 09:36 | tbaldridge | So duanj reminds me a ton of a fork of Blender3D that happened like 12 years ago. Some guy needed a bunch of features, so he forked it and worked on his own for quite some time. |
| 09:37 | puredanger | danlentz: there's interesting things in dunaj, but it's just so much stuff all together that I can't even pick out something to critique |
| 09:37 | tbaldridge | Problem was, when he was done 90% of his features were so different from master that it could never be merged, everything had changed. Forks and then remerging can never work IMO. |
| 09:38 | arrdem | agreed. I did the lib-clojure refactor a while back, and when I got it working I realized that I'd created a bunch of unmergable patches. |
| 09:39 | puredanger | there is also the issue that it is just a pile of solutions without the consideration of what the source problems or alternative solutions are |
| 09:43 | sobel | so, if i have a little clojure to deploy to an existing app that doesn't already have clojure, what's really involved, besides the clojure runtime and non-clojure deps like the oracle jar it needs |
| 09:44 | sobel | same question, command-line operation. |
| 09:44 | dstockton | quite an open question sobel |
| 09:45 | michaelr` | sobel: on thing is build integration, with the maven plugin maybe if it's a maven project |
| 09:45 | AeroNotix | sobel: I just did something similar with an Java application |
| 09:45 | AeroNotix | I just had the Java developers use an Uberjar and put that into the project |
| 09:45 | sobel | the java app is already mavenized |
| 09:45 | noncom | i am setting up a nrepl server on macos, but i cannot conenct to it. telnet seems to do fine, but lighttable or counterclockwise don't.. any ideas? |
| 09:45 | AeroNotix | you would just put the clojuer code as a mvn dep then |
| 09:45 | noncom | (there are no firewalls on) |
| 09:46 | dnolen | for people looking for a simple Emacs ClojureScript setup, 0.0-3165 now works a charm with inf-clojure |
| 09:46 | sobel | so, publish my clojar to the internal mvn repo, add it as a dep to the app? |
| 09:46 | dnolen | https://github.com/clojure/clojurescript/wiki/Emacs-%26-Inferior-Clojure-Interaction-Mode |
| 09:52 | clgv | sobel: it might help integration if you provide a java facade for the common interop calls |
| 09:52 | clgv | (interop between the java app and you clojure lib, is meant ;) ) |
| 09:53 | sobel | will i have to add clojure runtime as a dep to the java app, or can that get bundled? |
| 09:54 | sobel | clgv: pretty sure i'll need to do that |
| 09:54 | clgv | sobel: it istransitively pulled in because of your clojurelib |
| 09:55 | sobel | clgv: aha. thanks. |
| 09:56 | clgv | sobel: you'll need that offcicial API http://clojure.github.io/clojure/javadoc/ |
| 09:57 | AeroNotix | sobel: I just did a really heavy amount of java interop to do exactly this |
| 09:57 | AeroNotix | provide a clojure library that looks and smells like java |
| 09:57 | AeroNotix | there's quite a bit which is undocumented, or documented poorly. |
| 09:58 | sobel | AeroNotix: i'm convinced. the interop surface is extremely narrow, fortunately. |
| 09:58 | AeroNotix | cool |
| 09:58 | clgv | AeroNotix: are there gundogs sniffing your libs? ;) |
| 09:58 | AeroNotix | clgv: what |
| 09:58 | sobel | clgv: that will get pulled in transitively, right? |
| 09:58 | AeroNotix | the only thing you can't do is create Enums in Clojure, or at least I couldn't figure out how |
| 09:58 | clgv | sobel: it is part of clojure since at least 1.6 (maybe 1.5?) |
| 09:58 | sobel | clgv: or..oh, you meant i'll need those docs, gotcha |
| 09:58 | AeroNotix | but you can do literally everything else as far as I know |
| 09:59 | sobel | i can live without enums. |
| 10:00 | lewis1711 | what do you do with enums in a dynamically typed language? |
| 10:00 | AeroNotix | lewis1711: provide java with a nice API |
| 10:01 | AeroNotix | I just use :java-source-paths in lein |
| 10:01 | lewis1711 | I always just end up assigning symbols to variables, so I don't make mistakes through typos |
| 10:01 | AeroNotix | with an enum |
| 10:01 | sobel | if the java api becomes that classy, i'll just straight-up write it in java |
| 10:01 | lewis1711 | ah, fair call |
| 10:01 | clgv | AeroNotix: they could be translated to namespaced keywords at the java facade, if the requirements permit |
| 10:01 | AeroNotix | clgv: no need for a java facade |
| 10:01 | AeroNotix | you can write the majority nicely in just pure clojuer |
| 10:01 | AeroNotix | with gen-class and gen-interface |
| 10:01 | AeroNotix | along if you really want, a java Enum file. |
| 10:02 | clgv | depends on the java side requirements whether the facade is a good idea ;) |
| 10:02 | clgv | gen-class is usually not what I want to use ... |
| 10:02 | AeroNotix | I've had good experiences with it. |
| 10:03 | AeroNotix | pure-Clojure library, gen-class'd facade code. ezpz |
| 10:03 | AeroNotix | no java needed |
| 10:03 | AeroNotix | but the java friends get a library that looks and feels like java |
| 10:03 | AeroNotix | all the IDE goodies as well. |
| 10:03 | sobel | AeroNotix: that is my preference, unless i _have_ to provide Enums |
| 10:03 | sobel | which..i can't imagine, but whatever |
| 10:03 | sobel | i'll write enum-gen if it comes to that :) |
| 10:03 | AeroNotix | writing an enum in java and the rest in clojure is ez too. You just use :java-source-paths and match up the package names you used in gen-class to make it look nice. |
| 10:04 | clgv | AeroNotix: there are plenty of gen-class scenarios that are faster implemented by using java ;) |
| 10:04 | clgv | and better... |
| 10:04 | AeroNotix | quantify better |
| 10:05 | AeroNotix | faster, perhaps, if you're not familiar with the esoterics in gen-class. |
| 10:05 | clgv | so you'll have to judge on per case basis. |
| 10:05 | sobel | i'll be back when i can't make class-gen work :) |
| 10:05 | sobel | gen-class, too |
| 10:05 | AeroNotix | cool. |
| 10:06 | sobel | thx for the consult. this org needs a healthy introductory clojure experience. |
| 10:10 | elvis4526 | with java jdbc, how do I know construct the db-spec for postgresql ? |
| 10:10 | elvis4526 | I'm not sure what I'm suppose to put as :classname |
| 10:11 | elvis4526 | I have postgresql/postgresql pulled in with lein |
| 10:19 | om | elvis4526: :subprotocol "postgresql" should be enough |
| 10:20 | om | java.jdbc shall get the classname for you |
| 10:20 | elvis4526 | om: awesome, thanks! |
| 10:21 | brianwr | I having a problem recurrent problem with clojurescript/reagent/re-frame/figwheel enviroment. Sometimes i get a compile error like: "referred var ... does not exist at line ..." I know that is an error somewhere, but i am unable to find the origin of it using the stack trace. Any tips on debugging this? |
| 10:24 | om | elvis4526: you're welcome (by the way, it should be org.postgresql.Driver, if you ever need it) |
| 10:32 | danlentz | there are worse things than piles of solutions |
| 10:32 | danlentz | :) |
| 10:45 | ppppaul | anyone have experience using onyx and have any opinions on it? |
| 10:48 | clgv | ppppaul: what is your parallelization scenario? |
| 10:56 | timvisher | how do i reload my project.clj file without restarting my repl? |
| 10:58 | clgv | timvisher: because of new dependencies? |
| 10:59 | clgv | timvisher: there at least two libs to add dependencies on the fly |
| 11:01 | danlentz | look at vinyasa |
| 11:01 | danlentz | https://github.com/zcaudate/vinyasa |
| 11:04 | clgv | right, that was one of them |
| 11:13 | danlentz | timvisher: this looks interesting also http://palletops.com/alembic-clojure-classpath-control/ |
| 11:13 | timvisher | thanks! |
| 11:17 | justin_smith | alembic.still/load-project simply adds any deps that are in your project.clj but have not been loaded by the vm yet |
| 11:19 | alejandrozf | Hi all! how I could get "full" leiningen for "transporting" to an offline machine? |
| 11:20 | wink | alejandrozf: it shouldn't be more than the bat/sh called 'lein' and one corresponding jar in the correct path, i.e. under ~/.lein/ |
| 11:21 | alejandrozf | wink: both are on github page? |
| 11:22 | wink | alejandrozf: you could just grab the lein.sh, do an install and then copy the jar from .lein/self-installs |
| 11:22 | wink | it probably IS somewhere there as well, yeah |
| 11:22 | alejandrozf | wink: ohh thanks :)! |
| 11:23 | wink | the shell script is not hugely complicated, if you take a peek |
| 11:23 | wink | if it can't find the jar, it will download it |
| 11:23 | wink | and I think you only need to copy those 2 files and you're set |
| 11:23 | alejandrozf | wink: got it! I will take look too! |
| 11:26 | danlentz | this githib ddos attack certainly is lasting a while |
| 11:27 | chouser | thanks, china |
| 11:28 | clgv | chouser: huh? |
| 11:30 | chouser | clgv: There's some evidence that the Chinese Gov't is using its firewall capabilities to drive the ddos. |
| 11:30 | clgv | chouser: why wouldn't they like github? |
| 11:31 | danlentz | quick, deploy the octocats! |
| 11:31 | chouser | clgv: https://en.greatfire.org/blog/2015/mar/evidence-shows-cnnic-and-cac-behind-mitm-attacks |
| 11:33 | danlentz | The solution is simple. Lets just ask them to borrow some more money to upgrade our cyber defenses. |
| 11:33 | clgv | chouser: that article talks about th certificate issuses (MITM)? |
| 11:33 | zot | is there a way to override the hasheq function on a defrecord-created type? |
| 11:34 | justin_smith | clgv: chouser: yeah, that's proof that China did it, not a reason they would want to |
| 11:34 | justin_smith | I think the rationale has to do with the fact that github can be used to share arbitrary content, and tools that can be used to defeat the great firewall |
| 11:35 | sobel | danlentz: i think i just fell for vinyasa on the tagline alone: give your workflow more flow |
| 11:37 | clgv | sobel: :D |
| 11:38 | danlentz | sobel: wait until you get to the part about “Downard Facing Defn” |
| 11:38 | zot | (i should clarify — override, short of using deftype and having to manually make all the other stuff…) |
| 11:40 | clgv | zot: what is the requirement forcing you to do that? |
| 11:40 | zot | currently, porting some clojurescript code that already seems to do this; it's okay if it's a bit hackey, since it's a proof of concept |
| 11:41 | clgv | zot: it doesnt sound like a good idea to ruin defrecords ability to behave like a normal map |
| 11:42 | zot | ruin is a strong word :) in my case, I just want it to exclude hashing one of the fields |
| 11:43 | clgv | zot: can you trick it by making that field mutable? |
| 11:43 | zot | interesting idea. would that have other implications? |
| 11:44 | zot | actually, i thought that mutable only exists for deftype ... |
| 11:44 | zot | (looking now) |
| 11:46 | clgv | zot: honestly, I wouldnt attempt that. |
| 11:46 | clgv | zot: can't you achieve the same via aggregation? |
| 11:47 | timvisher | should the cider repl maintain history between sessions? |
| 11:47 | zot | clgv: what do you by aggregation? |
| 11:47 | clgv | have a deftype with the field for the non-hash data and the defrecord? |
| 11:48 | zot | meaning house the non-hashable data as a field of the defrecord? or as separate entities? |
| 11:50 | clgv | zot: (deftype Composite [strange-value, record] ...implement...your...own...hashing...) |
| 11:50 | danlentz | zot: why must you directly use hashing? |
| 11:50 | clgv | zot: the composite would not have map properties though |
| 11:52 | sobel | danlentz: lordy. =) |
| 11:53 | zot | danlentz: short version — i initially elided all of the hash/equiv code when trying to port, and i have tracked down a couple bugs to this, so they were clearly necessary. i could probably change the structure a bit to avoid it, but my intention is to avoid invasive changes when possible. i may just do the deftype thing, since for at least one of these objects, i don't need full map-i-ness. |
| 11:53 | zot | oops, second half was really a response to clgv |
| 11:54 | clgv | zot: I'd reevaluate the solution approach of the CLJS implementation |
| 11:55 | clgv | zot: it smells as if there is something fishy ;) |
| 11:56 | zot | clgv: not sure if it's fishy per se, or perhaps my explanation sucks. code in question is here: https://github.com/tonsky/datascript/blob/master/src/datascript/core.cljs#L18 |
| 11:57 | zot | basically for comparison, just want e/a/v, ignore tx/added. (this exists in at least 2 other structures in the codebase, so it's not unique to this one, but simplest to see.) |
| 11:57 | clgv | zot: IHash is the standard protocol of CLJS, right? |
| 11:57 | zot | yep |
| 11:57 | zot | as i understand, IHashEq is the clj equivalent for transparent operation |
| 11:58 | clgv | ok then you are running into the problem that Clojure is not build up from protocols ;) |
| 11:59 | zot | i know… i'm still smiling from the hope that something hacky would apparate in front of me :) and doing it as a deftype in the meanwhile. |
| 11:59 | clgv | zot: which part of the map implementation does Datom need? |
| 11:59 | Glenjamin | can you just (defn same-datom) ? |
| 11:59 | clgv | zot: just associative lookup and write? |
| 12:00 | clgv | Glenjamin: I'd guess hashin is used implicitely e.g. from PHM |
| 12:00 | Glenjamin | oh right, good point |
| 12:01 | clgv | otherwise that's a solution ;) |
| 12:01 | zot | for Datom I haven't checked, but at least one other structure required that i add real map'y code. (i'm looking at my own log to see.) |
| 12:01 | Glenjamin | could throw the mutable bits on metadata perhaps? |
| 12:01 | Glenjamin | which is horrible |
| 12:01 | zot | yeah, i had that thought and got distracted. is that doable / pure evil? |
| 12:01 | zot | (i can accept doable evil for now, since i've already crossed the line once or twice just to make the tests work.) |
| 12:02 | clgv | zot: because there are interfaces for lookup and write that you could implement on a deftype in case you do not need a real map but want associative operations |
| 12:02 | zot | yeah, that's what i've done elsewhere. |
| 12:03 | wink | hmm, anyone knows of a dsl/example/something related how to define a flow of sorts? |
| 12:03 | wink | actual problem: a storm topology. the builder syntax (java) is horrible. I might try to write some "config" and read that |
| 12:05 | zot | clgv: that's my path, apparently, although it will mark the first conversion from defrecord -> deftype, between the 2 languages, which makes me … nervous. |
| 12:06 | clgv | zot: I'd change the CLJS implementation as well. |
| 12:07 | zot | that thought crossed my mind too, and probably doesn't cost me toooo much. |
| 12:09 | zot | clgv: thanks for the thoughts, i appreciate the shared wisdom :) |
| 12:10 | clgv | zot: no problem ;) |
| 12:29 | om | is there a better way to do this?: |
| 12:29 | om | ,(def index {1 [:a :b :c] 2 [:a :c] 3 [:a :d]}) |
| 12:29 | clojurebot | #'sandbox/index |
| 12:29 | om | ,(defn r-map [ids] (apply merge-with into (for [[k vs] ids, v vs] (hash-map v (vector k))))) |
| 12:29 | clojurebot | #'sandbox/r-map |
| 12:30 | om | ,(r-map index) |
| 12:30 | clojurebot | {:c [1 2], :b [1], :d [3], :a [1 2 3]} |
| 12:31 | gfredericks | om: looks pretty reasonable to me |
| 12:33 | om | gfredericks: no way to avoid n^2 order, I guess? |
| 12:33 | clgv | om: you need to specify at least one goal to put "better" into context ;) |
| 12:34 | clgv | om: no that's possible in O(n) |
| 12:34 | om | clgv: right ;) : say, 1) more efficient 2) more idiomatic |
| 12:35 | clgv | om: you can do it with `reduce-kv` |
| 12:35 | om | thanks gfredericks, clgv I'll stick with it |
| 12:36 | clgv | n^2 is aweful for that task ;) |
| 12:36 | om | oh |
| 12:36 | om | clvg: this is why I asked ;) |
| 12:37 | gfredericks | what's n^2 about it? what's n? |
| 12:37 | clgv | om: with more precise estimation both version end up with O( m*n ) with number of entries n and maximum number of vals m |
| 12:38 | arrdem | gfredericks: think should I back out that options map edit to the wiki? |
| 12:38 | om | clgv: yeap, sure, in my example n=m in the worste case |
| 12:38 | gfredericks | arrdem: the what?? |
| 12:38 | lazybot | gfredericks: What are you, crazy? Of course not! |
| 12:38 | justin_smith | ,(reduce (fn [acc [k vs]] (reduce (fn [acc v] (update-in acc [v] (fnil conj []) k)) acc vs)) {} {1 [:a :b :c] 2 [:a :c] 3 [:a :d]}) |
| 12:38 | clojurebot | {:a [1 2 3], :b [1], :c [1 2], :d [3]} |
| 12:39 | arrdem | gfredericks: https://groups.google.com/d/msg/clojure/yzLCZh-GiQ8/nXiIFewvdusJ and your reply |
| 12:39 | justin_smith | om: nested reduce ^ |
| 12:39 | om | (inc justin_smith) |
| 12:39 | lazybot | ⇒ 218 |
| 12:39 | gfredericks | arrdem: I haven't looked at the clojure list in decades, are you confusing me with gtrak? |
| 12:39 | arrdem | derp sorry man |
| 12:39 | om | thks folks |
| 12:39 | gfredericks | (inc gtrak) ;; where is that guy anyways |
| 12:39 | lazybot | ⇒ 13 |
| 12:40 | arrdem | I haven't seen him around here in ages... |
| 12:40 | justin_smith | yeah, it's been a while |
| 12:40 | justin_smith | $seen gtrak |
| 12:40 | lazybot | gtrak was last seen quittingRemote host closed the connection 1 week and 6 days ago. |
| 12:40 | gfredericks | I hung out with him at strangeloop a good bit but that's it |
| 12:40 | justin_smith | only a week! |
| 12:40 | arrdem | justin_smith: hey man that's a lot of clock cycles |
| 12:41 | gfredericks | he might be the only peer named Gary I've ever known |
| 12:41 | gfredericks | it's an unfamiliar feeling |
| 12:41 | clgv | justin_smith: one angel dies when you use `reduce` on a map ;) |
| 12:41 | justin_smith | haha |
| 12:41 | clgv | every time :P |
| 12:42 | justin_smith | clgv: so are you saying I should be using reduce-kv or what? |
| 12:42 | mavbozo | i want to append streams of data to a file but there could be many writer. is clojure.java.io/writer with :append true is good enough to prevent writers overwriting each other? |
| 12:42 | clgv | justin_smith: yes |
| 12:42 | justin_smith | clgv: the inner one is not on a map, btw |
| 12:42 | clgv | justin_smith: but the outer one |
| 12:43 | justin_smith | clgv: I think I misenterpreted "every time" |
| 12:43 | justin_smith | ,(reduce-kv (fn [acc k vs] (reduce (fn [acc v] (update-in acc [v] (fnil conj []) k)) acc vs)) {} {1 [:a :b :c] 2 [:a :c] 3 [:a :d]}) |
| 12:43 | clojurebot | {:a [1 2 3], :b [1], :c [1 2], :d [3]} |
| 12:43 | om | clgv, justin_smith: this doesn't change much ;) |
| 12:44 | justin_smith | om: I'm sure he has a good reason for making the distinction |
| 12:45 | om | justin_smith: you mean to prefer the 3 arg reduce-kv to destructuring? |
| 12:45 | clgv | om: `reduce-kv` is more efficient and semantically the better fit |
| 12:46 | om | clgv: thanks, I'll cast a look at the source |
| 12:46 | justin_smith | yeah, it's the more specialized version I just keep forgetting |
| 12:46 | justin_smith | om: the source is uninformative |
| 12:46 | om | regarding effciency? |
| 12:46 | justin_smith | unless you go find the java underlying it I guess |
| 12:46 | justin_smith | regarding anything, it's just an interop call |
| 12:46 | clgv | $source reduce-kv |
| 12:46 | lazybot | reduce-kv is http://is.gd/mzlL83 |
| 12:46 | om | yeap I see that now ;) |
| 12:47 | clgv | $source APersistentHashMap |
| 12:47 | lazybot | Source not found. |
| 12:47 | clgv | $source PersistentHashMap |
| 12:47 | lazybot | Source not found. |
| 12:47 | clgv | damn... |
| 12:47 | om | cider shows it in a snap ;) |
| 12:47 | justin_smith | om: clgv: semantically better, perf wise the difference is negligable https://www.refheap.com/98938 |
| 12:48 | Bronsa | justin_smith: that's kinda surprising |
| 12:48 | justin_smith | it might make a bugger difference to pull out the fnil |
| 12:48 | clgv | justin_smith: make the map bigger and you'll see ;) |
| 12:49 | justin_smith | Bronsa: that's from a 1.6 repl |
| 12:50 | justin_smith | Bronsa: one moment, something weird might have been going on in my repl |
| 12:52 | justin_smith | I accidentally ran the reduce-kv one twice, because my inferior-lisp is being stupid |
| 12:52 | justin_smith | and the presence of the inputs is misleading compared to what generated them |
| 12:54 | justin_smith | Bronsa: clgv: https://www.refheap.com/98938 updated, the difference is less negligable, but still relatively small |
| 12:55 | clgv | justin_smith: again, try a bigger map |
| 12:56 | justin_smith | I don't know about you, but bigger maps aren't the common case in my code |
| 12:56 | clgv | well, then it's not worth it for you |
| 12:57 | clgv | the difference is 6% and the reduce-kv is probably not the dominant part in that form |
| 12:57 | justin_smith | clgv: as expected, replacing (fnil conj []) as an inline with a top level def makes a bigger perf difference |
| 12:57 | justin_smith | hmm... maybe not bigger, similar |
| 12:58 | om | pretty interesting, thanks justin_smith: |
| 12:59 | danlentz | so, reduce on a map is inefficient? |
| 13:00 | bendlas | ,(doc reduce-kv) |
| 13:00 | clojurebot | "([f init coll]); Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no entries, returns init and f is not called. Note that reduce-kv is supported on vectors, where the keys will be the ordinals." |
| 13:00 | om | I am dealing with adjacency tables and they are getting bigger: I'll do some testing |
| 13:00 | justin_smith | danlentz: I think it's more that reduce-kv is more optimized. For example it avoids the usual destructuring, if nothing else. |
| 13:05 | danlentz | seems like a seq of MapEntries would get destructured at some point |
| 13:06 | justin_smith | chouser: yeah, I found some more detailed info, and the specific github repos being ddosed are tools for circumventing the Chinese government firewall. |
| 13:06 | justin_smith | danlentz: destructuring isn't just about getting some values out of a container though |
| 13:06 | justin_smith | it's relatively heavyweight (the destructuring syntax specifically) |
| 13:07 | justin_smith | not like it will be a bottleneck, but it's big enough to consider taking it out of code that is in a bottleneck |
| 13:08 | danlentz | thats for pointing that out. I don’t think I’ve done it, but I’m not sure it would have occurred to me _not_ to do it |
| 13:24 | BinaryResult | A quick reminder, Disco Melee is currently hiring clojure developers https://docs.google.com/document/d/1GvnrSCUbYgbY9XdFs_DUx-0QZG2bIYT8Mbr0zdpTeew/edit?usp=sharing |
| 13:31 | rizo | hey, I started getting frequent repl fails recently: "Exception in thread "Thread-3" SocketException The transport's socket appears to have lost its connection to the nREPL server" |
| 13:31 | rizo | anyone knows what can cause it? |
| 13:31 | justin_smith | rizo: is it a local or remote repl? |
| 13:32 | rizo | local one |
| 13:32 | justin_smith | rizo: how are you accessing the repl - from an editor? |
| 13:32 | rizo | no, from the shell directly |
| 13:33 | justin_smith | OK, it's weird that there would be no indication of why the repl failed |
| 13:33 | rizo | justin_smith: $ `lein repl` ... nREPL server started on port 58236 on host 127.0.0.1 - nrepl://127.0.0.1:58236 |
| 13:34 | rizo | full output: https://gist.github.com/rizo/e20ed0d3dc53daafb92a |
| 13:34 | justin_smith | and when does this happen? |
| 13:35 | justin_smith | just randomly? immediately on startup? |
| 13:35 | rizo | I'm running an analytics system with a scheduler component (cronj), cassandra and redis. And it just fails in the middle of calculation |
| 13:35 | justin_smith | 137 means it got forcibly killed |
| 13:36 | justin_smith | it could be a victim of linux kernel memory overcommit |
| 13:36 | rizo | I've been using this service for some time now, it never happened before. I don't know though if some recent changes my team made to the project could affect something |
| 13:36 | justin_smith | rizo: is this on linux? |
| 13:36 | rizo | ubuntu lts |
| 13:37 | justin_smith | so, when you ask linux for memory, it always says yes |
| 13:37 | rizo | It runs for like 2 - 5 minutes and then fails |
| 13:37 | justin_smith | and if you try to use memory that isn't physically there, a random process gets killed |
| 13:37 | justin_smith | the more memory you are using, the higher the chance your process is killed |
| 13:37 | rizo | happende on two different machines. same project same docker container |
| 13:37 | rizo | (yes, i'm using the clojure:latest docker image, forgot to mention) |
| 13:38 | justin_smith | unless something else is randomly handing out SIGKILL to your processes, I would look at reducing your memory usage (starting with setting a lower max heap usage for the vm) |
| 13:39 | rizo | well... both of the servers have 32G of memory and I don't think they used it all during the execution |
| 13:39 | justin_smith | rizo: then find out what sends your process a sigkill |
| 13:39 | justin_smith | and turn on core dumps, you can use gdb to find out exactly what was happening when the sigkill happened |
| 13:40 | justin_smith | but really, random sigkill almost always means memory overcommit |
| 13:40 | rizo | I'll try it, thanks |
| 13:42 | justin_smith | rizo: funny enough, first google hit for signal 137 from java, was someone who was getting their cassandra server killed because of memory overcommit |
| 13:42 | rizo | It's really strange since I already tested the project with far more input data but it never failed this way |
| 13:42 | justin_smith | rizo: could be as simple as something that uses n^2 memory that snuck into the codebase |
| 13:43 | rizo | justin_smith: in my case it's a client cassaforte, I fetch around 5gb for batch processing |
| 13:43 | justin_smith | rizo: OK, I'd say profile things, turn on core dumps, check memory usage settings for the container if applicable |
| 13:44 | rizo | will have to check the recent commits. So you think the reason for the process failure is the os sending sigkill? Can it be anything else? |
| 13:44 | justin_smith | rizo: no, exit code 137 means the process received a sigkill |
| 13:45 | justin_smith | the signal sent via kill -9 |
| 13:45 | justin_smith | or when you access overcommitted memory |
| 13:45 | rizo | makes sense |
| 13:47 | rizo | justin_smith: thanks for the tips ;) |
| 13:50 | rizo | justin_smith: one of the recent changes was related with the cache handling, so it may have affected the memory usage |
| 13:50 | justin_smith | rizo: yeah, that smells right |
| 13:51 | justin_smith | rizo: ever use jvisualvm? you can connect to the process and log memory usage (both total, and how much of the allocated memory is available) as it runs |
| 13:51 | justin_smith | it makes a nice graph |
| 13:52 | justin_smith | and if I'm right, you'll see an attempt to jump up in mem usage just before the process is killed |
| 13:54 | rizo | justin_smith: yeah, one of my colleague uses it. will try it now |
| 13:58 | JanMan_ | 'ello |
| 14:00 | JanMan_ | For those interested, I'm building a Clojure teams in multiple places to deliver a next generation distributed systems platform based fully on Clojure. Looking for senior engineers who like Clojure to participate. http://bit.ly/1N7Aui9 |
| 14:02 | puredanger | JanMan_: maybe you should sponsor a Clojure conference |
| 14:02 | arrdem | (inc puredanger) |
| 14:02 | lazybot | ⇒ 39 |
| 14:03 | danlentz | ,danlentz |
| 14:03 | clojurebot | #error{:cause "Unable to resolve symbol: danlentz in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: danlentz in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: danlentz in this context",... |
| 14:03 | arrdem | (identity danlentz) |
| 14:03 | lazybot | danlentz has karma 1. |
| 14:03 | justin_smith | danlentz: it's only a pseudo syntax |
| 14:04 | danlentz | ,(def danlentz Math/PI) |
| 14:04 | clojurebot | #'sandbox/danlentz |
| 14:04 | danlentz | ,danlentz |
| 14:04 | clojurebot | 3.141592653589793 |
| 14:04 | danlentz | (identity danlentz) |
| 14:04 | lazybot | danlentz has karma 1. |
| 14:05 | JanMan_ | puredanger: Yup will be at Clojure West and hosting our local Clojure group |
| 14:05 | puredanger | JanMan_: thanks! We opened the sponsorship prospectus for http://euroclojure.org/sponsorship today too. |
| 14:13 | JanMan_ | puredanger: Euro's a bit far for us to sponsor as we're USA based... although I have teams in Australia and Costa Rica. |
| 14:13 | puredanger | no worries, just doing my job :) |
| 14:13 | JanMan_ | ABC: Always Be Closing |
| 14:15 | dyba | The other day I asked about a nif macro, a numeric if that looks like this: |
| 14:15 | joe124 | how do i convert a string to an integer or number? |
| 14:15 | dyba | (defmacro nif "Numeric if. `expr` must evaluate to a number." [expr pos zero neg] `(cond (pos? ~expr) ~pos (zero? ~expr) ~zero :else ~neg)) |
| 14:16 | dyba | I understand this version is buggy because it doesn't account for side effects |
| 14:16 | dyba | Rather, the correct way to define this macro is with a gensym |
| 14:17 | dyba | (defmacro nif [expr pos zero neg] (let [e (gensym)] `(let [~e ~expr] (cond (pos? ~e) ~pos (zero? ~e) ~zero :else ~neg)))) |
| 14:17 | Bronsa | dyba: you want something like (defmacro nif [expr pos zero neg] `(let [expr# ~expr] (cond (pos? expr#) ~pos ..))) |
| 14:17 | dyba | Bronsa: that was my next question, if I could use the # with a binding |
| 14:18 | Bronsa | dyba: yes, most of the time there's no reason toe us (gensym) directly in clojure |
| 14:18 | Bronsa | to use* |
| 14:18 | dyba | I think when I tried that out it didn't work but maybe it was because I had an outer let statement that wasn't quoted in which I used e# |
| 14:18 | Bronsa | there are cases where you will need it, but this is not one of those |
| 14:18 | dyba | expr# |
| 14:19 | joe124 | how do i convert a string to an int or have user-input take in their input as an int? |
| 14:19 | Bronsa | dyba: right, the auto-gensym thing works only in the context a syntax-quote |
| 14:19 | justin_smith | dyba: why is this a macro? |
| 14:24 | amalloy | justin_smith: because it only evaluates one of pos/zero/neg |
| 14:24 | justin_smith | ahh, of course |
| 14:25 | dyba | justin_smith: if you make it a function, you don't account for side effects |
| 14:25 | dyba | that is, evaluating expr may repeat the result more than once |
| 14:26 | dyba | Oh, I just saw amalloy answered |
| 14:28 | joe124 | can someone help me with my tiny function? http://pastebin.com/KNv9UY7z |
| 14:28 | joe124 | (i'm a beginner) |
| 14:29 | justin_smith | joe124: int doesn't have side effects |
| 14:29 | justin_smith | joe124: also, your let has too many () |
| 14:29 | justin_smith | around it |
| 14:30 | joe124 | ok one sec |
| 14:30 | justin_smith | joe124: so user-input is a string, throughout the entire function |
| 14:30 | justin_smith | also, int doesn't work on strings |
| 14:31 | joe124 | what is the proper way to either input an int from a user or convert a string to an int? |
| 14:31 | justin_smith | ,(Integer/parseInt "1") |
| 14:31 | clojurebot | 1 |
| 14:32 | joe124 | it says no such namespace: integer |
| 14:32 | justin_smith | joe124: I guess you didn't capitalize it properly |
| 14:32 | justin_smith | joe124: but that doesn't change the string into an int - it gives a new int from the string, and you have to use the return value |
| 14:34 | joe124 | does this l ook better? http://pastebin.com/sJeeQaiA |
| 14:34 | justin_smith | that looks like it is probably right |
| 14:34 | justin_smith | did you try it? |
| 14:34 | joe124 | yah it works, |
| 14:34 | joe124 | i'm wondering is this a proper functional style? |
| 14:35 | justin_smith | it's printing a response rather than returning anything useful |
| 14:37 | justin_smith | and it's inherently an IO thing - it takes user input and prints, there's no way to really do those things "functional" |
| 14:37 | joe124 | ok one sec |
| 14:38 | Glenjamin | you can do more to separate the IO from the computation, but it's hard in a 3 line example |
| 14:38 | justin_smith | yeah |
| 14:39 | justin_smith | I think the distinction is harder to derive for something so simple |
| 14:39 | joe124 | thats a g ood point lol |
| 14:39 | joe124 | can you explain why this code doesn't w ork http://pastebin.com/qGCMWchC |
| 14:40 | joe124 | is my 'if' statement in the wrong parenthesis or something |
| 14:40 | justin_smith | joe124: true and false are not functions |
| 14:40 | justin_smith | so you can't call them |
| 14:40 | joe124 | yah i just want to return them |
| 14:40 | justin_smith | parens don't do that, they call things |
| 14:41 | justin_smith | joe124: that function could be (defn is-greater-or-equal-to-five [x] (>= x 5)) |
| 14:41 | Glenjamin | http://pastebin.com/Fi5djbkh perhaps |
| 14:41 | justin_smith | (inc Glenjamin) |
| 14:41 | lazybot | ⇒ 18 |
| 14:42 | mpenet | rizo: you're fetching the data in a single query? |
| 14:43 | mpenet | rizo: anyway it's probalby not the main issue |
| 14:46 | arrdem | Has anyone played with trying to make macros as values meaningful? I'm just thinking that for some stuff like `or` and `and` there is a clear two-arity function which could make sense to take as a value. (yes I'm aware we have wrapper fns). |
| 14:46 | joe124 | thank you glenjamin and justin_smith |
| 14:46 | justin_smith | arrdem: apply would become a pain in the ass to implement |
| 14:46 | justin_smith | arrdem: is my suspicion at least |
| 14:47 | justin_smith | currently it isn't a macro, and doesn't have to worry about leaving args unevaluated |
| 14:50 | rizo | mpenet: not alway. the queries run in sequence but in total there must be dozens of them |
| 14:50 | joe124 | When is object oriented programming a better decision to use than functional, and vice versa? |
| 14:51 | danlentz | when in rome… |
| 14:51 | mpenet | rizo: if you can parallelise them alia will be a lot faster at this kind of things |
| 14:56 | mavbozo | joe124: in what context? clojure? |
| 14:58 | justin_smith | joe124: object oriented is good for things that don't need threads, you don't have tight memory constraints, and you need something that's easily split between many programmers. Functional is good if you need threads or async in general, if you don't have tight memory constraints, and the problem is expressable directly as an algorithm needing relatively little interaction with the outside world mid calculation. |
| 14:59 | danlentz | wait, when you dont have tight memory constraints? |
| 15:00 | justin_smith | danlentz: neither is apropriate for situations with tight memory constraints |
| 15:05 | anti-freeze | Hey everyone. Does anyone know how to include domina in selmer after the clojurescript compiler does its work? |
| 15:06 | anti-freeze | I keep getting blank source files when they're actually included |
| 15:08 | anti-freeze | Or infact any of the Compiled JS files in the js/out folder |
| 15:08 | anti-freeze | compiled CLJS* |
| 15:10 | ambrosebs | ,(reduce + 0 [1 2]) |
| 15:10 | clojurebot | 3 |
| 15:15 | joe124 | (reduce #(* % 2) myList) why doesnt this work? |
| 15:16 | arrdem | joe124: reduce takes a function of two arguments. Your provided function is a function of one argument. |
| 15:17 | emaczen | Is there a function that combines range and take? |
| 15:17 | emaczen | I know of nth rest, but I would also need an nthfirst |
| 15:17 | emaczen | but I am also hoping that these utilities already exist |
| 15:18 | joe124 | (reduce #(* % %) lst) ? |
| 15:18 | mavbozo | (reduce #(* %1 %2) lst) |
| 15:19 | joe124 | i want to take each element in the list, double it, then multiply it by the next element |
| 15:19 | arrdem | joe124: okay, so #(* 2 %1 %2) would do it for you. |
| 15:20 | joe124 | woah thanks |
| 15:20 | arrdem | you may need to give reduce the base case of 1. |
| 15:20 | arrdem | otherwise it'll use the first element of the seq as its base case, and you'll be off by a factor of 2 in the result |
| 15:21 | arrdem | so ##(reduce #(* 2 %1 %2) 1 [2 3 4 5]) |
| 15:21 | lazybot | ⇒ 1920 |
| 15:22 | arrdem | ##(reduce * (map #(* %1 2) [2 3 4 5])) |
| 15:22 | lazybot | ⇒ 1920 |
| 15:22 | arrdem | w00t |
| 15:22 | joe124 | reduce is scary can i just use map? |
| 15:24 | jroes | don't be afraid! |
| 15:24 | puredanger | ,(*) |
| 15:24 | clojurebot | 1 |
| 15:25 | arrdem | joe124: how could you solve this problem using only map? you need to accumulate a result over each element of the seq. |
| 15:25 | arrdem | map will just give you a new seq back with everything multiplied by two for instance. |
| 15:25 | joe124 | thats true |
| 15:26 | joe124 | can you give me a problem so solve to practice using reduce |
| 15:27 | arrdem | joe124: implement get-in using reduce. it's not too hard. |
| 15:28 | joe124 | what does get-in do |
| 15:28 | arrdem | so (get-in {:a {:b {:c 1}}} [:a :b :c]) -> 1 |
| 15:29 | joe124 | so it adds the values of everything in there? |
| 15:29 | arrdem | I suppose this is perfect #clojure-beginners material.. |
| 15:29 | joe124 | omg that exists |
| 15:29 | spieden | joe124: it paths into nested maps using a sequence of keys |
| 15:30 | joe124 | (get-in {:a {:b {:c 1}}} [:a :b]) -> {:c 1} ? |
| 15:30 | arrdem | joe124: bingo |
| 15:30 | spieden | yep |
| 15:30 | danlentz | well |
| 15:31 | danlentz | (map vector lst (rest list)) |
| 15:31 | danlentz | will break it into pairs for you |
| 15:31 | joe124 | i dont know what vector and rest mean |
| 15:32 | arrdem | $grim clojure.core/rest |
| 15:32 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/rest |
| 15:32 | arrdem | $grim clojure.core/vector |
| 15:32 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/vector |
| 15:32 | arrdem | since good 'ol hiredman has banned me from clojurebot's doc functionality |
| 15:32 | danlentz | but reduce is better |
| 15:33 | arrdem | joe124: so how can we do get-in with reduce? |
| 15:34 | joe124 | we have to change [:a :b :c] to look like ({{:a {:b {:c}}) so it evaluates the :c |
| 15:34 | danlentz | arrdem: are you calling hiredman a bot-blocker |
| 15:34 | danlentz | ;) |
| 15:35 | joe124 | is it mainly a formatting problem? |
| 15:36 | arrdem | joe124: nope. what does reduce do? |
| 15:37 | joe124 | sums everything? |
| 15:37 | joe124 | if you use + |
| 15:37 | danlentz | joe124: it is important to understand that [:a :b :c] and {:a {:b {:c nil}}} are not just formatted differently, but structurally different |
| 15:38 | joe124 | sure but if we can format it correctly and put () around it it will evaluate to get the value we want |
| 15:38 | Seylerius | joe124: It bangs everything through one function. |
| 15:39 | joe124 | im just a bit confused between reduce and map |
| 15:39 | joe124 | i know map applies a function to everything |
| 15:39 | arrdem | yep. |
| 15:39 | Seylerius | Basically, it starts with the first two, and repeats with the next and the result of the first, and so on. |
| 15:39 | danlentz | ,(doc reduce) |
| 15:39 | clojurebot | "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i... |
| 15:40 | arrdem | eh docstring truncation |
| 15:40 | arrdem | $grim clojure.core/reduce |
| 15:40 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/reduce |
| 15:41 | joe124 | so (reduce + [1 2 3]) is like (+ (+ 1 2) 3) |
| 15:41 | arrdem | exactly |
| 15:41 | jroes | ,(reduce + [1 2 3]) |
| 15:41 | clojurebot | 6 |
| 15:42 | arrdem | it's important to note that in the two argument case, the first element of the sequence is used as reduce's initial accumulator value. |
| 15:42 | arrdem | you can specify the accumulator by giving three arguments, being the function, the accumulator and then the sequence of inputs. |
| 15:43 | arrdem | so to go back to the get-in example |
| 15:43 | arrdem | we have the function |
| 15:43 | arrdem | $grim clojure.core/get |
| 15:43 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/get |
| 15:43 | arrdem | ##(get {:a 1} :a) |
| 15:43 | lazybot | ⇒ 1 |
| 15:44 | arrdem | so we can write get-in as the reduce of get over the input datastructure and the list of keys. |
| 15:44 | arrdem | ##(reduce get {:a {:b {:c 1}}} [:a :b :c]) |
| 15:44 | lazybot | ⇒ 1 |
| 15:45 | arrdem | which is the same as saying (get (get (get {:a {:b {:c 1}}} :a) :b) :c) |
| 15:45 | joe124 | i dont get it |
| 15:46 | joe124 | wait |
| 15:46 | joe124 | so the first get returns what |
| 15:46 | danlentz | see how it follows the same pattern as what you did a moment ago with + |
| 15:46 | joe124 | i mean the most inside get |
| 15:46 | arrdem | ##(get {:a {:b {:c 1}}} :a) |
| 15:46 | lazybot | ⇒ {:b {:c 1}} |
| 15:47 | danlentz | what does the second one return? |
| 15:47 | arrdem | so {:a {:b {:c 1}}} is a map which maps the value :a to a map which maps the value :b to a map which maps the value :c to 1 |
| 15:47 | joe124 | second get returns {:c 11} |
| 15:48 | arrdem | {:c 1} yes |
| 15:48 | danlentz | yup |
| 15:48 | danlentz | and the third? |
| 15:48 | joe124 | third get returns :c |
| 15:48 | jroes | ,(get {:c 1} :c) |
| 15:48 | clojurebot | 1 |
| 15:48 | arrdem | why would the third return :c? |
| 15:49 | joe124 | well it returns :c but then changes to it's key or whatever of 1 |
| 15:49 | arrdem | the third will get the value named by the key :c from the map {:c 1} |
| 15:49 | joe124 | i mean value yeah |
| 15:51 | joe124 | ##(reduce get {:a {:b {:c 1}}} [:a :b]) |
| 15:51 | lazybot | ⇒ {:c 1} |
| 15:51 | joe124 | ##(get {:c 1} [:c]) |
| 15:51 | lazybot | ⇒ nil |
| 15:52 | joe124 | ? |
| 15:53 | nkoza | joe124: (get-in {:c 1} [:c]) or (get {:c 1} :c) |
| 15:54 | joe124 | why does get-in use a vector as an argument |
| 15:54 | nuwanda_ | because it's supposed to go through nested data structures, the vector has the list of keys to lookup |
| 15:55 | arrdem | joe124: okay so each iteration of reduce is (reduce f (f (first col)) (rest col)), right? |
| 15:56 | joe124 | what does first col mean |
| 15:56 | jroes | collection |
| 15:56 | arrdem | col is shorthand for collection. the sequence of inputs that reduce takes is named col iirc. |
| 15:56 | arrdem | first is a function. |
| 15:56 | arrdem | $grim clojure.core/first |
| 15:56 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/first |
| 15:57 | arrdem | ##(first [1 2 3]) |
| 15:57 | lazybot | ⇒ 1 |
| 15:57 | arrdem | ##(first [2 3]) |
| 15:57 | lazybot | ⇒ 2 |
| 15:57 | arrdem | ##(first [3]) |
| 15:57 | lazybot | ⇒ 3 |
| 15:57 | arrdem | etc. |
| 15:57 | joe124 | (reduce f (f (first col)) (rest col)) so... |
| 15:58 | arrdem | oops. (reduce f (f acc (first col)) (rest col)) |
| 15:58 | arrdem | sorry I dropped the accumulator |
| 15:58 | arrdem | right? because the next value of the accumulator is (f acc (first col)) |
| 15:58 | joe124 | (reduce f (f acc (first col)) (rest col)) ah im seeing |
| 15:59 | joe124 | so in '(1 2 3) first col is 1 rest col is '(2 3) |
| 15:59 | arrdem | yep. |
| 15:59 | joe124 | where do we inc first col? |
| 15:59 | joe124 | so it moves to the next one |
| 16:00 | arrdem | we don't per se |
| 16:01 | arrdem | (reduce [f acc col] (if (empty? col) acc (reduce (f acc (first col)) (rest col))))) |
| 16:01 | arrdem | so rather than "increment", and walk down the collection that way, instread we just call ourselves again with the next value of the accumulator and the rest of the collection. |
| 16:02 | joe124 | what is this showing |
| 16:02 | joe124 | how to implement reduce ? |
| 16:02 | arrdem | yep. a recursive reduce implementation. |
| 16:02 | arrdem | you could also do it as a while loop but the two are equivalent. |
| 16:02 | joe124 | is recursive is always preffered |
| 16:02 | joe124 | in clojure |
| 16:03 | arrdem | sorta. Unfortunately we don't have tail call optimization so the loop and the recursive implementation do actually do different things. |
| 16:04 | Bronsa | https://github.com/clojure/clojure/commit/caa3b4fdc8da5880309b317d0045b1280181c452 |
| 16:04 | arrdem | instead we have recurl. |
| 16:04 | arrdem | *recur |
| 16:04 | joe124 | (reduce [f acc col] (if (empty? col) acc (reduce (f acc (first col)) (rest col))))) im having a tough time understanding this |
| 16:04 | hiredman | whooo boy |
| 16:04 | joe124 | like what does this do first? |
| 16:05 | hiredman | you are missing some parts |
| 16:05 | hiredman | ,(doc reduce) |
| 16:05 | clojurebot | "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i... |
| 16:05 | arrdem | hiredman: doing foldr not reduce for simplicity |
| 16:06 | arrdem | not that you can hear me I think. |
| 16:06 | joe124 | i have to eat arrdem wil u be here later |
| 16:06 | arrdem | yep. hit me up over in #clojure-beginners. |
| 16:06 | joe124 | ok sure thanks a ton |
| 16:06 | arrdem | my pleasure |
| 16:13 | arrdem | Bronsa: yeow. thanks for the heads up. |
| 16:14 | Frozenlock | I might need to do some low level network communication. Is clojure-protobuf the way to go? |
| 16:27 | hyPiRion | If you're communicating between Clojure programs, EDN should be sufficient at first. Unless you really need perf from the get-go, which I guess you don't. |
| 16:31 | Frozenlock | It's to communicate with a protocol on UDP. Playing with bytes and stuff. (My first time going this low level) |
| 16:34 | borkdude | "identifying the platform (:clj, :cljs, :cljr)"... what's cljr? |
| 16:35 | arrdem | borkdude: cljclr? |
| 16:35 | arrdem | I'm guessing. |
| 16:35 | arohner | borkdude: .net CLR |
| 16:35 | borkdude | ah |
| 16:35 | arohner | man, cond :let would make my life simpler right now |
| 16:36 | hyPiRion | Can I identify other platforms like that? |
| 16:36 | hyPiRion | say, :?!$ as Swearjure |
| 16:36 | arohner | lol |
| 16:36 | arohner | swearjure isn't a platform :-p |
| 16:37 | arrdem | I'd vote for swearjure support on jira |
| 16:37 | Bronsa | puredanger: assuming you're investingating the cause of the build failure -- I think there's a possibility that there's a bug in the tests, I just got a failure reported with `(->> [1] (mapcat inc))` which is an obvious error |
| 16:46 | puredanger | Bronsa: thx, just starting to look at it |
| 16:46 | Bronsa | puredanger: I think there are actually 2 bugs in that test (i don't know any test.check so I have no idea how to fix them) |
| 16:46 | puredanger | the reported error looks like it's masking the real error |
| 16:47 | Bronsa | yeah |
| 16:47 | puredanger | but that should be fixed too :) |
| 16:47 | Bronsa | puredanger: the first one is the one that's causing wrong tests to be generated |
| 16:47 | puredanger | well, they're random. some of them are expected to be bogus |
| 16:47 | Bronsa | puredanger: the second one is in the error reporting, trying to shrink, that's causing the NPE |
| 16:47 | Bronsa | puredanger: yeah, it looks like the wrong one are not getting filtered out correctly |
| 16:48 | Bronsa | e.g. I just got a (->> [-2 -4 -1] (take-while empty?)) |
| 16:48 | puredanger | they don't get filtered at all, they just produce errors |
| 16:49 | Bronsa | puredanger: correct me if I'm wrong -- but the way i read it is that the intention is to catch IllegalArgumentExceptions, ClassCastExceptions and NPEs and handle those tests as if they succeeded |
| 16:50 | puredanger | close - those exceptions from the different forms are treated as equivalent |
| 16:50 | puredanger | an exception in one and no exception should not succeed |
| 16:50 | Bronsa | ah, gotcha |
| 16:51 | puredanger | we're basically applying a series of random transforms to a random input in a variety of ways |
| 16:51 | puredanger | looking for differences |
| 16:51 | Bronsa | I see now |
| 16:53 | hiredman | maybe someone in here knows the answer to this, I seem to recall a quote from someone associated with the v8 javascript runtime about performance being *the* enabling feature, does anyone recall a specific talk or something where that may be from? |
| 16:54 | Bronsa | puredanger: well I don't quite understand it then :) I'll let you guys figure it out, here's a failing test in case it's helpful http://sprunge.us/NLAh |
| 16:55 | puredanger | sure, I'll take it :) |
| 17:01 | puredanger | ohhh, I know what the problem is |
| 17:02 | sveri | Hi, I am using sqlkorma and I have an entity like this: (defentity users (belongs-to tenant)). Now when I do a (select users (with tenant).... I get a flat map back containing the tenant keys and values mixed with the users keys and values...There might be collisions when two tables have the same column names...Am I missing something here? |
| 17:22 | otwieracz | hello |
| 17:22 | otwieracz | In my ~/.lein/profiles I've got: |
| 17:22 | otwieracz | {:user {.... :dependencies [[org.clojure/tools.nrepl "0.2.10"]] }} |
| 17:22 | otwieracz | However: |
| 17:23 | otwieracz | $ lein repl |
| 17:23 | otwieracz | nREPL server started on port 38613 on host 127.0.0.1 - nrepl://127.0.0.1:38613 |
| 17:23 | otwieracz | REPL-y 0.3.5, nREPL 0.2.6 |
| 17:23 | justin_smith | otwieracz: put it in :dev |
| 17:23 | otwieracz | Why 0.2.6 is here? |
| 17:23 | mavbozo | hardcoded to leiningen |
| 17:23 | justin_smith | :dev will override the leiningen version, :user will not |
| 17:24 | otwieracz | OK, I changed from :user to :dev |
| 17:24 | otwieracz | $ lein repl |
| 17:24 | otwieracz | nREPL server started on port 56471 on host 127.0.0.1 - nrepl://127.0.0.1:56471 |
| 17:24 | otwieracz | REPL-y 0.3.5, nREPL 0.2.6 |
| 17:24 | otwieracz | (I've already tried it :)) |
| 17:25 | justin_smith | otwieracz: is this in a project, or a projectless repl? |
| 17:25 | mavbozo | as of now, you can only override it in a project |
| 17:25 | otwieracz | projectless repl. |
| 17:25 | otwieracz | It works in project. |
| 17:25 | mavbozo | there's a discussion here a couple of days ago |
| 17:27 | gfredericks | is there anything comparable to unsigned-bit-shift-right in clojure pre-1.6 |
| 17:27 | justin_smith | ~unsigned |
| 17:27 | clojurebot | excusez-moi |
| 17:27 | Lewix | gfredericks: smell like a c++ guy |
| 17:28 | otwieracz | mavbozo: OK, so if I need nrepl 0.2.10 here, because 0.2.6 is buggy |
| 17:28 | otwieracz | What should I do? |
| 17:29 | mavbozo | otwieracz: for now, you must work in a project dir |
| 17:30 | justin_smith | otwieracz: java -cp $(cat magic-cp-file-you-created-based-on-lein-cp) clojure.main |
| 17:30 | justin_smith | is also an option |
| 17:30 | justin_smith | lein cp, followed by a bit of text editing to generate that file |
| 17:30 | justin_smith | or you can put the java command plus the whole class path literal in a shell script of course |
| 17:31 | justin_smith | without a project, lein isn't really doing much for you beyond generating that classpath anyway |
| 17:31 | justin_smith | so why not cache that part, fix it, and use java |
| 17:41 | mavbozo | justin_smith: i tried it, create nrepl-server, start it, and I can connect it by using cider |
| 17:41 | oddcully | (inc justin_smith) |
| 17:41 | lazybot | ⇒ 219 |
| 17:41 | oddcully | alias-ed that |
| 17:41 | mavbozo | justin_smith: but why I still got message "Please, install (or update) cider-nrepl 0.8.2 and restart CIDER" |
| 17:41 | mavbozo | cider-nrepl is in the classpath |
| 17:41 | justin_smith | mavbozo: missing the cider-nrepl middleware at runtime? |
| 17:42 | justin_smith | maybe it isn't initialized properly? |
| 17:43 | danlentz | is there a difference between clojurebot and lazybot for evaluating expressions? ie, comma vs. hashhash |
| 17:43 | danlentz | ,danlentz |
| 17:43 | clojurebot | #error{:cause "Unable to resolve symbol: danlentz in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: danlentz in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: danlentz in this context",... |
| 17:43 | mavbozo | justin_smith: ah, you're right, I have to put another parameter in nrepl-server/start-server |
| 17:43 | danlentz | ,(def danlentz 1) |
| 17:43 | clojurebot | #'sandbox/danlentz |
| 17:43 | danlentz | ,danlentz |
| 17:43 | clojurebot | 1 |
| 17:44 | danlentz | ##danlentz |
| 17:44 | danlentz | ##(def danlentz 2) |
| 17:44 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 17:44 | danlentz | ah |
| 17:44 | danlentz | ##(identity danlentz) |
| 17:44 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: danlentz in this context |
| 17:45 | mavbozo | justin_smith: boom! done! |
| 17:45 | danlentz | ,(all-ns) |
| 17:45 | clojurebot | (#object[clojure.lang.Namespace "clojure.uuid"] #object[clojure.lang.Namespace "user"] #object[clojure.lang.Namespace "clojure.core"] #object[clojure.lang.Namespace "clojure.repl"] #object[clojure.lang.Namespace "sandbox"] ...) |
| 17:45 | mavbozo | (inc justin_smith) |
| 17:45 | lazybot | ⇒ 220 |
| 17:46 | danlentz | ##(all-ns) |
| 17:46 | lazybot | ⇒ (#<Namespace lazybot.plugins.lmgtfy> #<Namespace cheshire.parse> #<Namespace lazybot.plugins.timer> #<Namespace clojure.set> #<Namespace findfn.core> #<Namespace slingshot.slingshot> #<Namespace cheshire.generate> #<Namespace socrates.util> #<Namespace lazybot.plugin... https://www.refheap.com/98950 |
| 17:46 | danlentz | ah, neat |
| 17:49 | danlentz | ##(dir lazybot.plugins.unix-jokes) |
| 17:49 | lazybot | java.lang.SecurityException: You tripped the alarm! lazybot.plugins.unix-jokes is bad! |
| 17:50 | danlentz | ,(dir lazybot.plugins.unix-jokes) |
| 17:50 | clojurebot | #error{:cause "No namespace: lazybot.plugins.unix-jokes found", :via [{:type java.lang.Exception, :message "No namespace: lazybot.plugins.unix-jokes found", :at [clojure.core$the_ns invoke "core.clj" 3994]}], :trace [[clojure.core$the_ns invoke "core.clj" 3994] [clojure.repl$dir_fn invoke "repl.clj" 185] [sandbox$eval119 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6784] ... |
| 17:51 | danlentz | ##(ns-publics ‘member:lazybot.plugins.unix-jokes) |
| 17:51 | lazybot | java.lang.SecurityException: You tripped the alarm! ns-publics is bad! |
| 17:52 | _orangejuice | https://www.irccloud.com/pastebin/RLahrnCX |
| 17:53 | _orangejuice | why does that return false? |
| 17:53 | _orangejuice | https://www.irccloud.com/pastebin/UavVRGrF |
| 17:54 | mavbozo | ,(doc identical?) |
| 17:54 | nuwanda_ | ,(doc identical?) |
| 17:54 | clojurebot | "([x y]); Tests if 2 arguments are the same object" |
| 17:54 | clojurebot | "([x y]); Tests if 2 arguments are the same object" |
| 17:55 | mavbozo | _orangejuice:^that's your answer |
| 17:55 | nuwanda_ | basically, I don't think identical? is what you're after here, if you expect that to return true |
| 17:55 | _orangejuice | identical? checks if its referring to the same object but and = checks if data is same? |
| 17:55 | mavbozo | yup |
| 17:56 | _orangejuice | Thank you! |
| 17:58 | catern | what are some features of other languages that clojure is able to implement/steal thanks to macros? |
| 17:58 | catern | types, goroutines, pattern matching, others? |
| 18:01 | mavbozo | stm |
| 18:02 | catern | stm? |
| 18:02 | mavbozo | dosync |
| 18:02 | mavbozo | for software transactional memory |
| 18:02 | catern | ah |
| 18:07 | spieden | "->" reminds me of "$" in haskell -- a bit different though |
| 18:08 | catern | mavbozo: what other languages have stm? Erlang, right? |
| 18:08 | mavbozo | haskell |
| 18:09 | justin_smith | catern: the threading macros / doto are two other examples |
| 18:09 | catern | justin_smith: but those aren't actually stolen from other languages |
| 18:09 | justin_smith | doto being effectively like the OO a.x().y() etc. |
| 18:09 | justin_smith | catern: other lisps don't have them :) |
| 18:09 | justin_smith | but can, if they adapt our macros |
| 18:10 | mavbozo | catern: erlang does not have STM |
| 18:10 | catern | I don't really know anything about erlang, but I though Clojure concurrency stuff was Erlangish? |
| 18:11 | danlentz | justin_smith: https://github.com/danlentz/cl-ctrie/blob/master/ctrie-util.lisp#L199 |
| 18:11 | justin_smith | catern: not at all |
| 18:11 | justin_smith | catern: it's haskellish |
| 18:11 | catern | oh, okay |
| 18:11 | justin_smith | danlentz: yeah, I am glad those constructs are catching on :) |
| 18:12 | danlentz | a recursive macro, no less |
| 18:12 | justin_smith | danlentz: for all I know someone tried them in common lisp before clojure came around, but I never saw them until I learned clojure |
| 18:12 | mavbozo | catern: http://clojure.org/state -> rich hickey chose not to Erlang-style actor model |
| 18:12 | catern | the threading macros are being added to elisp core, I believe |
| 18:12 | muraiki | heh I was right about to paste that mavbozo |
| 18:12 | catern | mavbozo: oh, thank you |
| 18:12 | justin_smith | catern: yeah, maybe clojure's biggest gift so far to the lisp world |
| 18:13 | mavbozo | muraiki: :p |
| 18:13 | catern | http://endlessparentheses.com/new-on-elpa-and-in-emacs-25-1-seq-el.html |
| 18:15 | mavbozo | catern: wooo.. clojure inspired sequence abstraction |
| 18:16 | danlentz | clojures greatest gift to the lisp world is a viable language in which you can work in lisp and get paid. |
| 18:16 | Frozenlock | If only emacs was immutable... |
| 18:16 | justin_smith | haha |
| 18:16 | justin_smith | danlentz: if only that could be backported to other langs the way our new syntaxes are :) |
| 18:16 | catern | Frozenlock: if emacs was immutable then those new sequence abstractions wouldn't be added :) |
| 18:17 | Frozenlock | errr |
| 18:17 | catern | you'd have to create a new emacs with them included :P |
| 18:17 | Frozenlock | If only emacs had immutable data-structure :-p |
| 18:17 | justin_smith | my emacs is immutable, it just sits there and doesn't change no matter what I do |
| 18:17 | justin_smith | oh, never mind, that was just a super long line printing in a process buffer :) |
| 18:18 | mavbozo | (inc danlentz) |
| 18:18 | lazybot | ⇒ 2 |
| 18:21 | mavbozo | catern: we could just change the reference to point to the new emacs value |
| 18:21 | catern | mavbozo: like with gcc? |
| 18:22 | catern | and egcs |
| 18:22 | catern | :) |
| 18:24 | catern | haha |
| 18:24 | Frozenlock | Wow, I need to review all the new stuff in Emacs. Some of it is very nice. http://endlessparentheses.com/new-on-elpa-and-in-emacs-25-1-let-alist.html |
| 18:24 | catern | my type theory professor would be really mad at this statement |
| 18:24 | catern | "First and foremost, Clojure is dynamic. That means that a Clojure program is not just something you compile and run, but something with which you can interact." |
| 18:24 | catern | he would be so mad |
| 18:25 | catern | because he semifrequently says that he thinks part of the dynamic vs static thing is just a branding problem |
| 18:25 | catern | and that those dynamic languages just got a better name for themselves, and everything thinks statically typed languages are static and therefore boring and slow |
| 18:25 | catern | well here is Clojure exploiting that label! :D |
| 18:26 | danlentz | isnt static generally faster? |
| 18:26 | catern | danlentz: yes :) |
| 18:26 | catern | danlentz: but the public relations problem, you see, would lead you to believe otherwise... |
| 18:27 | justin_smith | catern: you could switch dynamic with ad-hoc and retain the meaning and likely make that professor happy |
| 18:27 | catern | justin_smith: quite so |
| 18:28 | catern | but it wouldn't sound quite as good for clojure... :) |
| 18:28 | justin_smith | catern: but I prefer clojure in part because I like to develop with an ad-hoc system with exposed underpinnings |
| 18:29 | catern | justin_smith: what does "ad-hoc system" mean? |
| 18:29 | mavbozo | catern: rich hickey does not refer to dynamic typing in that sentence |
| 18:29 | catern | (in the way you are using it) |
| 18:29 | catern | mavbozo: yeah, but that's generally what people mean by "dynamic" when discussing programming languages :) |
| 18:29 | justin_smith | catern: it means not in its final form, being modified while in use, with various abstractions only tentatively present |
| 18:30 | justin_smith | perhaps I am at heart more tinkerer than programmer |
| 18:30 | danlentz | “ad-hoc system” is how you pronounce “system” with a bad chest cold |
| 18:31 | justin_smith | "In military, ad hoc units are created during unpredictable situations, when the cooperation between different units is needed for fast action." |
| 18:31 | danlentz | I think working in lisp building things up in a very experimental, practical way is very helpful to me |
| 18:31 | justin_smith | yeah, that's what I am trying to get at |
| 18:32 | danlentz | how often do you really know everything you need to know at the very beginning of a project when designing a top-down approach |
| 18:32 | mavbozo | catern: agree, back in my early programming days, i think interpreter~dynamic vs compiled~static |
| 18:32 | danlentz | when i was young I learned on applesoft basic, which was a very interactive REPL experience |
| 18:32 | nicferrier | hey all. is there a guide to embedding a repl in your app? |
| 18:33 | danlentz | https://github.com/clojure-emacs/cider-nrepl |
| 18:33 | hiredman | https://github.com/clojure/tools.nrepl#embedding-nrepl-starting-a-server |
| 18:33 | catern | nicferrier: writing an app that isn't in Emacs? what an age it is! |
| 18:33 | nicferrier | :-) |
| 18:33 | justin_smith | nicferrier: as you'll see from those docs, it's quite easy |
| 18:34 | nicferrier | I don't really wanna embed nrepl. |
| 18:34 | nicferrier | I'd prefer just a readline like interface, basically just what clojure -m gives you. |
| 18:34 | nicferrier | or whatever the switch is. |
| 18:34 | nicferrier | still. looking. |
| 18:34 | Frozenlock | nicferrier: If you are using CIDER, you'll probably want to add the cider.nrepl handler with it. |
| 18:35 | nicferrier | Frozenlock: I'm not. can't get on with cider. |
| 18:35 | justin_smith | nicferrier: in that case, dynamically bind *in* and *out* and *err*, then launch clojure.main |
| 18:35 | nicferrier | justin_smith: when you say launch... you mean call? |
| 18:35 | justin_smith | perhaps in its own thread |
| 18:35 | justin_smith | depending what all else you are doing |
| 18:35 | justin_smith | but yeah |
| 18:36 | nicferrier | cool. |
| 18:36 | nicferrier | and if I uberjar that it'll all be cool right? |
| 18:36 | justin_smith | and you can provide the "-m" "some.ns" args if you like |
| 18:36 | justin_smith | nicferrier: yup, clojure.main is gonna be in your uberjar |
| 18:37 | nicferrier | that's awesome. |
| 18:37 | nicferrier | I wanna use it because I can't break through a firewall. |
| 18:37 | mavbozo | (inc justin_smith) |
| 18:37 | lazybot | ⇒ 221 |
| 18:38 | justin_smith | nicferrier the trick is of course providing valid *in* / *out* / *err* bindings, but if you can use the root bindings, that's a sinch |
| 18:38 | mavbozo | nicferrier: not even ssh port-forwarding? |
| 18:39 | justin_smith | nicferrier: I use ssh -L for that typically, or ssh -R depending which side I am connecting from |
| 18:39 | nicferrier | ha. you puny mortals. |
| 18:39 | nicferrier | you haven't met *real* security people. |
| 18:39 | justin_smith | haha |
| 18:40 | danlentz | *real* security people are undetectable |
| 18:40 | justin_smith | fair enough, have fun with clojure.main then :) |
| 18:40 | nicferrier | they told me that at work today. "do ssh port forwarding!" and how I laughed when we got "fd closed" |
| 18:40 | justin_smith | nicferrier: the issue with nrepl, anyway, is it gives anyone who can make a local tcp connection effectively the user who is running your app, it's wide open on the localhost |
| 18:41 | nicferrier | justin_smith: exactly |
| 18:41 | justin_smith | and you can be much picker with clojure.main |
| 18:41 | nicferrier | but I couldn't connect to it because the box is locked down by the network and I can't get anything (eg: emacs) on the box. |
| 18:41 | justin_smith | maybe this is something that will be fixed with the socket repl in core |
| 18:41 | mavbozo | what about unix domain socket? |
| 18:41 | justin_smith | mavbozo: nrepl can't use those |
| 18:41 | hiredman | nicferrier: well, you could just run the repl that clojure.main runs |
| 18:41 | justin_smith | they are hard to use from clojure |
| 18:42 | justin_smith | from the jvm, even |
| 18:42 | hiredman | the jvm doesn't do domain sockets well |
| 18:42 | nicferrier | yeah, can't use unix sockts without c extension. guess what? |
| 18:42 | justin_smith | the fact that hiredman ignores me keeps demonstrating itself |
| 18:42 | mavbozo | justin_smith: from security view point, it's good right? |
| 18:42 | nicferrier | but yeah. I can use the clojure.main I reckon. |
| 18:42 | justin_smith | mavbozo: from a security view what is good? |
| 18:42 | nicferrier | justin_smith: why does he ignore you? you're the most helpful person here! |
| 18:43 | hiredman | our main work server embeds a socket repl listening on localhost, and we have a little netcat based client |
| 18:43 | mavbozo | unix domain socket compared to tcp port |
| 18:43 | justin_smith | he likely thinks I;m annoying, who knows |
| 18:43 | nicferrier | justin_smith: oh well. you're not. |
| 18:43 | justin_smith | mavbozo: yeah, much more secure, but not accessible easily from jvm, because not portable to windows basically |
| 18:43 | hiredman | (that you run locally as *ctl script) |
| 18:45 | mavbozo | nicferrier, justin_smith there is a junixsocket for unixdomain socket with jni. but still not portable to windows |
| 18:45 | nicferrier | jni is still c |
| 18:45 | justin_smith | mavbozo: yeah, it exists, but it isn't going to end up in clojure itself |
| 19:42 | Seylerius | ,(defn dropper [coll n] (if (empty? coll) coll (into (take (dec n) coll) (dropper (drop n coll) n)))) |
| 19:42 | clojurebot | #'sandbox/dropper |
| 19:42 | Seylerius | ,(dropper [1 2 3 4 5 6 7 8] 3) |
| 19:42 | clojurebot | (5 4 7 8 1 ...) |
| 19:43 | justin_smith | Seylerius: into is different with lists, and take returns lists |
| 19:43 | justin_smith | well, lazy-seqs, but they act like lists in this case |
| 19:44 | justin_smith | ,(into () [1 2 3 4 5]) |
| 19:44 | clojurebot | (5 4 3 2 1) |
| 19:45 | Seylerius | Right. |
| 19:45 | Seylerius | Because into is conj-based |
| 19:46 | Seylerius | I'm just struggling for the alternative. |
| 19:47 | Seylerius | ,(defn dropper [coll n] (if (empty? coll) coll (into (into [] (take (dec n) coll)) (dropper (drop n coll) n)))) |
| 19:47 | clojurebot | #'sandbox/dropper |
| 19:47 | Seylerius | ,(dropper [1 2 3 4 5 6 7 8] 3) |
| 19:47 | clojurebot | [1 2 4 5 7 ...] |
| 19:47 | Seylerius | Hah. |
| 19:48 | Seylerius | It's not the prettiest thing ever, but it worked. |
| 19:49 | gfredericks | ,(partition 2 3 (range 1 9)) |
| 19:49 | clojurebot | ((1 2) (4 5) (7 8)) |
| 19:49 | Seylerius | justin_smith: got a suggestion to avoid the stacked intos? |
| 19:49 | Seylerius | Oh. Well, that's nice. |
| 19:49 | gfredericks | ,(apply concat (partition 2 3 (range 1 9))) |
| 19:49 | clojurebot | (1 2 4 5 7 ...) |
| 19:49 | justin_smith | I think you can use subvec instead of take there to avoid the nested into |
| 19:49 | justin_smith | or just use concat, yeah |
| 19:50 | Seylerius | ,(flatten (partition 2 3 (range 1 9))) |
| 19:50 | clojurebot | (1 2 4 5 7 ...) |
| 19:50 | justin_smith | ~flatten |
| 19:50 | clojurebot | flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with. |
| 19:50 | Seylerius | Heh. |
| 19:50 | Seylerius | Okay. |
| 19:50 | Seylerius | Point made. |
| 19:50 | TEttinger | ,(apply concat (partition 2 3 (range 1 9))) |
| 19:50 | clojurebot | (1 2 4 5 7 ...) |
| 19:53 | Seylerius | ,(apply concat (partition 1 2 (range 1 9))) |
| 19:53 | clojurebot | (1 3 5 7) |
| 19:55 | hyPiRion | ,(defn aside [& fs] (fn [xs] (map #(%1 %2) fs xs))) |
| 19:55 | clojurebot | #'sandbox/aside |
| 19:55 | hyPiRion | ,(defn dropper* [coll n] (if (seq coll) (->> (split-at n coll) ((aside butlast #(dropper* % n))) (apply concat)))) |
| 19:55 | clojurebot | #'sandbox/dropper* |
| 19:55 | hyPiRion | ,(dropper* (range 1 9) 3) |
| 19:55 | clojurebot | (1 2 4 5 7) |
| 19:56 | hyPiRion | oh, it drops a bit eagerly I guess |
| 20:02 | danlentz | thats what she said |
| 20:05 | danlentz | pretty interesting the different ways to approach dropper |
| 20:11 | danlentz | im not sure where dropper comes from (is this a well known exercise?) but another interesting example of using reductions to manage state is Evan Gamble’s index-except exercise https://gist.github.com/egamble/7685276 |
| 21:06 | Seylerius | danlentz: It's problem #41 on 4clojure |
| 21:08 | Seylerius | ,(defn dropper [coll n] (apply concat (partition (dec n) n coll))) |
| 21:08 | clojurebot | #'sandbox/dropper |
| 21:09 | Seylerius | ,(dropper [:a :b :c :d :e :f] 2) |
| 21:09 | clojurebot | (:a :c :e) |
| 21:09 | Seylerius | (= (dropper [:a :b :c :d :e :f] 2) [:a :c :e]) |
| 21:09 | Seylerius | ,(= (dropper [:a :b :c :d :e :f] 2) [:a :c :e]) |
| 21:09 | clojurebot | true |
| 21:09 | Seylerius | ... |
| 21:09 | Seylerius | 4clojure is saying I'm failing that unit test. |
| 21:10 | Seylerius | ,(= (dropper [1 2 3 4 5 6] 4) [1 2 3 5 6]) |
| 21:10 | clojurebot | false |
| 21:11 | Seylerius | ,(dropper [1 2 3 4 5 6] 4) |
| 21:11 | clojurebot | (1 2 3) |
| 21:11 | Seylerius | Okay, that's legit. |
| 21:20 | jpavlick | hi guys |
| 21:21 | jpavlick | I'm trying to get a clojure hello world running and I'm performing poorly. |
| 21:21 | jpavlick | ~> lein run -m core.demo Can't find 'core.demo' as .class or .clj for lein run: please check the spelling. |
| 21:21 | clojurebot | Excuse me? |
| 21:23 | TEttinger | jpavlick: hm, did you start the project with lein new ? |
| 21:24 | TEttinger | I'm wondering if something was created and manually renamed |
| 21:26 | joe1245 | can someone explain how this is valid code? http://pastebin.com/z8WtmYsh i thought the syntax was (myfunc [args] (body)) |
| 21:29 | TEttinger | joe1245: those are different parameter lists for the same fn name |
| 21:30 | TEttinger | it's how something like + can be (+ 1 2) or (+ 1 2 3 4 5) |
| 21:30 | joe1245 | ok t hanks |
| 21:31 | TEttinger | so you could call that fn with one or two args |
| 21:31 | joe1245 | also when i try to call it by (sum 3) it doesn't work I have to use (sum [3]) can you explain |
| 21:32 | TEttinger | it expects a sequence for vals, it calls empty? on it to test if it has items in it, which only works for some form of sequence |
| 21:32 | TEttinger | so [3] works because it can be treated as a seq |
| 21:32 | TEttinger | you could also use a set if you wanted, like #{3} |
| 21:33 | TEttinger | also, vals is a poor choice for a parameter name, since it's already a fn in the standard lib |
| 21:33 | TEttinger | (doc vals) |
| 21:33 | clojurebot | "([map]); Returns a sequence of the map's values, in the same order as (seq map)." |
| 21:33 | joe1245 | cool thank you |
| 21:33 | joe1245 | btw how did you learn clojure |
| 21:34 | TEttinger | uh, mostly tinkering on lazybot plugins, which is not the best way to do it |
| 21:34 | TEttinger | but brave clojure is excellent these days |
| 21:34 | tahmid | I would recommend brave clojure |
| 21:34 | joe1245 | cool i'm doing that now |
| 21:35 | TEttinger | it does seem like brave clojure has good pacing and gets to important parts of clojure early on |
| 21:35 | tahmid | I like the vibe of it |
| 21:35 | TEttinger | I've linked it to some people, and a few days later they're asking questions that I wouldn't have been close to when I started |
| 21:36 | joe1245 | after i finish brave clojure what kind of project is clojure good at? |
| 21:36 | joe1245 | i want to show something interactive to put on my website for example |
| 21:37 | tahmid | You can do that with quil |
| 21:39 | TEttinger | clojure (that's clojure on the JVM I mean) is especially good at server-side stuff, but clojurescript has some really amazing stuff that can be done on the client side with libs like Om |
| 21:39 | joe1245 | awesome looks like just what i wanted |
| 21:39 | joe1245 | quil and stuff |
| 21:40 | TEttinger | I've used play-clj before, which is also cool but doesn't do things in webpages |
| 21:41 | joe1245 | yah i want to do webpage stuff because really who wants to download fungame.exe |
| 21:47 | tahmid | ‘(+ 2 3) |
| 21:48 | tahmid | ,(+ 2 3) |
| 21:48 | clojurebot | 5 |
| 21:53 | tahmid | ,(comp filter odd?) |
| 21:53 | clojurebot | #object[clojure.core$comp$fn__4446 "clojure.core$comp$fn__4446@3017a4f3"] |
| 21:53 | tahmid | (transduce (comp (filter odd?) (map inc))) |
| 21:53 | TEttinger | ,(transduce (comp (filter odd?) (map inc))) |
| 21:53 | clojurebot | #error{:cause "Wrong number of args (1) passed to: core/transduce", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (1) passed to: core/transduce", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 32] [sandbox$eval73 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.j... |
| 21:54 | tahmid | ,(println clojure-version) |
| 21:54 | clojurebot | #object[clojure.core$clojure_version clojure.core$clojure_version@32315315]\n |
| 21:54 | TEttinger | ,(transduce (comp (filter odd?) (map inc)) (range 10)) |
| 21:54 | clojurebot | #error{:cause "Wrong number of args (2) passed to: core/transduce", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (2) passed to: core/transduce", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 36] [sandbox$eval121 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.... |
| 21:54 | TEttinger | ,clojure-version |
| 21:54 | clojurebot | #object[clojure.core$clojure_version "clojure.core$clojure_version@32315315"] |
| 21:54 | TEttinger | hm |
| 21:54 | TEttinger | that's not good |
| 21:55 | tahmid | it’s 1.7+ right ? |
| 21:56 | vas | can someone explain to me the use of [[ double brackets ]] in anonymous fxns? |
| 21:56 | TEttinger | vas: it's used for destructuring |
| 21:57 | TEttinger | giving names to elements in a collection, as opposed to naming the collection itself |
| 21:57 | vas | you just blew my mind |
| 21:59 | TEttinger | ,((fn [start [internal insides within]] (+ start internal insides within)) 10 [1 2 3]) |
| 21:59 | clojurebot | 16 |
| 21:59 | TEttinger | it gets better! |
| 21:59 | TEttinger | ,((fn [start [internal insides within]] (+ start internal insides within)) 10 [1 2 3 4 5 6 7 8 9]) |
| 21:59 | clojurebot | 16 |
| 22:00 | TEttinger | it only looks at the names that are assigned in the destructuring, so if you have more it discards them (but you can name the whole of that [1 2 3 4 5 6 7 8 9] with :as) |
| 22:00 | vas | Aha! |
| 22:01 | TEttinger | ,((fn [start [internal insides within :as somelonglist]] (+ start internal insides within (apply + somelonglist))) 10 [1 2 3 4 5 6 7 8 9]) |
| 22:01 | clojurebot | 61 |
| 22:03 | TEttinger | using destructuring is one of the main ways that clojure code can be made smaller and cleaner, especially code that deals with nested collections |
| 22:04 | TEttinger | (the biggest way is knowing as much of the standard lib as possible) |
| 22:05 | TEttinger | mapcat is crazy cool |
| 22:05 | gfredericks | ~mapcat is crazy cool |
| 22:05 | clojurebot | Ok. |
| 22:06 | vas | I think I'm gonna print out core.clj and wallpaper my room with source code |
| 22:06 | raspasov | vas: haha |
| 22:07 | TEttinger | imagine if you did that for the java standard lib |
| 22:07 | TEttinger | "We're gonna need a bigger room!" |
| 22:07 | raspasov | TEttinger: hahaha |
| 22:07 | vas | Hahaha at that point i might just rather know the bytecode by heart |
| 22:08 | TEttinger | hm, let's see what the largest files are in the openjdk source... |
| 22:09 | raspasov | TEttinger: what if you did it for Scala? oh boy, you'll have to re-wallpaper your room every year and a half! |
| 22:09 | TEttinger | haha |
| 22:10 | vas | if i find the right artist and micropen i think i can get core.clj tattooed on my body |
| 22:13 | vas | thanks for the examples on maps, TEttinger |
| 22:13 | vas | er, [[ double bracks ]] |
| 22:14 | TEttinger | no problem! |
| 22:23 | TEttinger | one of the largest files in the JDK Is FilterGeneric.java , it's 4500 lines, most of them longer than 80 chars, with stuff like |
| 22:23 | TEttinger | return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15], av[16], av[17], av[18], av[19]); } |
| 22:24 | TEttinger | my god, there's a shell script in that java source |
| 22:24 | TEttinger | : SHELL; n=FilterGeneric; cp -p $n.java $n.java-; sed < $n.java- > $n.java+ -e '/{{*{{/,/}}*}}/w /tmp/genclasses.java' -e '/}}*}}/q'; (cd /tmp; javac -d . genclasses.java; java -ea -cp . genclasses | sed 's| *[/]/ *$||') >> $n.java+; echo '}' >> $n.java+; mv $n.java+ $n.java; mv $n.java- $n.java~ |