#clojure log - Sep 29 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

1:35 akkad: https://gist.github.com/9ef5804b239f0c3c94b9 => Parameter declaration "loop" should be a vector

2:50 et voila. missing [] before loop.

3:10 amalloy: a classic error message that's unusually bad even for clojure

3:17 akkad: man this recursion with loop/recur has me stumped

3:18 I'm looping but the new value passed to recur does not seem to update within the loop

3:23 aja

3:24 loke: (this is Clojurescript, but I don't think it matters to the case in hand) I have a sorted-map containing a few hundred (maybe up to a few thousand) elements keyed by string, and I have the key of a specific element. I now want to remove all elements with a key less than this specific element. What's the most efficient way to do this? (i.e. assuming keys a,b,c,d,e,f and marker d, I want to throw away a,b,c and keep keys d,e,f.

3:29 hyPiRion: loke: subseq

3:30 ,(let [s (apply sorted-set (range 10))] (subseq s >= 5))

3:30 clojurebot: (5 6 7 8 9)

3:30 * akkad can't read LazySeq outloud at the office...

3:31 loke: hyPiRion: Woah. Thanks!

3:51 siefca: hi guys. is arity overloading in Clojure handled at compile-time or at runtim[Ce?

3:53 i'm trying to find examples of static polymorphism in Clojure (if there are any, without core.typed)

4:18 amalloy: siefca: both, i guess. the compiler sees (f x y z) and emits the bytecode equivalent of f.invoke(x, y, z). at runtime the jvm dispatches that on f

5:02 dzhus`: I can apply a list of functions to a single value and collect the results via (map #(% arg) (list f1 f2 .. fn)). Is there a more concise way to do it?

5:02 hyPiRion: oh, this is the best use case for juxt

5:03 ,((juxt inc dec #(+ 10 %)) 10)

5:03 clojurebot: [11 9 20]

5:03 dzhus: noice

5:07 Is there a shortcut for (some identity)\

5:08 ?

5:09 muhuk_: dzhus: nil?

5:09 dzhus: some?

5:10 no, neither actually

6:19 Guest62166: is there a shothand for this .. (let [foo (fun)] (blah-bleh-blah foo) (raaaa foo) foo)

6:19 like .. for the java objects

6:20 oddcully: ,(doc doto)

6:20 clojurebot: "([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"

6:20 Guest62166: ah!

6:21 oddcully: ,(doto (java.util.HashMap.) (.put 1 2) (.put 2 3))

6:21 clojurebot: {1 2, 2 3}

6:21 Guest62166: hurmm but that would require x to be always passed in second place

6:22 oddcully: then maybe as-> ?

6:22 Guest62166: which is like 90% of cases

6:22 but as-> does not return the original

6:22 luma: oddcully, that doesn't return the original

6:22 Guest62166: what luma said

6:24 a macro like (ret [x (foo)] ....) in core would be nice

6:29 luma: ,(defmacro returning [binding & body] (let [[sym expr] binding] `(let [~sym ~expr] ~@body ~sym)))

6:29 clojurebot: #'sandbox/returning

6:30 luma: ,(returning [x 1] (println "x is" x))

6:30 clojurebot: x is 1\n1

6:31 Guest62166: +1 luma

6:31 should be in the core

6:44 sveri: Hi there, quick survey core.typed / schema or annotate?

6:45 Guest62166: ,(inc 1) (inc 2)

6:45 clojurebot: 2

6:45 Guest62166: new nrepl seems to eval every expression

6:45 on my machine

6:46 sveri: prismatic schema?

6:47 sveri: Guest62166: yea, exactly

6:47 Guest62166: i have used it on a large project in my company for enforcing types and structure

6:47 its easy to code

6:47 and has very low cpu footprint

6:48 dont know about core.typed

6:49 prismatic schema can let you enforce data shape too, which would otherwise be a little unsusual for a type checker imo

6:50 nowprovision: there was an article recently on reddit about cicrlceci dropping core.typed http://blog.circleci.com/why-were-no-longer-using-core-typed/ my initial experiements with schema for coercing and enforcing api schemas has been very pleasant

6:50 Guest62166: yes its really 10/10 project for me too

6:51 and the s/pred makes it possible to put weird assertions in type checking itself

6:52 if thats your thing

6:52 although i have not used schema to anotate functions, there seems to be support for it using s/fn i guess

6:52 would like to check it out sometime

8:27 roelof: Hello, I have a challenge where I have to change {:title "The Little Schemer" :authors [friedman, felleisen]}) to this {:title "The Little Schemer" :authors #{friedman, felleisen}}

8:27 I thought this would work : (assoc book :authors (set :authors))) but then I see this error message : java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

8:28 how to solve this ?

8:28 mavbozo: update-in ?

8:29 opqdonut: roelof: (set (:authors book))

8:29 roelof: or (set (book :authors))

8:29 roelof: or update-in for a fancier solution

8:30 roelof: the course did not mentioned update_in at this moment

8:30 snowell: Yeah, so if you can't use update-in, go with what opqdonut said

8:31 (set :authors) is trying to make a set out of the keyword :authors

8:31 (set (:authors book)) will use the value from the map

8:33 roelof: thanks, I hope I once get used to the syntax of clojure

8:37 now im getting more difficult challenges Im a lot lost in the syntax :(

8:42 mavbozo: roelof, what course do you follow?

8:43 roelof: mavbozo: this one ; http://iloveponies.github.io/

8:55 noncom: roelof: you won't be lost. there is almost no syntax. all that is written is usually obvious

8:56 roelof: when you wanted (assoc book :authors (set :authors))) to work - you had a wrong assumption that (set :authors) must somehow know about book, but it does not

