#clojure logs

2015-09-29

01:35akkadhttps://gist.github.com/9ef5804b239f0c3c94b9 => Parameter declaration "loop" should be a vector
02:50akkadet voila. missing [] before loop.
03:10amalloya classic error message that's unusually bad even for clojure
03:17akkadman this recursion with loop/recur has me stumped
03:18akkadI'm looping but the new value passed to recur does not seem to update within the loop
03:23akkadaja
03:24loke(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.
03:29hyPiRionloke: subseq
03:30hyPiRion,(let [s (apply sorted-set (range 10))] (subseq s >= 5))
03:30clojurebot(5 6 7 8 9)
03:31lokehyPiRion: Woah. Thanks!
03:51siefcahi guys. is arity overloading in Clojure handled at compile-time or at runtim[Ce?
03:53siefcai'm trying to find examples of static polymorphism in Clojure (if there are any, without core.typed)
04:18amalloysiefca: 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
05:02dzhus`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?
05:02hyPiRionoh, this is the best use case for juxt
05:03hyPiRion,((juxt inc dec #(+ 10 %)) 10)
05:03clojurebot[11 9 20]
05:03dzhusnoice
05:07dzhusIs there a shortcut for (some identity)\
05:08dzhus?
05:09muhuk_dzhus: nil?
05:09muhuk_dzhus: some?
05:10muhuk_no, neither actually
06:19Guest62166is there a shothand for this .. (let [foo (fun)] (blah-bleh-blah foo) (raaaa foo) foo)
06:19Guest62166like .. for the java objects
06:20oddcully,(doc doto)
06:20clojurebot"([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))"
06:20Guest62166ah!
06:21oddcully,(doto (java.util.HashMap.) (.put 1 2) (.put 2 3))
06:21clojurebot{1 2, 2 3}
06:21Guest62166hurmm but that would require x to be always passed in second place
06:22oddcullythen maybe as-> ?
06:22Guest62166which is like 90% of cases
06:22Guest62166but as-> does not return the original
06:22lumaoddcully, that doesn't return the original
06:22Guest62166what luma said
06:24Guest62166a macro like (ret [x (foo)] ....) in core would be nice
06:29luma,(defmacro returning [binding & body] (let [[sym expr] binding] `(let [~sym ~expr] ~@body ~sym)))
06:29clojurebot#'sandbox/returning
06:30luma,(returning [x 1] (println "x is" x))
06:30clojurebotx is 1\n1
06:31Guest62166+1 luma
06:31Guest62166should be in the core
06:44sveriHi there, quick survey core.typed / schema or annotate?
06:45Guest62166,(inc 1) (inc 2)
06:45clojurebot2
06:45Guest62166new nrepl seems to eval every expression
06:45Guest62166on my machine
06:46Guest62166sveri: prismatic schema?
06:47sveriGuest62166: yea, exactly
06:47Guest62166i have used it on a large project in my company for enforcing types and structure
06:47Guest62166its easy to code
06:47Guest62166and has very low cpu footprint
06:48Guest62166dont know about core.typed
06:49Guest62166prismatic schema can let you enforce data shape too, which would otherwise be a little unsusual for a type checker imo
06:50nowprovisionthere 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
06:50Guest62166yes its really 10/10 project for me too
06:51Guest62166and the s/pred makes it possible to put weird assertions in type checking itself
06:52Guest62166if thats your thing
06:52Guest62166although i have not used schema to anotate functions, there seems to be support for it using s/fn i guess
06:52Guest62166would like to check it out sometime
08:27roelofHello, 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}}
08:27roelofI 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
08:28roelofhow to solve this ?
08:28mavbozoupdate-in ?
08:29opqdonutroelof: (set (:authors book))
08:29opqdonutroelof: or (set (book :authors))
08:29opqdonutroelof: or update-in for a fancier solution
08:30roelofthe course did not mentioned update_in at this moment
08:30snowellYeah, so if you can't use update-in, go with what opqdonut said
08:31snowell(set :authors) is trying to make a set out of the keyword :authors
08:31snowell(set (:authors book)) will use the value from the map
08:33roelofthanks, I hope I once get used to the syntax of clojure
08:37roelofnow im getting more difficult challenges Im a lot lost in the syntax :(
08:42mavbozoroelof, what course do you follow?
08:43roelofmavbozo: this one ; http://iloveponies.github.io/
08:55noncomroelof: you won't be lost. there is almost no syntax. all that is written is usually obvious
08:56noncomroelof: 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
08:56roelofnoncom: for me not. in the last 10 exercises I make a lot of syntax errors
08:57noncomyou can first try arranging things in a (let [..]) where you step-by step write every point, maybe that'd be more clear
08:58noncomroelof: don't worry, you are on the way to clarity :)
09:00roelofnoncom: so using a helper which convert the authors to a set and using that in the function
09:01roelofnoncom: so also better look at the parameters of a function
09:01noncomroelof: yes. it's just simple steps. which later can be put one into another.
09:02noncomevery step has no implicit things, all is specified obviously (except for sometime with macros, but that's advanced)
09:02roelofthanks,
09:04roelofnow time for a very late lunch ( 15:00 hour) here :(
09:28oddcullyis 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
09:48snowell,(doc select-keys)
09:48clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
09:50snowell,(select-keys [:a :c] {:a 1 :b 2 :c 3 :d 4}); oddcully: like this?
09:50clojurebot{}
09:50snowell,(select-keys {:a 1 :b 2 :c 3 :d 4} [:a :c]); OK I meant this?
09:50clojurebot{:a 1, :c 3}
09:52oddcullysnowell: yes like this. or the pull syntax, if you know datascript
10:13crocketWhy do I not have direct access to protocols like ISeq in clojure?
10:13crocketClojureScript exposes ISeq.
10:15justin_smith,clojure.lang.ISeq
10:15clojurebotclojure.lang.ISeq
10:15crocket,(doc ISeq)
10:15clojurebotI don't understand.
10:15justin_smithcrocket: ^ as exposed as it could be
10:15justin_smithcrocket: it can't have doc because it's not a var
10:16justin_smithit's a class
10:16crocketClojureScript even has a documentation for ISeq.
10:16crocket,(doc ISeq)
10:16clojurebotCool story bro.
10:16justin_smithcrocket: because in clojurescript they don't have vars
10:16justin_smithso doc is completely different
10:16crocketWhere do I get documentation for clojure.algn.ISeq?
10:16justin_smithcrocket: also, it's not just ISeq unless you import it
10:16justin_smithit's clojure.lang.ISeq, clojure.lang is not auto-imported
10:18crocketI can't find javadoc
10:18justin_smithcrocket: there's a download for the javadoc here http://mavensearch.io/repo/org.clojure/clojure/1.7.0
10:19crocketIs there a web version of clojure javadoc?
10:20justin_smithnot sure... it's odd that its so hard to find
10:20crockethttps://clojure.github.io/clojure/javadoc/ is faulty
10:20justin_smiththere's definitely an html page for ISeq in that javadoc jar
10:22crocketShame
10:22justin_smithbut all there is to say is it has methods cons, first, more, and next. first returns Object, the others return ISeq
10:22justin_smithoh, and cons takes an arg
10:23justin_smith(of type Object)
10:26fuuduCoderany data scientists here ?
10:26fuuduCoderwhat has been your general experience with incanter
10:29crocketfuuduCoder, I heard clojure is going to beat python on exploratory data science(e.g., exploring new machine learning algorithms).
10:30fuuduCoderI hope so. fingers crossed. :-)
10:31crocketfuuduCoder, I recommend "Akhil Wali-Clojure for Machine Learning-Packt Publishing - ebooks Account (2014)"
10:53m1dnight_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:54m1dnight_or do I have to copy/paste it into the nrepl window first?
10:55m1dnight_ah nvm, I made a booboo.
11:11visofhi guys
11:11visofcan i do (case (type x) ??
11:12justin_smithvisof: sure, but often a multimethod is a better way to handle that
11:12m1dnight_https://clojuredocs.org/clojure.core/instance_q, like this?
11:13visofjustin_smith: it's not multimethod, it's generic method which should work on different types
11:13justin_smithvisof: how's that different from a multimethod?
11:14visofjustin_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:14justin_smithvisof: multimethod!
11:14justin_smith,(defrecord Foo [])
11:14clojurebotsandbox.Foo
11:14justin_smith,(defrecord Bar [])
11:14clojurebotsandbox.Bar
11:14justin_smith,(defmulti mult class)
11:14clojurebot#'sandbox/mult
11:15m1dnight_https://blog.8thlight.com/myles-megyesi/2012/04/26/polymorphism-in-clojure.html
11:15justin_smith,(defmethod mult Bar [n] "a bar")
11:15m1dnight_This is a good example as well.
11:15clojurebot#object[clojure.lang.MultiFn 0x55daea5a "clojure.lang.MultiFn@55daea5a"]
11:15m1dnight_(sorry for the combobreaker there)
11:15justin_smith,(defmethod mult Foo [n] "a foo")
11:15clojurebot#object[clojure.lang.MultiFn 0x55daea5a "clojure.lang.MultiFn@55daea5a"]
11:15visofjustin_smith: thanks it will do
11:15fehrenbachvisof: have you considered a protocol?
11:15justin_smith,(mult (Foo.))
11:15clojurebot"a foo"
11:15visoffehrenbach: nope
11:16fehrenbachvisof: 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:17visoffehrenbach: why it's better?
11:18dzhus`(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:19fehrenbachvisof: 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:20justin_smithdzhus`: what is db-spec ? maybe you provided a function there instead of the usual hash-map?
11:20justin_smithdzhus`: also, it would be good to see a paste of the whole stack trace, if you can share it on refheap.com
11:21dzhus`justin_smith: a map with :classname and stuff for connecting to DB. The same db-spec works in a different query
11:24dzhus`https://www.refheap.com/110076
11:27justin_smithdzhus`: weird, why would jdbc try to call seq on an anonymous function that it defined?
11:27justin_smithbecause from that stack trace and your error, this is clearly what is happening
11:28justin_smithinside set-parameters...
11:29Bronsadzhus`: which version of clojure are you using?
11:31dzhus`Java 1.8.0_60, Clojure 1.7.0, nREPL 0.2.1
11:32Bronsacan you try with 1.6 and see if the error message changes?
11:32justin_smithBronsa: oh, could this be a transducer arity thing?
11:32Bronsaprobably not but worth a try
11:33dzhus`maybe I'll try
11:37m1dnight_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:37m1dnight_or do I have to play with string ops?
11:37Bronsa,*ns*
11:37clojurebot#object[clojure.lang.Namespace 0x7af2ec7c "sandbox"]
11:37m1dnight_Yes, that yields the entire namespace.
11:37Bronsa,(name (ns-name *ns*))
11:37clojurebot"sandbox"
11:38m1dnight_oh
11:38Bronsa,(name (ns-name (the-ns 'clojure.core)))
11:38clojurebot"clojure.core"
11:38m1dnight_(name (ns-name *ns*)) --> "clojbot.modules.karma"
11:38m1dnight_I think I only want the last part.
11:38m1dnight_hmm maybe the entire part will do as well.
11:39Bronsam1dnight_: 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:41m1dnight_Idd, but I want to use it to automatically build databasetables and such.
11:41m1dnight_Ill just parse itmyself.
11:44TEttinger,(re-find #"\.[\w-]+$" (name (ns-name (the-ns 'clojure.core))))
11:44clojurebot".core"
11:44TEttinger,(re-find #"[\w-]+$" (name (ns-name (the-ns 'clojure.core))))
11:44clojurebot"core"
11:44TEttingerhm, could you start an ns with any char?
11:44m1dnight_,(re-find #"[\w-]+$" (name (ns-name (the-ns 'clojure.core.foo.bar))))
11:44clojurebot#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:45TEttingerit's trying to resolve with the-ns
11:45m1dnight_,(re-find #".*\.[\w]+$" (name (ns-name (the-ns 'clojure.core.foo.bar))))
11:45clojurebot#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:45m1dnight_oh
11:45m1dnight_ill just try on my own repl
11:46TEttinger,(in-ns 'clojure.core.foo.bar (re-find #"[\w-]+$" (name (ns-name *ns*))))
11:46clojurebot#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:47TEttinger(doc in-ns)
11:47clojurebot"([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
11:47TEttinger,(in-ns clojure.core.foo.bar (re-find #"[\w-]+$" (name (ns-name *ns*))))
11:47clojurebot#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:47TEttingeroh
11:47TEttingerherp
11:48TEttinger,(do (in-ns 'clojure.core.foo.bar) (re-find #"[\w-]+$" (name (ns-name *ns*)))))
11:48clojurebot#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:48TEttingerhaha
11:48justin_smithTEttinger: yeah, in-ns doesn't do (clojure.core/refer-clojure) automatically
11:48TEttinger,(do (in-ns 'clojure.core.foo.bar) (require 'clojure.core) (re-find #"[\w-]+$" (name (ns-name *ns*)))))
11:48clojurebot#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:48TEttinger,(do (in-ns 'clojure.core.foo.bar) (clojure.core/require 'clojure.core) (re-find #"[\w-]+$" (name (ns-name *ns*)))))
11:48clojurebot#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:48justin_smithTEttinger: (clojure.core/refer-clojure)
11:48TEttinger,(do (in-ns 'clojure.core.foo.bar) (clojure.core/refer-clojure) (re-find #"[\w-]+$" (name (ns-name *ns*)))))
11:48clojurebot"bar"
11:49TEttingeryay
11:49TEttinger(inc justin_smith)
11:49justin_smithTEttinger: 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:50TEttingerindeed
11:53m1dnight_ah cool :D thanks guys
11:53Bronsaor you can just in-ns to a real ns back
11:53justin_smith$ git commit -m 'FUCKING SCALA I TELL YOU WAT'
11:53Bronsain-ns is automagically resolved to c.c/in-ns
11:53justin_smithBronsa: as in clojure.core/in-ns of course
11:53Bronsanop
11:53justin_smithBronsa: oh, wow
11:54Bronsajustin_smith: you can't shadow in-ns as a matter of fact
11:54justin_smithfascinating
11:54Bronsahttp://dev.clojure.org/jira/browse/CLJ-1582
11:54bjajustin_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:55TEttingerjustin_smith: you dealing with some o' dis? http://nurkiewicz.github.io/talks/2014/scalar/img/list-scala.png
11:57xemdetiawow
11:57xemdetia'start here' in bottom right? I hope that graph is auto generated :(
11:57expezwhat is the predicate to see if something responds favorably to (seq <thing>)?
11:57justin_smithTEttinger: 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:57Bronsaexpez: there's a sequable? predicate in core.incubator
11:57snowellexpez: seq?
11:58Bronsahttps://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L83
11:58expezsnowell: nop
11:58Bronsaseqable*
11:58justin_smith,(seq? (list 1 2 3))
11:58clojurebottrue
11:58TEttingerxemdetia: I think they made it in Fortran
11:58justin_smith,(seq? [1 2 3])
11:58clojurebotfalse
11:58justin_smith(= (list 1 2 3) [1 2 3])
11:59TEttinger,(= (list 1 2 3) [1 2 3])
11:59clojurebottrue
11:59BronsaI don't think I've ever used the fact that lists compare with vectos
11:59TEttinger,(= (list 1 2 3) [1 2 3] (ArrayList. [1 2 3]))
11:59clojurebot#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:59TEttinger,(= (list 1 2 3) [1 2 3] (java.util.ArrayList. [1 2 3]))
11:59clojurebottrue
12:00TEttingerinteresting!
12:00TEttinger,(= (list 1 2 3) [1 2 3] (java.util.Deque. [1 2 3]))
12:00clojurebot#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:00expezheh why are vectors and lists =?
12:00justin_smithexpez: for convenience of course
12:00TEttinger,(= (list 1 2 3) [1 2 3] (java.util.LinkedList. [1 2 3]))
12:00clojurebottrue
12:01TEttinger,(= (list 1 2 3) [1 2 3] (java.util.ArrayDeque. [1 2 3]))
12:01clojurebotfalse
12:01TEttingeraha!
12:01TEttingeronly for List interface it seems, not Queue
12:03mungojellyexpez: have you read the classic "EGAL" paper? because i think that gives a good sense of clojure's attitude towards equality
12:04expezmungojelly: you probably misunderstood that paper if you're using it as an argument in favor of this behavior
12:04mungojellyexpez: 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:05expezmungojelly: 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:05mungojellymeh 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:07mungojellyi 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:08mungojellys and so that really means little.
12:10mungojellylists 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:14justin_smithmungojelly: it's funny though that (!= 1 1.0) but (= (list 1 2 3) [1 2 3]) - amusing combination of choices
12:16mungojellyit'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:17mungojellybut 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:22m1dnight_When is the namesapce set to "user"? I have a leiningen project which seems to resolve *ns* to user at runtime..
12:23justin_smithm1dnight_: it's the clojure default, any other runtime ns is caused by some tooling
12:23m1dnight_ah okay
12:23justin_smithso eg. lein run, all code should be in ns user at runtime
12:23m1dnight_hmm, that makes it more difficult.
12:23m1dnight_okay thanks justin_smith
12:23m1dnight_could I create nasty sideeffects if I do a (in-ns) before?
12:24justin_smithm1dnight_: hmm... what are you using runtime ns for anyway?
12:25m1dnight_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:26m1dnight_https://www.refheap.com/110085
12:26m1dnight_something like that
12:26m1dnight_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:27justin_smithm1dnight_: ok, but the *ns* call there ends up pointing to user?
12:27m1dnight_yep
12:28m1dnight_aha!
12:28m1dnight_I can expand the *ns* variable at compile time
12:28m1dnight_that works!
12:30m1dnight_oh wait, it doesn't
12:32m1dnight_yes it does. had to do a clean first :)
12:44akkadhmm something rich forgot to copy from CL
12:50oymyakonI 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:51rasmustooymyakon: do you have cider/cider-nrepl in your ~/.lein/profiles.clj ?
12:52oymyakonrasmusto: I have not installed cider as I thought it was only for emacs
12:52oymyakonshould I install it?
12:53rasmustooymyakon: newer versions of fireplace use cider iirc
12:53rasmusto(or they fall back to using vimscript)
12:53oymyakonoh, Ok then I will install it and try again. Thank you
12:59noncomwhen i can chose to use either reduce or mapv, what is betteR?
12:59akkadrasmusto: in dependencies?
12:59rasmustoakkad: in plugins
13:01akkadthanks
13:02mungojellyshould lein-midje be in the project.clj for a project that uses midje? or just in my own profiles.clj?
13:02justin_smithakkad: 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:03akkadjustin_smith: all of the attitude :P
13:14rasmustohey kid, lose the spoon!
13:30akkadhmm
13:30akkad(flatten foo) => OutOfMemoryError Java heap space java.util.Arrays.copyOf (Arrays.java:2882)
13:36justin_smithflatten is terrible anyway
13:37justin_smithperhaps you tried to flatten a recursive or infinite or indefinite structure?
13:37akkadnope. a seq of 100 seqs each containing 1000 elements
13:37akkads3 bucket file list
13:38rasmustoincrease your heap size (or use concat maybe?)
13:38rasmustoif you know how deep you have to traverse
13:39akkadmax/min can be set dynamic right/
13:39akkad?
13:39akkadtypically I recurse fine in cl with this same structure/dataset (defun flatten (x) (if (consp x) (flatten (car x)) x))
13:40justin_smithakkad: clojure's flatten is shitty
13:40justin_smithalso why would you only care about the car of x?
13:41justin_smithI mean you throw away the cdr there
13:43akkadhmm I've not lost data with it
13:43justin_smithwhat that code literally says, is if x is a cons, flatten it's car and ignore the cdr
13:43justin_smith*its
13:45akkadyeap
13:45justin_smithignore as in discard, not as in pass along unchanged
13:45akkadyes, understood
13:46akkadwill just loop/recur then thanks
13:49akkadjustin_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:50akkadanyway thanks, I'll avoid the flatten and just collect it myself
13:54justin_smithif 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:54justin_smith,(apply concat [[1 2 3] [4] [] [5]])
13:54clojurebot(1 2 3 4 5)
13:55TMAwhy 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:55justin_smith,(flatten "hello")
13:55clojurebot()
13:55justin_smith(source flatten)
13:56justin_smith(filter (complement sequential?) (rest (tree-seq seqential? seq x)))
14:01akkadnice command, source
14:06curtosishello all
14:08curtosisI 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:09curtosisit's happening when uberwar tries to create the web.xml
14:10curtosisand 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:10xeqicom.ctc.wstx.stax.WstxOutputFactory is a strange class. and different then what you pasted in slack
14:11xeqior, maybe you just didn't paste that line
14:11curtosisyeah, I didn't copy the detail over.
14:12curtosisI thought the entire stack trace was not likely to be particularly enlightening.
14:14curtosisit 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:15curtosismuch less anything I've changed in the last 2 hours.
14:17justin_smithcurtosis: have you changed deps recently and not run lein clean since?
14:17oddcullycurtosis: newly as in it worked before?
14:18oddcullycurtosis: if in doubt bisect your changes (and clean in between as justin_smith said)
14:18curtosis@justin_smith: nope. I mean, yes, I have changed deps, but have run lein clean several times since.
14:19curtosis@oddcully: yeah, it worked this morning. And, of course, I don't have a clean way to bisect the changes.
14:19curtosisbut I've tried individually commenting out or removing most of the changes, with no difference.
14:21curtosis(they're all really small... added a :profile to project.clj, and added a couple of functions to my routes)
14:21xeqicurtosis: did you change java versions recently? https://github.com/clojure/data.xml/blob/jdk16-pull-parser/jdk_15_readme.txt
14:21curtosisxeqi: 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:22curtosisI've started from a new shell session, too.
14:23curtosisMy next step is probably rebooting, just for the sake of completeness.
14:24curtosisthough that wouldn't do much to tell me why it broke.
14:28oddcullysomething 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:32curtosisugh, yeah.
14:38curtosiswelp, I blew away my target/classes directory, which uncovered an undetected error in the java-side code, but the problem persists.
14:39curtosisnote to self: lein clean doesn't clean everything.
14:43xemdetiadid you try lein clean --moms-coming-over /s
14:44curtosis:p
14:44curtosisoff to try rebooting....
15:00curtosisrebooting did not fix it, which is at least good in that there may still be a discernable cause
15:01oddcullyyay, your problem is persistent!
15:01TEttingerhave you tried becoming an alcoholic? it may help you forget the problem
15:01curtosis(:require [bourbon :as water])
15:01xeqicurtosis: could you paste a `lein deps :tree`
15:05curtosishttps://gist.github.com/curtosis/658f346512cc2708fea9
15:05curtosisfortunately, I had just started trawling through them.
15:08xeqicurtosis: have you recently changed https://gist.github.com/curtosis/658f346512cc2708fea9#file-1_tree-out-L32 ?
15:09curtosisnot for months
15:09curtosisbut interesting... it wants wstx!
15:11xeqiand its different version then in https://github.com/clojure/data.xml/blob/jdk16-pull-parser/jdk_15_readme.txt
15:11xeqior the underlieing staxs is
15:12curtosisyeah. though... why now?
15:15dillapsilly 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:17curtosisxeqi: worst fear confirmed. rolled back to commit from a week ago. same problem.
15:18oddcullycurtosis: just to have it mentioned: have you changed stuff in your ~/.lein/ ?
15:18curtosisoddcully: not that I'm aware of, but I'll check it anyway
15:20curtosisnope, nothing new there.
15:20curtosisall I have is cider-nrepl plugin, which I'm not using.
15:20curtosis(and it's been there for ages)
15:22sotojuanwhos gonna see david nolen today in nyc
15:22sotojuanrepresent #clojure
15:23oddcullydepend on the livestream not using flash :*)
15:24siefcaIs 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:25thearthursiefca: not in the litteral sense of changing an existing function
15:25Bronsasiefca: what do you mean byu arity overloading handling?
15:26thearthurit's easy to define a new function with the extra arity and have the rest of your code use it dynamically though
15:26thearthursiefca: so in practice this is not a problem
15:26Bronsaredeffing is not idiomatic
15:29siefcathearthur, 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:29ckirkendallHas anyone experienced a stack overflow exception in recent versions of ClojureScript due to circular dependencies. It is thrown in util/topo-sort
15:31thearthursiefca: 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:31thearthurhaving a second function floating around doesn't sound bat to me, though personal preference matters in these cases
15:32Bronsasiefca: no, that's not possible
15:33siefcaBronsa: by handling arity ovrloading I mean whether dispatching of call to some subroutine is done at runtime or at compile time
15:34oddcullyckirkendall: last week (or some timespan ago) someone over at #clojurescript had one of those.
15:34Bronsasiefca: clojure functions can only have overloading in the number of args, not on the args type -- that is done at compile time
15:35Bronsasiefca: assuming f is a Var, (f 1 2 3) is compiled to f.getRawRoot().invoke(1,2,3)
15:35curtosisxeqi: I've gone back several weeks. in commits... something else must be going on.
15:37siefcaBronsa: that's what I was looking for! :)
15:38siefcaBronsa: how can I inspect it on my own? (see Java calls that correspond to Clojure's expressions)
15:39Bronsasiefca: you can't really, clojure compiles to jvm bytecode
15:39Bronsasiefca: compiling clojure code to a classfile and decompiling it is the best you can do
15:40Bronsaif you're comfortable reading jvm bytecode, I usually just use javap -c on the classfile
15:40Bronsaotherwise there are a bunch of tools that take a jvm classfile and transform it back into a java source
15:42siefcaBronsa: thx, I'm not coming from Java world but from Ruby/C so such hints are helpful
15:44oddcullysiefca: 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:46siefcaoddcully: cool! thanks :)
15:53celwellHi, 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:54amalloydoto
15:55celwellamalloy: oh, i thought was only for using methods of an object, thanks
16:16cflemingoddcully: 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:16cflemingoddcully: siefca: CFR is also very good.
16:18curtosishmm... 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:18cflemingoddcully: siefca: The IntelliJ one is based on Fernflower IIRC, I'm not sure if they modified it though.
16:19justin_smithcurtosis: 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:19oddcullycfleming: 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:20oddcullyto my understanding the native stuff is just apocalipse wrapped
16:20cflemingoddcully: IIRC it doesn't do modern Java features, and since it's not OSS no-one else can add that.
16:22curtosisjustin_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:22oddcullythat 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:23cflemingYeah, I think CFR is state of the art there.
16:23oddcullyill check that out... once my pixie has compiled
16:23cflemingGenerally for complicated code I've found I have to try a couple and pick the best results.
16:32m1dnight_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:38wasamasausing evil?
16:53m1dnight_evil?
16:53m1dnight_no just white magic. Black magic tends to escalate rather quickly.
17:02hlolliIs 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:05Bronsano
17:05justin_smithhlolli: in clojure everything returns exactly one value (except for things like throw that technically don't return iirc)
17:08m1dnight_,(apply + ((fn [] [1 2])))
17:08hlolliok, so I guess I will just use destructuring
17:08clojurebot3
17:08m1dnight_You could do that. but thats kind of nasty.
17:09hlolliyes, I can always type in the two fields manually, just trying to find a way to make things shorter and more comfortable.
17:09m1dnight_No, return an array of results and apply a function that, is what I mean.
17:10m1dnight_so you would get: (apply x (one-function/macro)) if `one-function/macro` returns a vector of 2 numbers.
17:10hlollihmm ok! yes, I could work with that
17:27m1dnight_Is there a difference between :timestamp and :datetime? I can only seem to find the latter in the docs for sqlite.
17:28m1dnight_(Im using korma sql)
17:28m1dnight_(and sqlite)
17:31hlollianyway, thakns m1dnight_ works like magic
17:49ionthasI'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:50ionthasThe result should be [[10 [4 5]] [15 [7 8]] [20 [1 2]]]
17:51blake_ionthas: (sort-by first v3)
17:52blake_ionthas: ?
17:52oddcullyblake_: !
17:53ionthasblake_: you're right
17:53ionthasI think it's time to go to sleep xD
17:53blake_ionthas: Overthinking it, maybe? =)
17:53ionthasyep :)
17:54ionthasthanks for the help, I will stop for today.
17:54blake_ionthas: Or have fun debugging tomorrow.
17:54ionthasblake_: hahahah that will be hilarious but I think I will pass xD
17:55blake_Heh.
17:56curtosisSigh. I got nothing. Updated Java, OSX and XCode. Cleared out .m2/repository and target/classes, and still get XMLOutputFactory not found.
17:56curtosisseriously contemplating defenstrating something heavy.
18:04xemdetiacurtosis, have you just looked inside the repo jars to see if you can can find the actual class def
18:04curtosisI 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:05curtosisbut I'll take a look
18:05xemdetiawell 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:07curtosisyep.... 7353 Thu May 07 20:30:42 EDT 2009 com/ctc/wstx/stax/WstxOutputFactory.class
18:07curtosis(from the jar in my .m2/repository)
18:07xemdetiaThat's not XMLOutputFactory?
18:08curtosissorry, there's some earlier context I thought you'd seen. the error I'm getting is:
18:08curtosisjava.lang.RuntimeException: Provider for class javax.xml.stream.XMLOutputFactory cannot be created
18:08curtosis at javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:367)
18:08curtosis ... 61 more
18:08curtosisCaused by: java.util.ServiceConfigurationError: javax.xml.stream.XMLOutputFactory: Provider com.ctc.wstx.stax.WstxOutputFactory not found
18:08oddcullyyes, also check if that .m2/repository file there can be used (e.g. unzip -l the.jar)
18:09curtosisoddcully: yep, comes out fine.
18:09xemdetiais there some sort of properties registry or something for these providers that the clojure interface is not doing for you?
18:10curtosisxemdetia: 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:10curtosisand, 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:12oddcullyis your build machine the same OS as your build machine? have you tried vimdiff-ing an strace (grapsing straws here...)
18:13oddcullyerm... i mean is your CI machine the same OS as the box failing to build
18:14curtosisoddcully: 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:14curtosisand I'm grasping at straws as well
18:15xemdetiacurtosis, any funky permissions?
18:15xemdetiathat would be accounted for in the tar-untar-it worked fine path
18:16curtosisxemdetia: not sure how I'd check that
18:16curtosiswell, except I tried the untar in a clean directory on my OSX machine and that also broke.
18:16curtosisbuilding from the untar, I mean.
18:17xemdetiaok that would check it
18:36curtosisok, and now I've confirmed that it does *not* build on a different OSX machine.
18:36curtosis(same tarfile)
18:37curtosisI'd blame it on the 10.10.5 Yosemite update, but my work machine was throwing the error *before* the update.
18:37justin_smithcurtosis: maybe you get some version of some dep that is subtly incompatible with osx?
18:38curtosisjustin_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:50curtosisat least i've found a faster test case... lein pom blows up too. It's a clojure.data.xml problem.
20:26curtosisomg.... solved! I know what caused the problem, but I don't know how, or why only on OSX.
20:26justin_smithdo tell
20:27curtosisas part of debugging a different part of code (seeing what was put in the uberwar) I extracted META-INF/ into the project directory.
20:27curtosisthat's it.
20:28curtosiswith META-INF there, it blows up, only on OSX. (it's in the tar I moved across machines)
20:28curtosisrename/move META-INF, it works fine.
20:28curtosisthat is some seriously counterintuitive behavior.
20:38curtosisoh, 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:38curtosisbut respecting META-INF overrode that with an impl that wasn't on the classpath.
20:49curtosisno reason to think the project root should be considered on the classpath, but there it is
20:50curtosis("there it is" meaning it appears to be nevertheless included by the JRE; "lein classpath" does *not* include it.)
20:51justin_smithcurtosis: adding "do you have a directory called META-INF" to my list of diagnostic questions
20:51curtosis:)
21:10curtosisand now I really am going to find some bourbon.
21:10curtosisthanks all for the diagnostic efforts
23:59nxqdhi guys, what is the namespace for memoize in clojurescript