8:56 roelof: noncom: for me not. in the last 10 exercises I make a lot of syntax errors

8:57 noncom: you can first try arranging things in a (let [..]) where you step-by step write every point, maybe that'd be more clear

8:58 roelof: don't worry, you are on the way to clarity :)

9:00 roelof: noncom: so using a helper which convert the authors to a set and using that in the function

9:01 noncom: so also better look at the parameters of a function

9:01 noncom: roelof: yes. it's just simple steps. which later can be put one into another.

9:02 every step has no implicit things, all is specified obviously (except for sometime with macros, but that's advanced)

9:02 roelof: thanks,

9:04 now time for a very late lunch ( 15:00 hour) here :(

9:28 oddcully: is there some shorthand to pick a few selected keys from a map with specter/select? i tried a set, but that won't cut it

9:48 snowell: ,(doc select-keys)

9:48 clojurebot: "([map keyseq]); Returns a map containing only those entries in map whose key is in keys"

9:50 snowell: ,(select-keys [:a :c] {:a 1 :b 2 :c 3 :d 4}); oddcully: like this?

9:50 clojurebot: {}

9:50 snowell: ,(select-keys {:a 1 :b 2 :c 3 :d 4} [:a :c]); OK I meant this?

9:50 clojurebot: {:a 1, :c 3}

9:52 oddcully: snowell: yes like this. or the pull syntax, if you know datascript

10:13 crocket: Why do I not have direct access to protocols like ISeq in clojure?

10:13 ClojureScript exposes ISeq.

10:15 justin_smith: ,clojure.lang.ISeq

10:15 clojurebot: clojure.lang.ISeq

10:15 crocket: ,(doc ISeq)

10:15 clojurebot: I don't understand.

10:15 justin_smith: crocket: ^ as exposed as it could be

10:15 crocket: it can't have doc because it's not a var

10:16 it's a class

10:16 crocket: ClojureScript even has a documentation for ISeq.

10:16 ,(doc ISeq)

10:16 clojurebot: Cool story bro.

10:16 justin_smith: crocket: because in clojurescript they don't have vars

10:16 so doc is completely different

10:16 crocket: Where do I get documentation for clojure.algn.ISeq?

10:16 justin_smith: crocket: also, it's not just ISeq unless you import it

10:16 it's clojure.lang.ISeq, clojure.lang is not auto-imported

10:18 crocket: I can't find javadoc

10:18 justin_smith: crocket: there's a download for the javadoc here http://mavensearch.io/repo/org.clojure/clojure/1.7.0

10:19 crocket: Is there a web version of clojure javadoc?

10:20 justin_smith: not sure... it's odd that its so hard to find

10:20 crocket: https://clojure.github.io/clojure/javadoc/ is faulty

10:20 justin_smith: there's definitely an html page for ISeq in that javadoc jar

10:22 crocket: Shame

10:22 justin_smith: but all there is to say is it has methods cons, first, more, and next. first returns Object, the others return ISeq

10:22 oh, and cons takes an arg

10:23 (of type Object)

10:26 fuuduCoder: any data scientists here ?

10:26 what has been your general experience with incanter

10:29 crocket: fuuduCoder, I heard clojure is going to beat python on exploratory data science(e.g., exploring new machine learning algorithms).

10:30 fuuduCoder: I hope so. fingers crossed. :-)

10:31 crocket: fuuduCoder, I recommend "Akhil Wali-Clojure for Machine Learning-Packt Publishing - ebooks Account (2014)"

10:53 m1dnight_: How do I expand a macro in CIDER/emacs? I have a macro in my source code, I select the line and then evel "cider-macroexpand-1" but then I get a timeout error?

10:54 or do I have to copy/paste it into the nrepl window first?

10:55 ah nvm, I made a booboo.

11:11 visof: hi guys

11:11 can i do (case (type x) ??

11:12 justin_smith: visof: sure, but often a multimethod is a better way to handle that

11:12 m1dnight_: https://clojuredocs.org/clojure.core/instance_q, like this?

11:13 visof: justin_smith: it's not multimethod, it's generic method which should work on different types

11:13 justin_smith: visof: how's that different from a multimethod?

11:14 visof: justin_smith: i have 2 records Foo and Bar and want to make method XXX which work on 2 with one argument, how can i do this?

11:14 justin_smith: visof: multimethod!

11:14 ,(defrecord Foo [])

11:14 clojurebot: sandbox.Foo

11:14 justin_smith: ,(defrecord Bar [])

11:14 clojurebot: sandbox.Bar

11:14 justin_smith: ,(defmulti mult class)

11:14 clojurebot: #'sandbox/mult

11:15 m1dnight_: https://blog.8thlight.com/myles-megyesi/2012/04/26/polymorphism-in-clojure.html

11:15 justin_smith: ,(defmethod mult Bar [n] "a bar")

11:15 m1dnight_: This is a good example as well.

11:15 clojurebot: #object[clojure.lang.MultiFn 0x55daea5a "clojure.lang.MultiFn@55daea5a"]

11:15 m1dnight_: (sorry for the combobreaker there)

11:15 justin_smith: ,(defmethod mult Foo [n] "a foo")

11:15 clojurebot: #object[clojure.lang.MultiFn 0x55daea5a "clojure.lang.MultiFn@55daea5a"]

11:15 visof: justin_smith: thanks it will do

11:15 fehrenbach: visof: have you considered a protocol?

11:15 justin_smith: ,(mult (Foo.))

11:15 clojurebot: "a foo"

11:15 visof: fehrenbach: nope

11:16 fehrenbach: visof: if you only need to dispatch on the type of a single argument, and both are records, a protocol might be a better fit than multimethods

11:17 visof: fehrenbach: why it's better?

11:18 dzhus`: (jdbc/query db-spec ["SELECT bar FROM foo;"]) gives me 'IllegalArgumentException Don't know how to create ISeq from: clojure.java.jdbc$query$fn__1145 clojure.lang.RT.seqFrom (RT.java:528)', any ideas what may be wrong?

11:19 fehrenbach: visof: it's simpler, conveys what exactly is happening (type-based single dispatch) as opposed to multimethods which can do more or less anything, and it's faster (unlikely to be a pressing concern, but still)

11:20 justin_smith: dzhus`: what is db-spec ? maybe you provided a function there instead of the usual hash-map?

11:20 dzhus`: also, it would be good to see a paste of the whole stack trace, if you can share it on refheap.com

11:21 dzhus`: justin_smith: a map with :classname and stuff for connecting to DB. The same db-spec works in a different query

11:24 https://www.refheap.com/110076

11:27 justin_smith: dzhus`: weird, why would jdbc try to call seq on an anonymous function that it defined?

11:27 because from that stack trace and your error, this is clearly what is happening

11:28 inside set-parameters...

11:29 Bronsa: dzhus`: which version of clojure are you using?

11:31 dzhus`: Java 1.8.0_60, Clojure 1.7.0, nREPL 0.2.1

11:32 Bronsa: can you try with 1.6 and see if the error message changes?

11:32 justin_smith: Bronsa: oh, could this be a transducer arity thing?

11:32 Bronsa: probably not but worth a try

11:33 dzhus`: maybe I'll try

11:37 m1dnight_: Is there a way to get the module name in clojure only? So if I have a namespace "clojbot.modules.foo" I want the foo part.

11:37 or do I have to play with string ops?

11:37 Bronsa: ,*ns*

11:37 clojurebot: #object[clojure.lang.Namespace 0x7af2ec7c "sandbox"]

11:37 m1dnight_: Yes, that yields the entire namespace.

11:37 Bronsa: ,(name (ns-name *ns*))

11:37 clojurebot: "sandbox"

11:38 m1dnight_: oh

11:38 Bronsa: ,(name (ns-name (the-ns 'clojure.core)))

11:38 clojurebot: "clojure.core"

11:38 m1dnight_: (name (ns-name *ns*)) --> "clojbot.modules.karma"

11:38 I think I only want the last part.

11:38 hmm maybe the entire part will do as well.

11:39 Bronsa: m1dnight_: there's nothing in clojure built-in for that since the last ns segment isn't really any more meaningful than the rest of the namespace name

11:41 m1dnight_: Idd, but I want to use it to automatically build databasetables and such.

11:41 Ill just parse itmyself.

11:44 TEttinger: ,(re-find #"\.[\w-]+$" (name (ns-name (the-ns 'clojure.core))))

11:44 clojurebot: ".core"

11:44 TEttinger: ,(re-find #"[\w-]+$" (name (ns-name (the-ns 'clojure.core))))

11:44 clojurebot: "core"

11:44 TEttinger: hm, could you start an ns with any char?

11:44 m1dnight_: ,(re-find #"[\w-]+$" (name (ns-name (the-ns 'clojure.core.foo.bar))))

11:44 clojurebot: #error {\n :cause "No namespace: clojure.core.foo.bar found"\n :via\n [{:type java.lang.Exception\n :message "No namespace: clojure.core.foo.bar found"\n :at [clojure.core$the_ns invokeStatic "core.clj" 4011]}]\n :trace\n [[clojure.core$the_ns invokeStatic "core.clj" 4011]\n [clojure.core$the_ns invoke "core.clj" -1]\n [sandbox$eval143 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval143 inv...

11:45 TEttinger: it's trying to resolve with the-ns

11:45 m1dnight_: ,(re-find #".*\.[\w]+$" (name (ns-name (the-ns 'clojure.core.foo.bar))))

11:45 clojurebot: #error {\n :cause "No namespace: clojure.core.foo.bar found"\n :via\n [{:type java.lang.Exception\n :message "No namespace: clojure.core.foo.bar found"\n :at [clojure.core$the_ns invokeStatic "core.clj" 4011]}]\n :trace\n [[clojure.core$the_ns invokeStatic "core.clj" 4011]\n [clojure.core$the_ns invoke "core.clj" -1]\n [sandbox$eval167 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval167 inv...

11:45 m1dnight_: oh

11:45 ill just try on my own repl

11:46 TEttinger: ,(in-ns 'clojure.core.foo.bar (re-find #"[\w-]+$" (name (ns-name *ns*))))

11:46 clojurebot: #error {\n :cause "Wrong number of args (2) passed to: "\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: "\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [sandbox$eval191 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval191 invoke "NO_SOURCE_...

11:47 TEttinger: (doc in-ns)

11:47 clojurebot: "([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."

11:47 TEttinger: ,(in-ns clojure.core.foo.bar (re-find #"[\w-]+$" (name (ns-name *ns*))))

11:47 clojurebot: #error {\n :cause "clojure.core.foo.bar"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.core.foo.bar, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.core.foo.bar"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java...

11:47 TEttinger: oh

11:47 herp

11:48 ,(do (in-ns 'clojure.core.foo.bar) (re-find #"[\w-]+$" (name (ns-name *ns*)))))

11:48 clojurebot: #error {\n :cause "Unable to resolve symbol: re-find in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: re-find in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: re-find i...

11:48 TEttinger: haha

11:48 justin_smith: TEttinger: yeah, in-ns doesn't do (clojure.core/refer-clojure) automatically

11:48 TEttinger: ,(do (in-ns 'clojure.core.foo.bar) (require 'clojure.core) (re-find #"[\w-]+$" (name (ns-name *ns*)))))

11:48 clojurebot: #error {\n :cause "Unable to resolve symbol: require in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: require in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: require i...

11:48 TEttinger: ,(do (in-ns 'clojure.core.foo.bar) (clojure.core/require 'clojure.core) (re-find #"[\w-]+$" (name (ns-name *ns*)))))

11:48 clojurebot: #error {\n :cause "Unable to resolve symbol: re-find in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: re-find in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: re-find i...

11:48 justin_smith: TEttinger: (clojure.core/refer-clojure)

11:48 TEttinger: ,(do (in-ns 'clojure.core.foo.bar) (clojure.core/refer-clojure) (re-find #"[\w-]+$" (name (ns-name *ns*)))))

11:48 clojurebot: "bar"

11:49 TEttinger: yay

11:49 (inc justin_smith)

11:49 justin_smith: TEttinger: it's a good one to remember when you make a typo when using in-ns - sometimes easier than stopping and restarting the repl (which is another option, heh)

11:50 TEttinger: indeed

11:53 m1dnight_: ah cool :D thanks guys

11:53 Bronsa: or you can just in-ns to a real ns back

11:53 justin_smith: $ git commit -m 'FUCKING SCALA I TELL YOU WAT'

11:53 Bronsa: in-ns is automagically resolved to c.c/in-ns

11:53 justin_smith: Bronsa: as in clojure.core/in-ns of course

11:53 Bronsa: nop

11:53 justin_smith: Bronsa: oh, wow

11:54 Bronsa: justin_smith: you can't shadow in-ns as a matter of fact

11:54 justin_smith: fascinating

11:54 Bronsa: http://dev.clojure.org/jira/browse/CLJ-1582

11:54 bja: justin_smith: I typically just use clojure.core/in-ns to get to the correct namespace rather than a full refer-clojure. I didn't actually realize refer-clojure existed though. That's handy

11:55 TEttinger: justin_smith: you dealing with some o' dis? http://nurkiewicz.github.io/talks/2014/scalar/img/list-scala.png

11:57 xemdetia: wow

11:57 'start here' in bottom right? I hope that graph is auto generated :(

11:57 expez: what is the predicate to see if something responds favorably to (seq <thing>)?

11:57 justin_smith: TEttinger: kafka configs, the options are a hash map, if my numeric config was provided as a number it would silently hang, changing it to a string fixed it :????:

11:57 Bronsa: expez: there's a sequable? predicate in core.incubator

11:57 snowell: expez: seq?

11:58 Bronsa: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L83

11:58 expez: snowell: nop

11:58 Bronsa: seqable*

11:58 justin_smith: ,(seq? (list 1 2 3))

11:58 clojurebot: true

11:58 TEttinger: xemdetia: I think they made it in Fortran

11:58 justin_smith: ,(seq? [1 2 3])

11:58 clojurebot: false

11:58 justin_smith: (= (list 1 2 3) [1 2 3])

11:59 TEttinger: ,(= (list 1 2 3) [1 2 3])

11:59 clojurebot: true

11:59 Bronsa: I don't think I've ever used the fact that lists compare with vectos

11:59 TEttinger: ,(= (list 1 2 3) [1 2 3] (ArrayList. [1 2 3]))

11:59 clojurebot: #error {\n :cause "Unable to resolve classname: ArrayList"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Unable to resolve classname: ArrayList, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "Unable to resolve classname: ArrayList...

11:59 TEttinger: ,(= (list 1 2 3) [1 2 3] (java.util.ArrayList. [1 2 3]))

11:59 clojurebot: true

12:00 TEttinger: interesting!

12:00 ,(= (list 1 2 3) [1 2 3] (java.util.Deque. [1 2 3]))

12:00 clojurebot: #error {\n :cause "No matching ctor found for interface java.util.Deque"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: No matching ctor found for interface java.util.Deque, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "No matchin...

12:00 expez: heh why are vectors and lists =?

12:00 justin_smith: expez: for convenience of course

12:00 TEttinger: ,(= (list 1 2 3) [1 2 3] (java.util.LinkedList. [1 2 3]))

12:00 clojurebot: true

12:01 TEttinger: ,(= (list 1 2 3) [1 2 3] (java.util.ArrayDeque. [1 2 3]))

12:01 clojurebot: false

12:01 TEttinger: aha!

12:01 only for List interface it seems, not Queue

12:03 mungojelly: expez: have you read the classic "EGAL" paper? because i think that gives a good sense of clojure's attitude towards equality

12:04 expez: mungojelly: you probably misunderstood that paper if you're using it as an argument in favor of this behavior

12:04 mungojelly: expez: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999 Equal Rights for Functional Objects or, The More Things Change, The More They Are the Same (1993) by Henry Baker

12:05 expez: mungojelly: Along the same vein is equality betwene a set and a list if they contain the same values. Do you think that makes sense too?

12:05 mungojelly: meh it's not that clojure exactly implements the ideas of the paper, some of them are old fashioned, it's that it informs this whole aesthetic of equality

12:07 i think it makes a lot of sense to have an idea of equality that compares something more abstract than references, because if you compare reference equality it's finicky and unintuitive. but then you have to construct an equality abstraction, which has lots of details. it's easier to just say, if the bits of what you're pointing right to are the same they're equal, but you're just pointing at reference

12:08 s and so that really means little.

12:10 lists and vectors are equal because they're thingies, and you can look at them and say, is the first thing equal? is the second thing equal? all of them all the way to the end and they're the same length? ok good equal enough. the fact that they're not the "same" container type is abstracted out of the equality along with the specificity of which memory reference the containers are in.

12:14 justin_smith: mungojelly: it's funny though that (!= 1 1.0) but (= (list 1 2 3) [1 2 3]) - amusing combination of choices

12:16 mungojelly: it's a mildly unfortunate choice in computing that .0 is generally how we say "i want this number to be a float and remain so in interaction with other things" but i guess you can't get people to say the whole word "float" or anything instead of .0 because .0 is so easy .0.0.0.0.0.0.0

12:17 but then you go look at a failing program and eventually you find that what's missing is a .0 somewhere and then it doesn't seem so convenient anymore

12:22 m1dnight_: When is the namesapce set to "user"? I have a leiningen project which seems to resolve *ns* to user at runtime..

12:23 justin_smith: m1dnight_: it's the clojure default, any other runtime ns is caused by some tooling

12:23 m1dnight_: ah okay

12:23 justin_smith: so eg. lein run, all code should be in ns user at runtime

12:23 m1dnight_: hmm, that makes it more difficult.

12:23 okay thanks justin_smith

12:23 could I create nasty sideeffects if I do a (in-ns) before?

12:24 justin_smith: m1dnight_: hmm... what are you using runtime ns for anyway?

12:25 m1dnight_: I have a clojure irc bot and I load modules at runtime. And now Im creating a macro that says "I will store entities like this in some database" and that macro should expand to a create-table call. To make sure that each module in the bot uses a unique table I want to prepend the namespace to it in the macro.

12:26 https://www.refheap.com/110085

12:26 something like that

12:26 The big picture is a DSL for the writer of modules to be abstract of the way the bot stores stuff. The write rof modules just has to say "store this"

12:27 justin_smith: m1dnight_: ok, but the *ns* call there ends up pointing to user?

12:27 m1dnight_: yep

12:28 aha!

12:28 I can expand the *ns* variable at compile time

12:28 that works!

12:30 oh wait, it doesn't

12:32 yes it does. had to do a clean first :)

12:44 akkad: hmm something rich forgot to copy from CL

12:50 oymyakon: I have a problem with vim fireplace and lein repl, I am getting this error whenever I try to eval a form from vim Ljava.lang.StackTraceElement has no field or method named cljs$lang$protocol_mask$partition0$

12:51 rasmusto: oymyakon: do you have cider/cider-nrepl in your ~/.lein/profiles.clj ?

12:52 oymyakon: rasmusto: I have not installed cider as I thought it was only for emacs

12:52 should I install it?

12:53 rasmusto: oymyakon: newer versions of fireplace use cider iirc

12:53 (or they fall back to using vimscript)

12:53 oymyakon: oh, Ok then I will install it and try again. Thank you

12:59 noncom: when i can chose to use either reduce or mapv, what is betteR?

12:59 akkad: rasmusto: in dependencies?

12:59 rasmusto: akkad: in plugins

13:01 akkad: thanks

13:02 mungojelly: should lein-midje be in the project.clj for a project that uses midje? or just in my own profiles.clj?

13:02 justin_smith: akkad: wait, which thing did rich "forget" to copy from CL? most features CL has that clojure doesn't were intentionally left out / intentionally done differently

13:03 akkad: justin_smith: all of the attitude :P

13:14 rasmusto: hey kid, lose the spoon!

13:30 akkad: hmm

13:30 (flatten foo) => OutOfMemoryError Java heap space java.util.Arrays.copyOf (Arrays.java:2882)

13:36 justin_smith: flatten is terrible anyway

13:37 perhaps you tried to flatten a recursive or infinite or indefinite structure?

13:37 akkad: nope. a seq of 100 seqs each containing 1000 elements

13:37 s3 bucket file list

13:38 rasmusto: increase your heap size (or use concat maybe?)

13:38 if you know how deep you have to traverse

13:39 akkad: max/min can be set dynamic right/

13:39 ?

13:39 typically I recurse fine in cl with this same structure/dataset (defun flatten (x) (if (consp x) (flatten (car x)) x))

13:40 justin_smith: akkad: clojure's flatten is shitty

13:40 also why would you only care about the car of x?

13:41 I mean you throw away the cdr there

13:43 akkad: hmm I've not lost data with it

13:43 justin_smith: what that code literally says, is if x is a cons, flatten it's car and ignore the cdr

13:43 *its

13:45 akkad: yeap

13:45 justin_smith: ignore as in discard, not as in pass along unchanged

13:45 akkad: yes, understood

13:46 will just loop/recur then thanks

13:49 justin_smith: on this structure I get the same results if I run a (defun flatten (structure) (cond ((null structure) nil) ((atom structure) (list structure)) (t (mapcan #'flatten structure))))

13:50 anyway thanks, I'll avoid the flatten and just collect it myself

13:54 justin_smith: if the seq is as you described above, seq of seqs, just use (apply concat sos) and that will give you a lazy seq of the items that you can process on the fly or treat as a flat structure or whatever

13:54 ,(apply concat [[1 2 3] [4] [] [5]])

13:54 clojurebot: (1 2 3 4 5)

13:55 TMA: why is clojure's flatten so bad? is it something like (def flatten (comp (partial reduce concat) (partial map flatten)))? [with all the difficulties of optimizing that away into a neat loop]

13:55 justin_smith: ,(flatten "hello")

13:55 clojurebot: ()

13:55 justin_smith: (source flatten)

13:56 (filter (complement sequential?) (rest (tree-seq seqential? seq x)))

14:01 akkad: nice command, source

14:06 curtosis: hello all

14:08 I asked this over on slack, but am still stuck... wondering if anyone has tips for debugging why uberwar is (newly, for this project) throwing an exception on creating an XmlOutputFactory (Provider com.ctc.wstx.stax.WstxOutputFactory not found)

14:09 it's happening when uberwar tries to create the web.xml

14:10 and I can't for the life of me figure out what I could possibly have modified that would have broken that... everything works fine from the repl.

14:10 xeqi: com.ctc.wstx.stax.WstxOutputFactory is a strange class. and different then what you pasted in slack

14:11 or, maybe you just didn't paste that line

14:11 curtosis: yeah, I didn't copy the detail over.

14:12 I thought the entire stack trace was not likely to be particularly enlightening.

14:14 it got me as far as leiningen.ring.war/make-web-xml, but this is all so deep in the plumbing I can't see a linkage to anything I control at the project level.

14:15 much less anything I've changed in the last 2 hours.

14:17 justin_smith: curtosis: have you changed deps recently and not run lein clean since?

14:17 oddcully: curtosis: newly as in it worked before?

14:18 curtosis: if in doubt bisect your changes (and clean in between as justin_smith said)

14:18 curtosis: @justin_smith: nope. I mean, yes, I have changed deps, but have run lein clean several times since.

14:19 * akkad goes begging for folks lein/jvm-opts

14:19 curtosis: @oddcully: yeah, it worked this morning. And, of course, I don't have a clean way to bisect the changes.

14:19 but I've tried individually commenting out or removing most of the changes, with no difference.

14:21 (they're all really small... added a :profile to project.clj, and added a couple of functions to my routes)

14:21 xeqi: curtosis: did you change java versions recently? https://github.com/clojure/data.xml/blob/jdk16-pull-parser/jdk_15_readme.txt

14:21 curtosis: xeqi: nope. I've been building with 1.8 for months. I even tried switching to 1.7 to see if that fixed it, to no avail.

14:22 I've started from a new shell session, too.

14:23 My next step is probably rebooting, just for the sake of completeness.

14:24 though that wouldn't do much to tell me why it broke.

14:28 oddcully: something could depend on the right lib implicitly and now the change in version made it go away. and the most develish case: it broke already sooner, but uncleaned stuff made it work for some time longer

14:32 curtosis: ugh, yeah.

14:38 welp, I blew away my target/classes directory, which uncovered an undetected error in the java-side code, but the problem persists.

14:39 note to self: lein clean doesn't clean everything.

14:43 xemdetia: did you try lein clean --moms-coming-over /s

14:44 curtosis: :p

14:44 off to try rebooting....

15:00 rebooting did not fix it, which is at least good in that there may still be a discernable cause

15:01 oddcully: yay, your problem is persistent!

15:01 TEttinger: have you tried becoming an alcoholic? it may help you forget the problem

15:01 curtosis: (:require [bourbon :as water])

15:01 xeqi: curtosis: could you paste a `lein deps :tree`

15:05 curtosis: https://gist.github.com/curtosis/658f346512cc2708fea9

15:05 fortunately, I had just started trawling through them.

15:08 xeqi: curtosis: have you recently changed https://gist.github.com/curtosis/658f346512cc2708fea9#file-1_tree-out-L32 ?

15:09 curtosis: not for months

15:09 but interesting... it wants wstx!

15:11 xeqi: and its different version then in https://github.com/clojure/data.xml/blob/jdk16-pull-parser/jdk_15_readme.txt

15:11 or the underlieing staxs is

15:12 curtosis: yeah. though... why now?

15:15 dillap: silly questions - is there a way to automatically use clojure.repl in cider? Every time I change namespaces I have to manually (use 'clojure.repl).

15:17 curtosis: xeqi: worst fear confirmed. rolled back to commit from a week ago. same problem.

15:18 oddcully: curtosis: just to have it mentioned: have you changed stuff in your ~/.lein/ ?

15:18 curtosis: oddcully: not that I'm aware of, but I'll check it anyway

15:20 nope, nothing new there.

15:20 all I have is cider-nrepl plugin, which I'm not using.

15:20 (and it's been there for ages)

15:22 sotojuan: whos gonna see david nolen today in nyc

15:22 represent #clojure

15:23 oddcully: depend on the livestream not using flash :*)

15:24 siefca: Is arity overloading in Clojure handled at compile-time or at runtime? (Btw, is it possible to add arity to function object that has alredy been defined?)

15:25 thearthur: siefca: not in the litteral sense of changing an existing function

15:25 Bronsa: siefca: what do you mean byu arity overloading handling?

15:26 thearthur: it's easy to define a new function with the extra arity and have the rest of your code use it dynamically though

15:26 siefca: so in practice this is not a problem

15:26 Bronsa: redeffing is not idiomatic

15:29 siefca: thearthur, Bronsa: I could define new function, handle additional arity in it and call the original function for other cases -- there are two function objects in mmory then. What I was looking is some way to "inject" additional arity to function that already exists.

15:29 ckirkendall: Has anyone experienced a stack overflow exception in recent versions of ClojureScript due to circular dependencies. It is thrown in util/topo-sort

15:31 thearthur: siefca: This is not possible to do retroactivly for an existing function. you could get close by using a function that generates these functions perhaps?

15:31 having a second function floating around doesn't sound bat to me, though personal preference matters in these cases

15:32 Bronsa: siefca: no, that's not possible

15:33 siefca: Bronsa: by handling arity ovrloading I mean whether dispatching of call to some subroutine is done at runtime or at compile time

15:34 oddcully: ckirkendall: last week (or some timespan ago) someone over at #clojurescript had one of those.

15:34 Bronsa: siefca: clojure functions can only have overloading in the number of args, not on the args type -- that is done at compile time

15:35 siefca: assuming f is a Var, (f 1 2 3) is compiled to f.getRawRoot().invoke(1,2,3)

15:35 curtosis: xeqi: I've gone back several weeks. in commits... something else must be going on.

15:37 siefca: Bronsa: that's what I was looking for! :)

15:38 Bronsa: how can I inspect it on my own? (see Java calls that correspond to Clojure's expressions)

15:39 Bronsa: siefca: you can't really, clojure compiles to jvm bytecode

15:39 siefca: compiling clojure code to a classfile and decompiling it is the best you can do

15:40 if you're comfortable reading jvm bytecode, I usually just use javap -c on the classfile

15:40 otherwise there are a bunch of tools that take a jvm classfile and transform it back into a java source

15:42 siefca: Bronsa: thx, I'm not coming from Java world but from Ruby/C so such hints are helpful

15:44 oddcully: siefca: this one is stand alone and ok http://jd.benow.ca/. if you are running already cursive/intelij - it has a disasm built in in version 14

15:46 siefca: oddcully: cool! thanks :)

15:53 celwell: Hi, is there a core function that will take a value and use it for the first argument of any following expressions? Think ->, but uses the _initial_ value each time (obviously, for side-effects)

15:54 amalloy: doto

15:55 celwell: amalloy: oh, i thought was only for using methods of an object, thanks

16:16 cfleming: oddcully: siefca: JD is fairly out of date last time I looked, and it's a pain to use since it's native. There are a couple of really good ones in pure Java these days, I like Procyon, and the one built into IntelliJ is pretty good too.

16:16 oddcully: siefca: CFR is also very good.

16:18 curtosis: hmm... curiouser and curiouser. tarred up my entire dev directory and dropped it on a linux machine that has never had it run (I even had to install lein). Builds fine there. Tried deleting my ~/.m2/repository on my main machine, and I'm still getting the problem.

16:18 cfleming: oddcully: siefca: The IntelliJ one is based on Fernflower IIRC, I'm not sure if they modified it though.

16:19 justin_smith: curtosis: that's super weird. How about also purging the lein self-installs? what other difference could be there (other than various config I assume you would remember using...)

16:19 oddcully: cfleming: i downloaded jde and it worked... i can only comment on that. i also used the jde plugin for intellij up to the current version

16:20 to my understanding the native stuff is just apocalipse wrapped

16:20 cfleming: oddcully: IIRC it doesn't do modern Java features, and since it's not OSS no-one else can add that.

16:22 curtosis: justin_smith: indeed it is! The only significant differences are platform (OS X vs Linux) and JDK (Sun vs OpenJDK). But the original config (OSX/Sun) worked this morning.

16:22 oddcully: that might be. i only used it against old crappy code where the source is lost. i also never tried it against code, that attempts to prevent disasm (aka copy-protection etc)

16:23 cfleming: Yeah, I think CFR is state of the art there.

16:23 oddcully: ill check that out... once my pixie has compiled

16:23 cfleming: Generally for complicated code I've found I have to try a couple and pick the best results.

16:32 m1dnight_: Has anyone encountered the error that in CIDER you have to select the code statement below a macro in order to expand the above macro?

16:38 wasamasa: using evil?

16:53 m1dnight_: evil?

16:53 no just white magic. Black magic tends to escalate rather quickly.

17:02 hlolli: Is there a cleaver way to have a function or macro return two values instead of one. So I can have a function (defn x [a b] (+ a b)) and fill inn the two artireis with (x (one-function/macro))

17:05 Bronsa: no

17:05 justin_smith: hlolli: in clojure everything returns exactly one value (except for things like throw that technically don't return iirc)

17:08 m1dnight_: ,(apply + ((fn [] [1 2])))

17:08 hlolli: ok, so I guess I will just use destructuring

17:08 clojurebot: 3

17:08 m1dnight_: You could do that. but thats kind of nasty.

17:09 hlolli: yes, I can always type in the two fields manually, just trying to find a way to make things shorter and more comfortable.

17:09 m1dnight_: No, return an array of results and apply a function that, is what I mean.

17:10 so you would get: (apply x (one-function/macro)) if `one-function/macro` returns a vector of 2 numbers.

17:10 hlolli: hmm ok! yes, I could work with that

17:27 m1dnight_: Is there a difference between :timestamp and :datetime? I can only seem to find the latter in the docs for sqlite.

17:28 (Im using korma sql)

17:28 (and sqlite)

17:31 hlolli: anyway, thakns m1dnight_ works like magic

17:49 ionthas: I'm having a problem applying a funcion to a vector of vectors. (def v3 [[20 [1 2]] [10 [4 5]] [15 [7 8]]) I want to sort the vector of vector using the first element of each vector. Using something like (apply #(sort-by first (first %)) v3) doesn't work :/. Can anyone give me a hint?

17:50 The result should be [[10 [4 5]] [15 [7 8]] [20 [1 2]]]

17:51 blake_: ionthas: (sort-by first v3)

17:52 ionthas: ?

17:52 oddcully: blake_: !

17:53 ionthas: blake_: you're right

17:53 I think it's time to go to sleep xD

17:53 blake_: ionthas: Overthinking it, maybe? =)

17:53 ionthas: yep :)

17:54 thanks for the help, I will stop for today.

17:54 blake_: ionthas: Or have fun debugging tomorrow.

17:54 ionthas: blake_: hahahah that will be hilarious but I think I will pass xD

17:55 blake_: Heh.

17:56 curtosis: Sigh. I got nothing. Updated Java, OSX and XCode. Cleared out .m2/repository and target/classes, and still get XMLOutputFactory not found.

17:56 seriously contemplating defenstrating something heavy.

18:04 xemdetia: curtosis, have you just looked inside the repo jars to see if you can can find the actual class def

18:04 curtosis: I haven't poked there... I'm not confident it's a config/repo problem anymore, since I can build successfully on a different machine.

18:05 but I'll take a look

18:05 xemdetia: well if I was in your shoes I would be a lot more confident if I can say 'it is absolutely 100% defined in this jar and even a simple test import works fine'

18:07 curtosis: yep.... 7353 Thu May 07 20:30:42 EDT 2009 com/ctc/wstx/stax/WstxOutputFactory.class

18:07 (from the jar in my .m2/repository)

18:07 xemdetia: That's not XMLOutputFactory?

18:08 curtosis: sorry, there's some earlier context I thought you'd seen. the error I'm getting is:

18:08 java.lang.RuntimeException: Provider for class javax.xml.stream.XMLOutputFactory cannot be created

18:08 at javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:367)

18:08 ... 61 more

18:08 Caused by: java.util.ServiceConfigurationError: javax.xml.stream.XMLOutputFactory: Provider com.ctc.wstx.stax.WstxOutputFactory not found

18:08 oddcully: yes, also check if that .m2/repository file there can be used (e.g. unzip -l the.jar)

18:09 curtosis: oddcully: yep, comes out fine.

18:09 xemdetia: is there some sort of properties registry or something for these providers that the clojure interface is not doing for you?

18:10 curtosis: xemdetia: I'm not actually using it myself at all. It's getting used by clojure.data.xml when lein ring uberwar tries to create a web.xml file.

18:10 and, this all worked on this machine this morning. Something had to have changed, but I can't figure out what it possibly could be.

18:12 oddcully: is your build machine the same OS as your build machine? have you tried vimdiff-ing an strace (grapsing straws here...)

18:13 erm... i mean is your CI machine the same OS as the box failing to build

18:14 curtosis: oddcully: no, my normal dev box is OSX 10.10. I was able to successfully tar everything up and build on a clean linux box. so not really comparable

18:14 and I'm grasping at straws as well

18:15 xemdetia: curtosis, any funky permissions?

18:15 that would be accounted for in the tar-untar-it worked fine path

18:16 curtosis: xemdetia: not sure how I'd check that

18:16 well, except I tried the untar in a clean directory on my OSX machine and that also broke.

18:16 building from the untar, I mean.

18:17 xemdetia: ok that would check it

18:36 curtosis: ok, and now I've confirmed that it does *not* build on a different OSX machine.

18:36 (same tarfile)

18:37 I'd blame it on the 10.10.5 Yosemite update, but my work machine was throwing the error *before* the update.

18:37 justin_smith: curtosis: maybe you get some version of some dep that is subtly incompatible with osx?

18:38 curtosis: justin_smith: I suppose that's possible... but I don't even know where to start tracking that down. lein deps :all-deps-that-changed-since-this-morning ? /s

18:50 at least i've found a faster test case... lein pom blows up too. It's a clojure.data.xml problem.

20:26 omg.... solved! I know what caused the problem, but I don't know how, or why only on OSX.

20:26 justin_smith: do tell

20:27 curtosis: as part of debugging a different part of code (seeing what was put in the uberwar) I extracted META-INF/ into the project directory.

20:27 that's it.

20:28 with META-INF there, it blows up, only on OSX. (it's in the tar I moved across machines)

20:28 rename/move META-INF, it works fine.

20:28 that is some seriously counterintuitive behavior.

20:38 oh, I see... META-INF/services/javax.xml.stream.XMLOutputFactory pointed to WstxOutputFactory, which was on the *project* classpath, but not on the *leiningen* classpath. It was the lein code that was generating XML, so it should have been pulling in the default platform implementation.

20:38 but respecting META-INF overrode that with an impl that wasn't on the classpath.

20:49 no reason to think the project root should be considered on the classpath, but there it is

20:50 ("there it is" meaning it appears to be nevertheless included by the JRE; "lein classpath" does *not* include it.)

20:51 justin_smith: curtosis: adding "do you have a directory called META-INF" to my list of diagnostic questions

20:51 curtosis: :)

21:10 and now I really am going to find some bourbon.

21:10 thanks all for the diagnostic efforts

23:59 nxqd: hi guys, what is the namespace for memoize in clojurescript

Logging service provided by n01se.net