#clojure logs

2014-10-05

00:02dbaschamalloy: still, with an array long-to-hash only becomes 10% faster
00:07dbaschamalloy: actually it becomes significantly faster, encode overall still takes 4x as long as the java version
00:07amalloysure, but you're getting there
00:07amalloyyou should be able to get it to at most 1.5x
00:08amalloyif you're inclined to keep pushing
00:11dbaschamalloy: well, I could rewrite the entire thing in java from clojure :)
00:12dbaschthe initial question was, what was the point of writing a clojure implementation of something for which there is a very performant java library
00:26alexyzis there a way to get from a Java array to a Clojure seq?
00:31dbaschalexyz: (seq the-array)
00:34dbaschbtw, if you change the-array, the seq changes so don’t do it
00:35dbasch(the sequence is backed by the array directly)
00:36alexyzdbasch thanks
00:37alexyzmeanwhile I have found a "native" Clojure function so no need to convert
00:38alexyzstill reading about multimethods... if the dispatch function returns a sequence how should I define a defmethod? I've tried '("text" "html") and it doesn't seem to match --- everything going to :default
00:39alexyzhttp://pastie.org/9621536
00:51dbaschalexyz: why do you need a multimethod there? it seems like you just want a case
00:52amalloyalexyz: multimethods are sneaky buggers, greatly opposed to being redefined. i bet if you (def my-multi nil) and then re-run that code it works fine
00:53dbaschI still think that’s an unnecessary usage of a multimethod though
00:54alexyzdbasch I asked earlier and was told about multimethod which seems to fit pretty well. I didn't know about case though
00:55alexyzamalloy unfortunately I'm not following you. I have found a bug in that code though and now it seems to work fine
00:56dbaschor not even a case, a map would do just fine
00:57alexyzdbasch in what sense a map?
00:57dbaschalexyz: you have a mapping of mime types to titles, right?
00:58alexyzdbasch nope... for each mime type I plan to apply a different approach for finding out the real title
00:58alexyzso basically it's a mapping from mime types to functions
00:58dbaschalexyz: ok, in that case a case
00:58alexyzthat's why multimethods sounded like exactly what I needed
00:59dbaschmultimethods are more useful when you have things of different types, and you don’t want to be figuring out what something is
00:59dbaschbut in your case you always have two strings
01:00alexyzbut the processing is rather different... and this sounds a lot like polymorphism
01:01alexyzI mean I'm pretty sure I can achieve the same results with either multimethods or a case so the real question here is more about what's the idiomatic way
01:01dbaschalexyz: in this situation it’s a matter of taste I guess. If you like it that way, why not
01:01alexyzI'll actually give it a try to both to learn how each of them feels
01:03dbaschI guess the other reason for multimethods is when you don’t know all your cases in advance and you want to be able to add dispatch methods without touching the existing logic
01:04alexyzdbasch in this particular case I thought that having the :default matcher around could prove quite useful
01:05dbaschalexyz: see also cond
02:13sineerAnyone knows how to use use .appendChild with Om dom/div ?
03:03borkdudebbloom what's the difference between union and sum types?
03:05julienmarieHello all. I'm quite of a newbie here. I got troubles to swap! a nested atom. I feel a bit lost about it for now ( first week on clojure / clojurescript ) http://pastebin.com/bwSqBLxW .Been scratching my head for a day on that now…
03:16borkdudejulienmarie I suggest you add a println to set-active to see what you are calling it with
03:16julienmarie@borkdude I'll do that
03:19julienmarie@borkdude this is what I'm getting [:menu [{:name Dashboard, :path /, :icon dashboard} {:name Analytics, :path /analytics, :icon analytics}]]
03:19julienmariebut I need to iterate under the :menu symbol
03:19borkdudejulienmarie I suggest you now look at the update-in function
03:20julienmarieinstead of assoc ?
03:20borkdudejulienmarie or assoc-in
03:20borkdudejust take a look at those functions
03:23julienmarie@borkdude thanks!
03:24borkdudenp
03:31borkdudequestion about core.typed: when I define a function in namespace a and also have the annotation there, and this function is called from namespace b incorrectly typewise, lein typecheck a b doesn't find it
03:31borkdudequestion is: what am I doing wrong
03:34borkdudecfleming renaming via filename refactors namespaces name, but not the other way around
03:37borkdudehmm, lein typed says: "Not checking ringapp.other (tagged :collect-only in ns metadata)"
03:37borkdudewhile I called it with lein typed ringapp.api ringapp.other
04:14H4nsi'm using http-kit+ring+compojure and my static resources are not found. i've looked at the system class loader (java.lang.ClassLoader/getSystemClassLoader) path and found that it contains the right directories. it seems, though, that a different class loader is used.
04:14H4nsany ideas how i could debug this further?
04:16H4nsin fact, the context class loader path seems to not contain anything
04:23H4nsapparently, a restart of my application helped with this.
05:14cflemingborkdude: Yeah, there's a few cases I need to fix there - the namespace code is old and crufty unfortunately
05:15cflemingborkdude: How's the core.typed support in Cursive BTW? It's pretty new and I haven't used it in anger yet.
05:15cflemingborkdude: I'd like to start using core.typed for some of the Cursive code but I haven't yet.
05:54SagiCZ1is there any way to take a string and compile it as a C code in java?
05:55martinklepschI just wrote a bit of code that feels complicated, would be happy if someone could take a look: https://gist.github.com/mklappstuhl/60b061d749f0c0c12275
05:59dysfunHi. what interface do i have to implement to support conj?
06:00SagiCZ1dysfun: Sequential?
06:00dysfuntuy
06:36dysfunis there a nice clojurescript dom library that might work under clojure with a webkit open?
06:37dysfunthe api is basically the same
06:42dysfundommy looks interesting. i'm not sure if i approve or disapprove of the gross abuse of macros in that way
06:48mbachow do i make a plot of a sequence of [x y] appear on my screen with minimum effort
06:48mbac(clojure.magic/plot data) isn't working :P
06:49mbacis it loom?
06:50borkdudecfleming I have the following issue with core.typed in general now: https://www.refheap.com/91197
06:50borkdudecfleming it's not entirely clear what happens when you just check 1 ns... what happens if the annotations are in another namespace? or when annotations are in "this" namespace, but calls in another?
06:51cflemingborkdude: Hmm, interesting - I'm not sure, I must admit. I implemented the Cursive support modelling it on the calls that the Emacs/Vim support makes, but like I say I still haven't used it myself other than to test it.
06:52cflemingborkdude: So I'm still not sure about a lot of the core.typed details.
06:52borkdudecfleming me neither. I started using it because it was present in the REPL menu :)
06:52cflemingborkdude: Haha - so you'll try all the libraries I add support for?
06:52borkdudecfleming maybe
06:53borkdudecfleming if I get a free license :P
06:53cflemingborkdude: I'll run it by my CFO
06:54borkdudecfleming how big is your team/company?
06:54borkdudecfleming I thought you were the only one
06:54cflemingborkdude: It's just me.
06:54borkdudehehe ok
06:54cflemingborkdude: My CFO is either me, or my wife
06:54borkdudecfleming lol ok.
06:57borkdudecfleming I actually had a use case for core.type to find possible null pointers in some code which uses bigints extensively, but until I can work this namespace problem out, it won't be of much use
06:57borkdudecfleming it's more a core.typed thing than cursive
06:57cflemingborkdude: Try the core.typed mailing list, ambrosebs is very responsive on there
06:57cflemingborkdude: When he's not around here, that is.
06:58borkdudecfleming I already pinged him on twitter, so I think he'll respond soon
06:58cflemingborkdude: Ok cool
07:00cflemingborkdude: Speaking of null pointers, check this out: http://t.co/qTbnjiXwpg
07:01borkdudecfleming yeah, I saw it via your twitter
07:01cflemingborkdude: I have a total geek crush on jetbrains
07:02dysfunthat is pretty cool
07:02dysfunshame i hate IDEs
07:02cflemingdysfun: That is a shame :-)
07:03borkdudecfleming do I understand correctly you would have to add annotations in order for it to detect possible NPEs?
07:03borkdudeit's still cool though
07:04cflemingborkdude: No, they've had that for ages. This infers what and where the annotations should be.
07:04cflemingborkdude: Depending on how well it works, it might completely eliminate NPEs in Java
07:06borkdudecfleming so you have a program in java with possible NPEs, intellij warns that you should add annotations?
07:09mbacoh wait maybe it's incanter
07:09borkdudecfleming "infer annotations" means you wouldn't have to add them, so why speak of annotations - isn't that more of an implementation detail?
07:09mbacwait maybe i should just write text to a file and use gnuplot
07:11cflemingborkdude: Right, that's a little confusing, I think they're talking about what their algorithm actually infers. As I understand it it'll infer what those annotations should be in SDK/library code.
07:11cflemingborkdude: I'm assuming it can also tell you where they should go in your own code.
07:12cflemingborkdude: I'm guessing this analysis is independent of the actual NPE checking
07:13cflemingborkdude: But if it can use the inferred ones, you're right, the annotations themselves become a little redundant except as documentation.
07:21mbaci find myself doing (map (fn [i x] [i x]) (range (count xs)) xs) a lot
07:21mbacis there something more idiomatic
07:21Bronsa,(map-indexed vector '[a b c])
07:22clojurebot([0 a] [1 b] [2 c])
07:22Bronsambac: ^
07:23mbacthank you!
08:03clj-learnerwhats the difference between (resolve 'first) and #'first
08:18dysfunoh excellent, i made java segfault
08:21rweirgold star!
08:21rweirunless it involved JNI
08:25dysfunwell, only JNI written by oracle
08:25dysfun(javafx)
08:25rweirsilver star then ;p
08:25dysfunjavafx is certainly interesting
08:26dysfuni had no idea an api could be made this infuriating
08:26rweirworse than jdbc?
08:26dysfunbut i think being able to crash a browser by loading a webpage with a simple javascript loop is quite special
08:44gfredericks,`````````x
08:44clojurebot#<StackOverflowError java.lang.StackOverflowError>
09:36hyPiRionoh, you.
09:46noncomhow do i in clojure better find the constructor for a class that I need and pass the required parameters to it? i cannot make (.getConstructors) with (.newInstance) to work with it..
09:51gfredericksnoncom: you're asking about how to find documentation on java classes, or just call a constructor, or something else?
09:51gfredericks,(BigInteger. "42") ;; calling a constructor
09:51clojurebot42
09:53gfredericks,(.newInstance BigInteger "42")
09:53clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: newInstance for class java.lang.Class>
09:53justin_smithdysfun: SagiCZ1: hash-maps and sets support conj but are not sequential
09:53gfredericks,(.newInstance BigInteger)
09:53clojurebot#<InstantiationException java.lang.InstantiationException: java.math.BigInteger>
09:53dysfun*sigh* i wonder what we could achieve with something similar to html but with an immutable DOM
09:55gfredericksnoncom: the docs for newInstance state that it won't work if the class doesn't have a zero-arg constructor
10:09rubberduckanyone familiar with core.async.impl.protocols ? in particular what's the procedure for implementing ReadPort in clojure ?
10:09rubberduckfrom what I can tell you get passed a handler and you must lock it then check if it's active and call commit with the value
10:10rubberduckManyToManyChannel implementation isn't very straightforward :(
10:12kungiCan I somehow create a globally unique symbol?
10:13justin_smith,(symbol (java.util.UUID/randomUUID))
10:13clojurebot#<ClassCastException java.lang.ClassCastException: java.util.UUID cannot be cast to java.lang.String>
10:13justin_smitherr
10:13justin_smith,(symbol (str (java.util.UUID/randomUUID)))
10:13clojurebot906eafe8-36c2-4cb7-b035-65d39983413c
10:13kungijustin_smith: Hmm ok this is possible.
10:14justin_smithglobally unique (or at least pretty damned close to it)
10:14kungijustin_smith: thanks
10:21noncomgfrederics: say i have a class with 2 constructors - 1) parameterless, 2) with some params. i want to be able to call the parametrized one, passing the parans
10:22noncomgfredericks: sorry, misspelled the nick :)
10:25noncomgfredericks: actually, my ultimate goal is to be able to find a class by its name, so that i use (Class/forName) and then call a parametrized constructor on it to get the instance... what would be the best approach for that ?
10:26gfredericks,(.getConstructors BigInteger)
10:26clojurebot#<Constructor[] [Ljava.lang.reflect.Constructor;@1b91ad7>
10:26noncom,(.getConstructors (Class/forName "BigInteger"))
10:26clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: BigInteger>
10:27gfredericks,(map #(seq (.getParamaterTypes %)) (.getConstructors BigInteger))
10:27clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getParamaterTypes for class java.lang.reflect.Constructor>
10:27gfredericks,(map #(seq (.getParameterTypes %)) (.getConstructors BigInteger))
10:27clojurebot(([B) (int [B) (java.lang.String int) (java.lang.String) (int java.util.Random) ...)
10:27noncomhmmm... thats giving some signatures !
10:27gfredericks,(def my-string-constructor (->> BigInteger (.getConstructors) (filter #(= [String] (seq (.getParameterTypes %)))) (first)))
10:27clojurebot#'sandbox/my-string-constructor
10:28gfredericks,(.newInstance my-string-constructor (into-array ["42"])
10:28clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:28gfredericks,(.newInstance my-string-constructor (into-array ["42"]))
10:28clojurebot42
10:28gfredericksso that does it I think
10:28gfredericksyou might also find a helper in the clojure.lang.Reflector class
10:28gfredericksor something to that effect
10:29gfredericksnoncom: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L150
10:29gfredericks,(clojure.lang.Reflector/invokeConstructor BigInteger (into-array ["42"]))
10:29clojurebot42
10:29gfredericksrather easier
10:32noncomgfredericks: wow!
10:32noncomgfredericks: that's it, thanks! :)
10:32gfredericksnp
11:49john________Can ask a datomic question here?
11:50AeroNotix_john________: don't ask to ask, ask.
11:52john________I hope it is not unpolite to paste in serveral lines of a datomic query code:
11:52john________[:find ?e ?name
11:52john________ :where
11:52john________ [?e :item/name ?name]
11:52john________ [?e :item/values ?ref]
11:52justin_smithuse a pastebin
11:52john________ [?ref :value/attribute ?a]
11:52john________ [?a :attribute/ident “12009”]
11:52john________]
11:52justin_smithuse refheap.com next time
11:52john________allright thanxs I do that from now on!
11:53justin_smithI'm guessing you are fairly new to IRC
11:54john________yes! quite just used it so far only a couple of times for short questions
11:54john________https://www.refheap.com/91206
11:55justin_smiththanks
12:04bbloomborkdude: i explained it to gfredericks
12:14viktar(+ 2 2)
12:14clojurebot4
12:15mbacso, it's kind of a drag that for toplevel scopes you need to use def but inside of defs you need to use let
12:17gfredericksmbac: they're pretty different
12:19gfredericksit's not just about positioning
12:20mbacwhat's different about them?
12:20mbacor, rather, why would you want them to be different?
12:20gfredericksdef is for things that can be referenced from anywhere, and they are also mutable (e.g., for code reloading)
12:20AeroNotix_mbac: let is scoped
12:20gfredericksso there's more indirection involved
12:20mbaccan't you just think of the top-level scope as the body of function that wraps the module
12:21AeroNotix_mbac: def can be accessed from outside the namespace it's being defined as well
12:21gfredericksmbac: that kind of hand-waves around how code reloading works
12:21mbacoh. hmm.
12:21justin_smithmbac: you can't, because the body of a function is immutable, and global bindings are not
12:22mbacwait so (def x 0) (def y (based-on x)) (def x 1) is a thing?
12:23justin_smithit's terrible, but it's a thing
12:23mbac:'(
12:23mbaci guess that's super useful sometimes...
12:24justin_smithmostly for development workflows, but yeah, I get pretty damn suspicious when I see it being done in code
12:26borkdudebbloom I'll have to dig up the logs then
12:29justin_smith,(name "name")
12:29clojurebot"name"
12:30justin_smithit's handy, but it surprised me
12:32bbloomyeah, especially because ##(keyword :keyword) doesn't work, nor does ##(symbol 'symbol)
12:32lazybot(keyword :keyword) ⇒ :keyword
12:32lazybot(symbol (quote symbol)) ⇒ symbol
12:32bbloomoh wow, maybe it does
12:32bbloomnevermind
12:33bbloom&*clojure-version*
12:33lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
12:33bbloomhuh
12:35justin_smith,(keyword :keyword)
12:35clojurebot:keyword
12:35justin_smith,(symbol 'symbol)
12:35clojurebotsymbol
12:36justin_smithyeah, these facts just simplified some of my code immensely
12:36bbloomjustin_smith: oh, i remember now:
12:36bbloom,(symbol 'namespace 'name)
12:36clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String>
12:36bbloomyeah
12:36bbloom:-/
12:36justin_smithahh
12:36bbloom,(keyword 'ns 'n)
12:36clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String>
12:36bbloom,(keyword 'ns "n")
12:36clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String>
12:36bbloomno good
12:37justin_smithluckily I don't need that version for my code
12:47bbloomhmm so core.async gos get GC-ed if they are waiting on channels for which nobody holds the other end... but what about threads created with clojure.core.async/thread ?
12:47dysfunis there anywhere i can read about things planned for future versions of clojure?
12:48bbloomdysfun: http://dev.clojure.org/display/design/Home
12:48dysfunthanks
12:56allenj12how does this work if conj never gets a coll? (def foo [x] (when (> x 0) (conj (foo (dec x)) x))) => (foo 5) -> (5 4 3 2 1)
12:57gfredericks,(defn foo [x] (when (> x 0) (conj (foo (dec x)) x)))
12:57clojurebot#'sandbox/foo
12:57gfredericks,(foo 5)
12:57clojurebot(5 4 3 2 1)
12:58gfredericks,(conj nil 1)
12:58clojurebot(1)
12:58gfredericksallenj12: ^^ nil is treated as an empty collection sometimes
12:59allenj12gfredericks: why do i feel like thats a bad thing?
12:59allenj12kinda goes against the philosophy nothing is nothing, an empty list is something
12:59bbloomallenj12: industry wide brainwashing?
13:00bbloomi kid though, i go back and forth on my feelings about nil :-P
13:00dysfunbecause you'd like it to not error out and a lot of things that return sequences may also return nil
13:00allenj12eh i have mixed feelings about this aswell
13:01bbloomin general, clojure handles nil reasonably sanely
13:02justin_smithallenj12: things silently returning nil are pretty pervasive in clojure
13:02justin_smith,(+ nil)
13:02clojurebotnil
13:02justin_smith,(+ :a)
13:02clojurebot#<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.Keyword to java.lang.Number>
13:03bbloomjustin_smith: (+ nil) is just garbage in garbage out
13:03bbloom+ is defined for numbers only
13:03allenj12huh
13:03justin_smithsure, but notice that it catches it with :keword
13:03justin_smithbut not with nil, that was my point
13:04bbloomjustin_smith: that's b/c nil can be a Number
13:04justin_smithsure, the pervasiveness of nils is related to the underlying jvm
13:04justin_smithnot accusing clojure here, just describing
13:04allenj12i see
13:06bbloomyeah, that's a good point: null is pervasive on the jvm already, so shouldn't fight it
13:07justin_smithfor comparison, we can look at how scala handels it http://blog.sanaulla.info/2009/07/12/nothingness/
13:07justin_smithwhich to me reads like a language designed by Heidegger or something
13:09aaelonyjustin_smith: (and "being" t
13:09aaelonyjustin_smith: (and "being" "time")
13:10justin_smithhehe
13:10aaelonyhehe ;)
13:17justin_smithjohn_______: did you ever get any help with your datomic question
13:18justin_smithor, more to the point, did you ever actually ask it?
13:19john_______@justin_smith: yes but nobody answered. I asked why this query https://www.refheap.com/91206 performs so bad. I also posted a question to the datomic user group
13:20john_______but as always I think I just have to read and learn more about how datomic handles queries
13:46dpathakj,(and “being” “time”)
13:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: “being” in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:46justin_smithdpathakj: inc clojure, smart-quotes aren't quotes
13:46justin_smith,(and "being" "time")
13:46clojurebot"time"
13:47dpathakjYeah. Looks like I just found out that my irc client is smart-quoting on me.
13:47justin_smith*in clojure
13:47borkdudecfleming namespaces that don't require core.typed won't be type checked
13:47borkdudecfleming sais ambrose
13:48john_______justin_smith Somebody helped me on the datomic IRC thanxs alot
13:49justin_smithborkdude: I can see how that would be useful actually.
13:49borkdudejustin_smith tell me
13:50viktarexit
13:50justin_smithborkdude: if I am adapting a codebase to use core.typed, that means I can work throught it one ns at a time.
13:51borkdudejustin_smith then what is the point of calling lein typed with specific namespaces
13:51justin_smithborkdude: and if I have a feature that turns into a terrible rabbit hole when I try to strictly type it, I can still typecheck all the other namespaces, even if that one would never survive the check.
13:51justin_smithborkdude: sorry, I know nothing about "lein typed"
14:23michaelr524hey
14:24pellishi all
14:24pellisis this the proper place for clojurescript q's?
14:24michaelr524here is an excersize, how would you split a constant length string to 5 parts of a given length
14:24michaelr524pellis: yeah, why not
14:25pelliswell i just tried deep diving into om and clojurescript
14:25pellisgiven around 1 month experience with clojure (but i do learn fast)
14:25pellismy last clojure code was around a year ago
14:26michaelr524[8, 4, 4, 4, 12] <- these lengths
14:26pellisi came to the conclusion that i can't really do something complex - I need some background in clojurescript first.
14:26pellisso my question is - what would be a good place to slowly introduce clojurescript into existing javascript projects?
14:26pellisis that even wise?
14:27pellisfor example - a clojurescript coffeescript hybrid ? or clojurescript on node.js?
14:28michaelr524pellis: i think the best way to start would be to build a clojurescript only project
14:28justin_smith,,(reduce (fn [[acc s] n] [(conj acc (subs s 0 n)) (subs s n)]) [[] "this is the input string, is it long enough?"] [8 4 4 4 12])
14:28michaelr524pellis: why mix in javascript?
14:28clojurebot[["this is " "the " "inpu" "t st" "ring, is it "] "long enough?"]
14:28justin_smithmichaelr524: see above
14:28pellismichaelr524: what if i feel too insecure there? should i go back to square one and invest time in learning first?
14:28michaelr524justin_smith: one sec, let me parse that
14:28justin_smithexercise for the reader: error checking for when the string runs out
14:29michaelr524pellis: just build one simple project in clojurescript - this should cure your problems :)
14:29pellismichaelr524: i can't build anything simple enough :(
14:32michaelr524pellis: why not?
14:33michaelr524justin_smith: cool, i like your solution
14:33justin_smiththanks
14:33pellismichaelr524: i guess i can't think simple enough. i've been doing complex problems for too long, that i consider everything trivial
14:33justin_smithit errors out if the input string is too short
14:33michaelr524justin_smith: i was thinking in the same direction actually.. but maybe there is a way to make it more efficient?
14:33michaelr524i wonder
14:34justin_smithmore efficient? yeah, use a transient
14:34michaelr524justin_smith: the string will always be the same size. it's an rfc compliant uuid without the '-'s
14:34justin_smitherror checking? maybe assert that the length of the string is longer than the sum of all the sizes, and if not, bail
14:34michaelr524justin_smith: i want to bring the '-' back
14:35justin_smithoh, never mind that part then :)
14:36seangroveAny way to destructure the last item in a seq?
14:36michaelr524justin_smith: it's kinda surprised me actually, i've never seen the acc in (reduce) abused in such a nice way :)
14:37Bronsaseangrove: nope
14:37seangroveBronsa: Didn't think so, but thought it might be worth it to ask - thanks
14:40justin_smith,(map identity (second (reduce (fn [[index acc s] n] (aset acc index (subs s 0 n)) [(inc index) acc (subs s n)]) [0 (make-array String 5) (str (java.util.UUID/randomUUID))] [9 5 5 5 12])))
14:40clojurebot("d1d7a603-" "e9c3-" "4c5a-" "8b27-" "65aef1b44629")
14:41justin_smiththe map identity is because arrays don't print very readably :)
14:41Bronsaseq?
14:41takemikazuchiHi guys, is this a good place to ask some basic questions? I'm a little confused about string equality in Clojure.
14:41justin_smithBronsa: ahh, of course :)
14:41justin_smithtakemikazuchi: go for it
14:42hiredmanyes
14:42takemikazuchijustin_smith: Thanks. Here's the gist: https://gist.github.com/Takemikazuchi/04d2db23a0d6437296c9
14:42michaelr524justin_smith: nice.. but think further about it, i think i'll just maybe go for the crazy stupid solution and concat the result of 5 (subs) :)
14:43takemikazuchiI mean this works like I expect: ,(= "E" (clojure.string/capitalize "E"))
14:43takemikazuchiBut the behavior changes when I'm iterating over a string, I suppose?
14:44justin_smithmichaelr524: or even construct it directly from 5 calls to subs, since it's always five elements :)
14:44justin_smithtakemikazuchi: when you iterate on a string you get characters, not strings
14:44clojurebotExcuse me?
14:44hiredmantakemikazuchi: you are comparing characters to strings
14:44takemikazuchiThanks makes sense.
14:45takemikazuchiso capitalize is returning a string
14:45hiredmanI suspect so
14:45takemikazuchiYup that was it!
14:45justin_smith,(clojure.string/capitalize \e)
14:45clojurebot"E"
14:45justin_smithyup
14:46takemikazuchiJust needed to add (str x)
14:46justin_smith,(first (clojure.string/capitalize \e)) ; second option
14:46clojurebot\E
14:47michaelr524justin_smith: exactly, that's what I was trying to communicate in my last sentence hehe
14:47justin_smithmichaelr524: ahh, OK. We have a concat function so it was ambiguous
14:48justin_smiththough in context concat would not actually make any sense...
14:48cflemingborkdude: ok, so for external annotations you'd type check the ns containing the annotations, not the actual code? Makes sense.
14:49cflemingborkdude: I should really test that!
14:49borkdudecfleming well, that wasn't what I meant. say I have a call in a namespace "other" to function f that is called with the wrong type
14:50justin_smithmichaelr524: bonus, the version with five calls of subs in a collection will be more readable too
14:50borkdudeeven when I have an annotation in namespace "other2" and typecheck "other2", it won't detect the wrong call in "other" if it didn't require core.typed
14:51borkdudecfleming If I would add the require to "other" and type check other, it will detect
14:51borkdudecfleming so that's all you have to do I think
14:51borkdudecfleming checking "current ns" doesn't work if you haven't got the require, that's what it boils down to
14:53takemikazuchijustin_smith, hired_man, thanks guys.
14:54cflemingborkdude: But if other doesn't have the require, then it can't be annotated, right?
14:54takemikazuchiGot to question 30 of 4Clojure
14:54borkdudecfleming the annotation can be in a different namespace
14:56cflemingI see. And this restriction is from core.typed itself, right?
14:56borkdudecfleming for example, this works with the require, not without: https://www.refheap.com/91211
14:56borkdudecfleming yes
14:57borkdudecfleming "works" -> "type checks"
14:59borkdudecfleming you could add a warning when someone calls "type check current namespace" when the require isn't present
15:00michaelr524justin_smith: https://www.refheap.com/91212
15:00michaelr524justin_smith: could have used a vector of the calls + join of course
15:01michaelr524justin_smith: but maybe this is more efficient :)
15:01justin_smithmichaelr524: ahh - why not a StringBuilder?
15:01justin_smithStringBuilder would be more efficient by far, I didn't realize what you were doing
15:01michaelr524justin_smith: well, there is a roumor that java automatically creates a StringBuilder when you try something like that
15:01rubberduckanyone here familiar with clojure.core.async.impl.protocols ? I'm having trouble figuring out the required semantics for ReadPort implementation since it's not documented
15:02rubberduckand the only implementation (chan) is cluttered with buffer stuff which is hard to follow
15:02justin_smithmichaelr524: I had no idea, but really using a StringBuilder directly would not be that much more complex
15:02borkdudedoesn't clojure have transient strings for that? ;P
15:02michaelr524justin_smith: I think that's the latest recommendation from the java people, instead of using a StringBuilder just concatenate your strings aways with that + operator
15:03justin_smithif java does it (as in the compiler), that doesn't help at all
15:03justin_smithclojure does not use the java compiler except when building the clojure jar
15:03michaelr524justin_smith: there is a point in what you are saying here
15:03michaelr524hmm
15:04hyPiRion,(time (do (reduce str "" (range 100000)) nil))
15:04michaelr524then probabaly a StringBuilder would be better
15:04clojureboteval service is offline
15:04hyPiRionoh, uh
15:04michaelr524eval service went out of bussiness
15:04justin_smithhyPiRion: but that's not using concat calls
15:04borkdudeinsert coin
15:04hyPiRionjustin_smith: oh, so it's concat vs. stringbuilder?
15:05justin_smithyeah, that's what we are comparing
15:06hyPiRion&(let [s (mapv str (range 10000))] (time (do (reduce #(.concat %1 %2) "" s) nil)))
15:06lazybotExecution Timed Out!
15:06hyPiRionoh whoah, you shouldn't timeout on that
15:07hyPiRionlazy bugger
15:07hyPiRion&(let [s (mapv str (range 10000))] (time (do (apply str "" s) nil)))
15:07lazybot⇒ "Elapsed time: 8.555949 msecs" nil
15:07hyPiRionstr is using stringbuilder internally
15:07mbac(defn save-sexp [d f] (with-open [w (clojure.java.io/writer f)] (.write w (binding [*print-dup* true] (prn d)))))
15:08mbacis that no longer the right way to serialize stuff?
15:09justin_smithhyPiRion: oh, cool
15:11michaelr524ok then
15:11michaelr524I've updated the paste
15:11michaelr524https://www.refheap.com/91212
15:11dbaschamalloy justin_smith I got that geohash code to be “only” 1.8x as slow as the java version
15:11justin_smithdbasch: awesome, what did it take?
15:12dbaschturns out bit-flip and bit-test are pretty inefficient
15:12justin_smithwow, I had no idea
15:14dbaschjustin_smith: in my benchmark (bit-flip x n) takes twice as long as (bit-xor x (bit-shift-left 1 n))
15:41dbaschjustin_smith: plus there was some random sillines, e.g. (+ lo (/ (- hi lo) 2)) instead of (/ 2 (+ hi lo))
15:41dbaschsilliness
15:43dbaschthis is what I have so far https://www.refheap.com/91217
15:44dbaschit has room for improvement
16:10arrdemdbasch: isn't locate [double double double long] -> long?
16:10arrdemclojure.lang.IFn$DDDLL exists
16:10arrdemcould be worth something
16:11dbaschI’ll try
16:13dbaschnot sure if that type hint makes a difference, it seems to get lost in the noise
16:14arrdemdbasch: yeah looking at that it should get lost in the noise.
16:14arrdemdbasch: hinting the return type would only help if it were called in a tight loop, and it isn't.
16:15dbaschas it is it takes about 700ns on my machine, compared to 11us for the original function and 400ns for the java version
16:17dbaschthe one thing I don’t understand is why bit-flip seems so slow compared to the hand-rolled alternative.
16:18Bronsadbasch: it's not inlined so it always gets compiled to flipBit(Object,Object)
16:19Bronsadbasch: replacing (bit-flip x n) with (clojure.lang.Numbers/flipBit x n) should make it fast
16:20dbaschBronsa: I’ll try that, it would make that code more clear
16:20dbaschbut that’s the kind of function that should be inlined
16:20Bronsait's unfortunate that not all the stdlib has :inline metadata where it would make a difference
16:20Bronsayeah
16:21dbasch(inc Bronsa)
16:21lazybot⇒ 53
16:21BronsaI have a ticket that adds :inline metadata to most of the predicate functions in core, but I doubt it's ever going to make it in
16:22arrdemstory of jira...
16:23Bronsaarrdem: not as much as jira as the Rich deciding :inline will no longer be used
16:24Bronsaarrdem: Alex told me that :inline is deprecated and will no longer be added to functions in core
16:24Bronsadeprecated in favour of compiler macros -- which don't exist yet.
16:24arrdemsounds about right
16:25BronsaI really don't understand why we can't leverage :inline and replace it later with those, when they'll actually be a thing
16:25arrdemwhat's the word on those. 1.8 ish? not even seeing anything on google or in the logs for em.
16:26Bronsaarrdem: they're in the Release.Next page so maybe they'll make it in for 1.7, but who knows
16:27Bronsaarrdem: http://dev.clojure.org/display/design/Inlined+code
16:29arrdemBronsa: hum... could probably do that in like... a week for Oxcart/TEJVM
16:31BronsaI would experiment with them if I saw the need for them, but I fail to see the limitation of :inline. I get that definline sucks because it requires eval, but :inline is fine for me. w/e
16:32arrdem:inline/definline is a hack IMO due to lack of a real constant folder/partial evaluation engine. It works, but it's just a hacky implementation of a special case that Rich decided was worth caring about.
16:33Bronsaactually if I have to be honest :inline kinda sucks too because it requires metadata to be evaluated at analysis time.
16:34arrdem'tbaldridge was ... pursuasive that a partial application engine probably wasn't worthwhile generally but you're right in primitive type cases like this it really can pay off
16:34arrdemidk
16:34arrdemI was planning on doing one and it didn't happen
16:34arrdemdown that path lies loop unrolling and inlining heuristics. and madness.
16:36gfredericksclojurebote: down that path |lies| loop unrolling and inlining heuristics. and madness.
16:37gfrederickshwhoops.
16:37gfredericksclojurebot: down that path |lies| loop unrolling and inlining heuristics. and madness.
16:37clojurebotOk.
16:37cflemingBronsa: don't get me started on definline - I still don't understand why there's so much resistance to supporting/using it
16:37cflemingBronsa: Especially now that there's a fix to the main known problem - many thanks for that!
16:38Bronsacfleming: yeah I really don't get it either
16:39Bronsacfleming: TBH I thought that by fixing that AOT compilation bug clojure/core would reconsider its stance on definline, I was kind of baffled when they didn't change stance on it
16:39arrdemBronsa: hum so CL's DEFINE-COMPILER-MACRO defines/allows a second round of declinable form rewriting before code gen?
16:40justin_smith~down that path
16:40clojurebotdown that path lies loop unrolling and inlining heuristics. and madness.
16:40cflemingBronsa: Yeah, me too. At least I can use it in my own code now though.
16:40arrdemjustin_smith: good thing I'm already mad then
16:40Bronsaarrdem: yeah something like that
16:41Bronsaarrdem: in t.a speak, it's just extending the -analyze multimethod for 'function-name
16:41ustunozgurhi there, a java interop question: (new (.getClass "test1") "test2") doesn't work. is there a way to achieve something like this without reflection?
16:41Bronsacfleming: so you're using a patched clojure?
16:41arrdemBronsa: ehrm... yeah because this occurs at the form level not at the analyzed AST level
16:42gfredericksustunozgur: your example seems inherently reflective
16:42Bronsaarrdem: yep
16:42arrdemBronsa: which actually makes this less powerful because you aren't exporting all the analysis stuff.
16:42arrdemBronsa: you can't look at closed overs and soforth
16:42ustunozguryes, gfredericks (assert (= String (.getClass "Test"))) (new String "test") works though.
16:42Bronsaarrdem: uh? you get &env and nobody prevents you from calling analyze on &body
16:42ustunozgurmaybe because it's a special form.
16:43Bronsaarrdem: cljs does something like this already
16:43ustunozgurnot sure where I would need this though, just tinkering.
16:43gfredericksustunozgur: yeah new is a special form; if you don't have the class name at compile time, it's inherently reflective
16:43Bronsaarrdem: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj#L260-L276 as an example
16:43cflemingBronsa: Yeah, although I haven't applied that patch yet. I will do as soon as the patch stabilises - I've been running with the patch from http://dev.clojure.org/jira/browse/CLJ-1315 since it came out.
16:43arrdemBronsa: I guess. I'd just lean towards exposing the analyzed AST for user definable transforms because almost anything interesting is gonna try to get tha tinformation anyway.
16:44ustunozgurgfredericks: OK, thank you.
16:44arrdemcfleming: how's the patched verison of Clojure thing working for you? it's been tempting me for a while now.
16:44BronsaI've done that, it gets old really fast
16:44Bronsacommits in clojure master break everything
16:45gfrederickswhat are we patching for?
16:45cflemingarrdem: It's working well for me, I'm still running 1.5.1.
16:45Bronsaand you're left trying to manually merge everything
16:45arrdemgfredericks: rabble rabble rabble
16:45cflemingarrdem: Everyone using Cursive is using a patched version.
16:45Bronsacfleming: ssssh they don't need to know
16:45arrdemBronsa: interesting example. thanks.
16:46gfredericksah
16:46cflemingBronsa: Hehe, yes, my lips are sealed.
16:46arrdemlol @ ninja patched version
16:46gfrederickshow do you convince leiningen to use a patched version? do you have to exclude clojure from every dep?
16:46gfredericksis there a global exclude feature?
16:46cfleminggfredericks: I use Ant. It doesn't take much convincing.
16:46Bronsaarrdem: that's a really nice example actually, I've tried moving that transformation to the AST level as a pass, and it's way easier to do it this way
16:46gfrederickscfleming: that is the first time anybody has told me that.
16:47Bronsagfredericks: just exclude org.clojure/clojure and include my.clojure/clojure
16:47gfredericksBronsa: so leiningen *does* have a global exclude?
16:47arrdemgfredericks: not that I'm seeing. you have to roll it manually.
16:47gfredericksI guess a plugin could do the dirty work
16:47arrdemthis is actually the primary reason why I've never used org.oxlang/clojure for anything...
16:48Bronsagfredericks: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L63-L66
16:48arrdem(inc Bronsa)
16:48lazybot⇒ 54
16:48gfredericks(inc Bronsa) ;; semiprimes are cool
16:48lazybot⇒ 55
16:48Bronsalet them rain
16:49arrdem(dec Bronsa) ;; karma/minute rate exceeded
16:49lazybot⇒ 54
16:49johnwalker(inc Bronsa)
16:49lazybot⇒ 55
16:49gfredericksBronsa is going to win an award for karma thrashing
16:49BronsaI know how a rubberband feels now
16:50arrdemhe's got a loooong way to go before catching up with amalloy..
16:50gfredericks~amalloy
16:50clojurebottry that; it won't work
16:51gfredericksclojurebot: clojurebot is a jukebox for amalloy's greatest hits
16:51clojurebotIk begrijp
16:52m1dnight_Dutch \o/
17:00arrdemI guess the issue is when if ever does a patched verison of Clojure pay for itself...
17:01gfredericks...when you get the feature you need?
17:01gfrederickswhich is immediately?
17:01arrdemno as in what features could not be added as libraries.
17:01arrdemso.. lets say I wanted a library that adds clojure.core/seqable?
17:01gfrederickssome of them
17:02gfredericksprobably mods to the compiler mostly?
17:02arrdemprobably...
17:02arrdembut even then TEJVM is almost good enough, just drag that in and mod it
17:04gfredericks$google TEJVM
17:04lazybot[CPU count confusion | VMware Communities] https://communities.vmware.com/message/2334874
17:04arrdem$google clojure.tools.emitter.jvm
17:04lazybot[clojure/tools.emitter.jvm · GitHub] https://github.com/clojure/tools.emitter.jvm
17:05gfredericksoh hey right
17:05arrdemthat thing that Bronsa and I were working on. all summer.
17:05gfredericksworked on so hard you needed some seriously optimized acronyms
17:06arrdemthat's actually the dev.clojure.org/jira name :/
17:06gfredericksoh I like those acronyms actually
17:06gfredericksI just don't know them all
17:07gfredericksI've been working on TCHECK and NREPL lately
17:10takemikazuchiAnyone wanna give me some feedback? I'm working through 4clojure problems: Problem: https://4clojure.com/problem/31 My solution: https://www.refheap.com/91221
17:11justin_smithtakemikazuchi: conj takes varargs, so you don't need to wrap a call to conj in another call to conj
17:11justin_smith,(conj [] :a :b)
17:11clojurebot[:a :b]
17:12gfredericks,(conj [] conj conj (conj))
17:12clojurebot[#<core$conj clojure.core$conj@d4f698> #<core$conj clojure.core$conj@d4f698> []]
17:12justin_smithlol
17:12gfredericksactually
17:12gfredericks,(conj (conj) (conj) (conj) (conj))
17:12clojurebot[[] [] []]
17:13arrdemrofl
17:14takemikazuchijustin_smith: in that case I believe I need to as last of x is a collection that I want to insert y into.
17:16justin_smithahh, I misread, you are right
17:17justin_smithwell, style wise, if you are using pop, then use peek and not last
17:17justin_smithpeek/pop butlast/last
17:17justin_smith(first/rest)
17:18gfredericks+/-, *//, concat/deconcat swap!/unswap!
17:19justin_smithheh
17:19justin_smithwe need unswap!
17:19gfrederickslaunch-missiles/return-missiles
17:19takemikazuchijustin_smith: That makes sense, peek does seem more natural there.
17:20justin_smithgfredericks: deconcat is clearly (rand-nth [partition partition-all partition-by])
17:20gfrederickssplit-at
17:21gfrederickssplit-with
17:21justin_smithoh yeah, those too
17:21gfredericks(juxt take drop)
17:27dbaschdeconcat randomly partitions a sequence so that all possible partitions are equally likely
17:28arrdemyou could actually define a Concat type and a sane deconcat operator...
17:28gfredericks,(defn deconcat [coll] ((juxt take drop) (rand-int (inc (count coll))) coll))
17:28clojurebot#'sandbox/deconcat
17:28gfredericks,(deconcat (range 10))
17:28clojurebot[(0 1 2 3 4 ...) ()]
17:28gfredericks,(deconcat (range 10))
17:28clojurebot[(0 1 2) (3 4 5 6 7 ...)]
17:29dbaschgfredericks: that’s all splits, I mean all possible partitions from all n elements to a single collection
17:34arrdemso looks like we define concat in terms of a lazy sequence of cons...
17:34arrdemcould probably have a Concat type with a seq of subsequences
17:34arrdemthen deconcat is trivially the sequence of subsequences
17:38justin_smitha version of deconcat https://www.refheap.com/91223
17:38takemikazuchiAnyone who knows ruby here, is it safe to say Ruby's foo(*bar) and Clojure's (apply foo bar) are functionally equivalent?
17:40dbaschjustin_smith: but the empty subsequences…
17:40amalloytakemikazuchi: yes, they are the same general idea
17:40justin_smithdbasch: they are all valid inputs that return the original sequence if you apply concat
17:41justin_smithfeel free to change the (rand-int n) to (inc (rand-int (dec n))) of course
17:42takemikazuchiamalloy: Thanks. Any significant differences I should keep in mind?
17:43amalloytakemikazuchi: not really. some nice stuff like apply is a function, so you can do something silly like ##(map apply [+ -] [[1 2 3] [21 7 2]])
17:43lazybot⇒ (6 12)
17:44amalloyi suppose (partial apply +) would be a more common example
17:44amalloy(def sum (partial apply +))
17:47hiredmanpartial apply + 0
17:52gwstakemikazuchi: can the splat be used on something akin to ##(apply + (range 10))
17:52lazybot⇒ 45
17:53gwse.g. a hypothetical sum function that takes a variable number of arguments: sum(*[0..9])
17:53H4nsin compojure, is there a way to pass both the body-params and a url param to a handler? apparently, if i use vector syntax, i can only access the url parameters (/bar/:foo), whereas when i use map syntax, i can't access the url parameters.
17:53H4ns(i want to have a PUT handler which has the ID in the url and the updated data in the request body)
17:54amalloygws: yes, that is like the only thing that splat can do
17:56dbaschjustin_smith: check this one out https://www.refheap.com/91226
17:56gwsamalloy: i don't know ruby that well, but i created a vararg sum function and it works when i pass multiple args but with *[0..9] i get "Range can't be coerced into Fixnum" on ruby 2.1.0, so that's why i asked
17:56dbaschlazy, uniform random partition
17:59justin_smithinteresting, so it has 50% chance of size 1, 25% of size 2, 12.5% of size 3 etc. (modulo the bail out if size is greater than remaining contents)
18:00justin_smithwhereas mine was even within range of size of coll (with same bailout condition)
18:00amalloygws: that's not the syntax for rangers. it's just a really weird number
18:00amalloy*ranges
18:00justin_smithamalloy: time for the ad&d based dsl for sequences
18:00takemikazuchigws: Yeah I mean the analogy starts to break down at that point I supppose
18:00dbaschjustin_smith: and mine doesn’t even care about the seq size, or if it’s finite
18:01justin_smithright
18:01dbasche.g. (take 10 (random-partition (range)))
18:01takemikazuchilol you end up with something like this: lambda{|*x| x.inject(:+) }.call(*(1..9).to_a)
18:01amalloygws: you want (1...9)
18:01amalloytakemikazuchi: eh? you don't need the to_a
18:01takemikazuchiamalloy: yeah just noticed that.
18:02amalloydef sum(*xs) xs.inject(:+) end; sum(1...9)
18:02amalloyor something like that
18:02amalloythere. def sum(*xs) xs.inject(:+) end; sum(*(1..9))
18:03dbaschjustin_smith: the 1/2 chance is to guarantee uniformity
18:04dbaschcan’t think of a better way off the top of my head
18:04justin_smithright, just observing the behavior
18:05justin_smithcould have as easily been thirds (1/3 chance of size 1, 1/6 of size 2, 1/12 of size 3, etc.)
18:05dbaschjustin_smith: but then it wouldn’t be uniform
18:06dbaschI wanted all possible partitions to be equally likely
18:09dbaschthat would be an awful interview question btw
18:11dbaschI should create a library called useless, in the spirit of amalloy’s useful
18:12dbaschthis could go in there
18:13dbaschalong with a macro that makes code fail randomly
18:13dbaschactually that’s not useless
18:16amalloydbasch: the classic backwards-mode macro belongs there
18:17amalloy(defmacro backwards [& body] (cons `do (postwalk (fn [x] (if (seq? x) (reverse x) x)) body)))
18:19gfrederickswithout-redefs
18:20dbaschwith-open-or-dev-null
18:20dbaschmaybe-off-by-one-loop
18:21dbaschthread-somewhere
18:21dbasch-???>
18:22dbaschaka as the magical mystery arrow
18:23dbaschalso aka as
18:24justin_smithdbasch: how is 50% chance of size 1 etc. more uniform than 33% chance of zie 1 etc. ?
18:24dbaschjustin_smith: because there are 2^n partitions
18:25dbaschso for example the one with all the elements must occur when you get n tails in a row
18:25dbaschtechnicall 2^(n-1)
18:26justin_smithdbasch: clearly there is something I don't yet get about statistics underlying all this
18:26dbaschtry for example (frequencies (take 10000 (repeatedly #(random-partition (range 4)))))
18:27dbasche.g. for (0 1 2) you have four possibilities
18:27dbaschyou want to choose ((0 1 2)) with 1/4 chance
18:28cflemingarrdem: Without running the patch that I'm running, I can't compile my project
18:28cflemingarrdem: So for me the payoff was pretty immediate.
18:29cflemingarrdem: That said, technically I only need my patched version to actually compile, not at runtime.
18:38gfredericks,(partition-by (fn [_] (rand-nth [true false])) '(0 1 2))
18:38clojurebot((0 1) (2))
18:38gfredericks,(partition-by (fn [_] (rand-nth [true false])) '(0 1 2))
18:38clojurebot((0) (1) (2))
18:38gfredericks,(partition-by (fn [_] (rand-nth [true false])) '(0 1 2))
18:38clojurebot((0 1) (2))
18:38gfredericks,(partition-by (fn [_] (rand-nth [true false])) '(0 1 2))
18:38clojurebot((0) (1) (2))
18:38gfredericks,(partition-by (fn [_] (rand-nth [true false])) '(0 1 2))
18:38clojurebot((0 1) (2))
18:38gfrederickso_O
18:39gfredericks,(repeatedly 8 (fn [] (partition-by (fn [_] (rand-nth [true false])) '(0 1 2))))
18:39clojurebot(((0) (1 2)) ((0 1 2)) ((0 1) (2)) ((0) (1 2)) ((0) (1 2)) ...)
18:39gfrederickslooks legit
18:40justin_smith(inc gfredericks)
18:40lazybot⇒ 91
18:40justin_smiththat's the one
18:41tuftanyone know how to do a "where in" style query in datomic? i.e. get entities where an attribute value is one of several
18:41dbaschyes, that’s nicer
18:53AeroNotix_does/can timbre rotate log files?
18:57lodinAnyone know how to restart an nrepl server so that all defs etc are gone? I tried (do (stop-server s) (start-server)) but that didn't help.
18:58justin_smithlodin: defs are not local to the nrepl server
18:58justin_smiththey are global to the clojure process
18:58lodinOh.
19:02lodinThat actually makes a lot of sense. :-)
19:07lodinIs there any tool to start/stop isolated clojure processes easily (which I then can access using nrepl)? I think I've read about such a tool.
19:09justin_smithhttp://leiningen.org/grench.html there is grench, I don't know isolated it is
19:10truebuddiquick question here at http://pastebin.com/hpFqRFJ7
19:13jkjworking with clojure and sampling large data objects, i'd be happy if i had a ide and a repl that wouldn't choke on a few kilobytes of text
19:14jkjwonder if there is a middleware to protect emacs from accidentally printint something that takes all the cpu for couple of minutes
19:15justin_smithjkj: iirc the issue is that it applies regexes per line, so lack of line breaks make it freak out
19:15jkjok
19:16jkjjustin_smith: good to know
19:18jkjhmm. maybe the trick would be to redirect all the output to something that can take it. web browser maybe
19:19justin_smithjkj: you could set debug-on-signal, and then send a signal to emacs via kill in a command line
19:20justin_smithjkj: then in the debugger you can see what the hell it was doing
19:20jkjjustin_smith: thx
19:20justin_smithsending problematic output to a text file and opening it in emacs in auto-tail-mode is another option
19:20justin_smithit will scroll down as new content is created, but not do the CPU heavy shit it does in the repl buffer
19:21justin_smithsorry it's called auto-revert-tail-mode
19:21justin_smithor something like that - it is like tail -f but in an emacs buffer
19:21justin_smithwatches the file and reloads every time it sees a change
19:22justin_smithyou could use proper logging, and then open the log file using auto-rever-tail-mode
19:22alexbaranosky_bbloom :snapshot sounds like a good idea
19:23lodinjustin_smith: I found https://github.com/projectodd/shimdandy. Unfortunately I can't use it via clojure itself. :-)
19:23jkjoops. HUP was a bad idea :D
19:23justin_smithjkj: oops
19:28bbloomalexbaranosky_: it certainly is :-) works out nice too if your variable is a map, which is a good idea anyway so you can assoc/update-in on each recur, rather than muck with positional arguments
19:28jkji'm not quite sure if printing huge amounts of data slowly or lagging when handling big buffers is really a problem or just trying to misuse emacs
19:29justin_smithjkj: it's a problem with the repl buffer, that won't come up in a buffer in plain text mode
19:29jkjjustin_smith: ok
19:29justin_smithdo you mean it is lagging for big non-repl buffers?
19:29tuftany ideas on testing set membership for an attribute value in datomic? searched all over with no luck
19:30justin_smithjkj: if so, in clojure mode or in general?
19:30cflemingjkj: if you're an IDE sort of person, Cursive handles lots of output pretty well.
19:31jkjcfleming: haven't tried that.
19:33arrdemcfleming: fair
19:34cflemingarrdem: I had a hideous Rube Goldberg machine hooked up just to be able to compile until I applied that patch.
19:35jkjDebugger entered--Lisp error: (wrong-type-argument symbolp [object ede-project-autoload ....
19:35jkjquite strange place where it hits after signilng
19:36arrdemcfleming: what patch did you need that badly?
19:36arrdemcfleming: I have a list of bugbears with Clojure, but nothing that actually stops me getting work done
19:36jkjit seems to finish the print and then give backtrace of something else
19:36jkjso doing what is does does not stop on signal
19:36cflemingarrdem: http://dev.clojure.org/jira/browse/CLJ-1315
19:37arrdemcfleming: gotcha
19:37cflemingarrdem: Without that patch, I had to bring up the IntelliJ test infrastructure (~45 secs) and compile inside it.
19:38jkjnow i have stuff in repl buffer and pushin any key takes about 1,5 sek for the character to appear
19:38arrdemcfleming: lol
19:38cflemingarrdem: And then shower afterwards, which also takes time.
19:38jkjany ideas on seeing what it does?
19:38truebuddisorry if already replied .. disconnected earlier but was asking about splitting (-> .... ) into multiple forms.. http://pastebin.com/hpFqRFJ7
19:39bobpoekertWhat are people using for single-machine k-means clustering these days?
19:39bobpoekertStill Weka?
19:39cflemingarrdem: What's the status of TEJVM these days?
19:40cflemingarrdem: Is it realistic to use it to compile?
19:40arrdemtruebuddi: you need to be threading that request. right now you ignore it. line 19
19:40arrdemtruebuddi: in future please use refheap, because Raynes made it, it's awesome and it doesn't have ads.
19:41truebuddigoogling refheap
19:41arrdemcfleming: TEJVM totally works, Oxcart is sketchy at best however
19:41truebuddiarrdem: thank you will do
19:42arrdemcfleming: the main restrictions with TEJVM are either actual bugs in core (incorrect annotations) or just performance. Bronsa has gotten it down to ~15x clojure.core/compile from ~25x but it's still slow.
19:43arrdemcfleming: I never had issues when building Oxcart that weren't of my own doing.
19:43cflemingarrdem: That's probably ok for a production build if it makes a different though.
19:43cflemings/different/difference/
19:43arrdemcfleming: oh. TEJVM can't do AOT yet. Oxcart can, but I never backported the infrastructure for Bronsa
19:43cflemingarrdem: Ah.
19:43arrdemcfleming: that's another killer
19:44bobpoekertSearching around for clustering implementations there's a bunch of stuff that hasn't been updated in years and isn't in maven, adn Weka
19:44bobpoekertand stuff like MALLET which is NLP-specific
19:44arrdemone of these days I'll have free time and PR it... but not today
19:44cflemingarrdem: Did you look at skummet at all? It looked interesting as well and sounds like it was quite successful.
19:44truebuddiarrdem: I changed it to https://www.refheap.com/91230 but still getting cemerick.friend$authenticate$fn__379 cannot be cast to java.util.Map
19:45arrdemtruebuddi: you have a type error somewhere. you are passing a function where it expects a map. more than that I cannot trivially surmise.
19:46kenrestivo~tejvm
19:46clojurebotIt's greek to me.
19:46kenrestivome too
19:46arrdemtruebuddi: I would guess line 12
19:46arrdemtruebuddi: check your arguments order with ->
19:46arrdemcfleming: meh totally not biased in this or anything but I think that skummet is a hack/wrong approach
19:47arrdemcfleming: have you seen my end of summer blag post?
19:47cflemingarrdem: Sure, but it's one that might produce decent gains with relatively little work.
19:47cflemingarrdem: No, got a link?
19:48arrdemcfleming: http://arrdem.com/2014/08/05/of_oxen,_carts_and_ordering/
19:48arrdemcfleming: https://groups.google.com/forum/#!topic/clojure-dev/dSPUNKSaV94
19:48arrdemcfleming: those two pretty well capture my takeaway from this summer
19:49cflemingarrdem: Ah, I lie, I did see the mailing list post. I think the proposal to split out core sounds good.
19:50arrdemno way it's gonna happen.. but it would be nice
19:50arrdem^ one line summary of my summer :/
19:51cflemingarrdem: I didn't realise that one of the main benefits of Oxcart was to remove var indirection - nice.
19:53truebuddiarrdem: converting the defn to a def worked ... https://www.refheap.com/91230 thanks!
19:54arrdemcfleming: as I argued in the clj-dev post, skummet and "lazy loading" can only approximate an actual tree shaking compiler, and do so at the cost of creating a difficult to maintain fork of Clojure.
19:55arrdemcfleming: if the world were flat and I had my way, we'd do lib-clojure and then Mikera and I would be free to build crazy clojure-like fast languages
19:55arrdembut it isn't
19:55cflemingarrdem: Yeah, no doubt. I'd love to be able to make a totally static production build of Cursive for deployment though.
19:55cflemingarrdem: I guess there's nothing stopping you doing it except time and money, right? :-)
19:56justin_smithjkj: not sure actually, if just seeing where it was when you interrupted did not help
19:56justin_smithjkj: #emacs could have some ideas
19:57arrdemcfleming: basically. mainly money as it can buy time... if someone wanted to foot the bill for this I'd be delighted to say fuckit, maintain my lib-clojure fork and keep working on Oxcart but GSoC is over
19:57arrdemcfleming: that and I think if you're gonna statically compile Clojure may as well take the time to clean up some warts
19:58arrdemI have a project that's my sketch of doing so, but it doesn't work and I'm not sure it'll ever exist so I'll refrain from advertising it here.
20:00cflemingarrdem: I'd be interested in hearing about it - are you going to the conj?
20:01arrdemcfleming: I probably will but I don't have plans yet.
20:01cflemingarrdem: Ok, I'll buy you a beer if you make it and you can tell me about it.
20:01arrdemcfleming: haha you're on
20:02arrdemafter seeing all the cool stuff from strangeloop I'd be crazy to miss the conj... but classes and stuff
20:03cflemingarrdem: Yeah, I have to make it to strangeloop one of these days, it looks amazing.
20:04cflemingarrdem: Almost more interesting than the conj actually, more eclectic
20:04arrdemcfleming: yeah it was really interesting to see all the hot stuff from different languages and communities. I've been looking at the conj schedule and due to having a single track there's something for everone
20:17bobpoekertI found a library that was updated this year! The documentation is all in japanese.
20:18bobpoekertoh, and it only works on 2d vectors :(
20:18TEttinger(inc Japanese)
20:18lazybot⇒ 1
20:19TEttingerwhat are you looking for, bobpoekert? something in core.matrix?
20:19bobpoekertsomething that can take 27-dimensional
20:19bobpoekertvectors of reals
20:19bobpoekertand turn them into a k-means tree
20:19bobpoekertwhether it's in core.matrix or not I don't really care
20:21justin_smith(inc 日本の)
20:21lazybot⇒ 1
20:22TEttingerI saw a japanese version of https://github.com/joshuaeckroth/clj-ml
20:23justin_smithbobpoekert: this looks a little dated, but it does look like what you are looking for http://www.informatik.uni-ulm.de/ni/staff/HKestler/parallelkmeans/
20:24justin_smithit's not really idiomatic as a clojure project, but it is doing k-means and has source code you can start with
20:24bobpoekertTEttinger: I was referring to https://github.com/satoh-disk/k-means
20:29TEttingerthere seem to be a bunch of leads. https://github.com/elben/k-means
20:30bobpoekertthat's 2d
20:30bobpoekertjustin_smith's suggestion might work
20:30TEttingerI am not familiar with k-means at all, so I'd go with justin_smith's then. I also found https://github.com/codyrioux/kmeans-clj
20:31bobpoekertnumeric processing with core.async???
20:31lazybotbobpoekert: Oh, absolutely.
20:34bobpoekertit should really be more common knowledge that (apply min-key …) is argmin
20:34bobpoekerttook me a long time before I found that out
20:34bobpoekertmin-key and max-key are really confusingly names
20:34bobpoekertnamed
20:37justin_smithyeah, I wonder what the origin of the current names is?
20:49gfredericksmin-by and max-by would be less surprising I guess?
20:54justin_smithor argmin and argmax, which is what they are called in math
20:54hodlrin order to pull in java libs into my project what do i need to enter into project.clj from the pom.xml ?
20:54justin_smithhodlr: [group/project "version.id"]
20:55justin_smitherr, that was sloppy
20:55justin_smith[groupId/artifactID "version"]
20:56hodlrjustin_smith: thanks :)
20:56gfredericksjustin_smith: I'm kind of surprised I never noticed those names in math
20:57justin_smithgfredericks: http://en.wikipedia.org/wiki/Arg_max
20:58justin_smithit's the only standard name for the function I know of
20:58justin_smithI guess technically arg-min and arg-max could be like min-key / max-key but take collections and return sets
20:59justin_smith(the set of all items returning the minimum value)
20:59justin_smith(or maximum)
20:59gfredericksHUH.
20:59gfredericks(inc justin_smith)
20:59lazybot⇒ 85
21:00justin_smithactually planet math is usually a better source than wikipedia http://planetmath.org/argminandargmax
21:02justin_smithactually, to be most mathematically correct, we could (intern 'clojure.core (symbol "arg max") #(hash-set (apply max-key %)))
21:02justin_smithbut it would be a pain in the ass to use something with a name like that in actual code
21:03justin_smith,(intern *ns* (symbol "arg max") #(apply max-key %&))
21:03clojurebot#'sandbox/arg max
21:04gfrederickssomebody at work was asking about the behavior of ##(keyword "foo bar") and why it doesn't throw
21:04lazybot⇒ :foo bar
21:04gfredericksdoes anybody know if the answer is A) only backwards compatibility, B) speed (from not checking), C) something else?
21:04justin_smithwe've had similar discussions around here
21:05TEttinger,((keyword "Oh yeah: I heard the best news!") {(keyword "Oh yeah: I heard the best news!") "Oh really?"})
21:05clojurebot"Oh really?"
21:05TEttingerthey certainly are valid
21:06justin_smith,(intern *ns* (symbol "arg max") (fn [key sq] (apply max-key key sq)))
21:06clojurebot#'sandbox/arg max
21:06justin_smith,((resolve (symbol "arg max")) #(* % %) [-10 1 2 3 4])
21:06clojurebot-10
21:06gfrederickssure but there are uses where they don't
21:07gfrederickse.g., if you like to just blindly parse your json into keywords, that might work okay most of the time, but as soon as you start using cascalog or storm things break
21:07gfrederickssince they're serializing things behind the scenes
21:07justin_smithright. and the blindly parsing json into keywords thing may just be the source of the permissive behavior?
21:08gfredericks"source of"?
21:08justin_smithmaybe "a justification for"
21:08justin_smithsloppy wording
21:09gfrederickswell it certainly sets up the "changing this would break lots of code" argument
21:10gfrederickswhich I figured is a good enough explanation for not expecting anything to change at this point; but I wasn't sure if it was universally regretted or not.
21:13justin_smithtangentially, I wonder if something related to this (any string becoming a symbol / keyword) couldn't have been exploited to make gensyms a bit stronger (eg. rendering them unreadable)
21:13justin_smithI think I meant ie.
21:17gfrederickshaha that's clever
21:17gfredericksso they're guaranteed to not clash
21:17gfrederickscould make some fringe uses more difficult though
21:18justin_smithyeah
21:18bbloomgfredericks: it's speed / not bothering to do error checking b/c it's hard
21:18bbloomand of course can't change now b/c ppl depend on broken behavior
21:18bbloombut keywordizing strings when parsing json is a universally bad idea without a known schema
21:19bbloomand a marginally bad idea with a schema too :-P
21:22gfredericksbbloom: error checking isn't hard in this case, is it? just arm thyself with a decent regex?
21:22bbloomgfredericks: problem isn't "this case" it's universally
21:23bbloomif you make a promise to check your arguments for validity, you get in to the whole type systems, contracts, schemas, etc etc etc forever
21:23bbloomseems the line for clojure was drawn: "only check arguments when there's a high likelihood that somebody will fuck up AND it doesn't slow the whole thing down"
21:24bbloom"but mostly only when a macro will eat the line numbers of your stack trace"
21:24bbloom:-P
21:30Wild_Catwhile we're on that topic, I'm curious, why was the decision taken to keywordize strings?
21:31gfredericksbbloom: coolthx
21:31gfredericksWild_Cat: in what case?
21:32Wild_Catgfredericks: JSON deserialization.
21:32justin_smiththat's optional
21:32justin_smithalways has been
21:32Wild_Catwait, it is?
21:32bbloomthere's a keywordize? argument
21:32Wild_Cathrmm. I'm misremembering. Disregard my question and carry on, then.
21:33Wild_Catit's been too long since I got the occasion to write actual Clojure code.
21:33bbloomthe argument is discussed in the api docs
21:33bbloombut not the readme
21:33bbloombut it should be :-P
21:36gfredericksbbloom: I'm looking for such an argument in the cheshire docstrings but can't find it; is that where you were referring to?
21:37bbloom core.data.json
21:37bbloomi assumed that's what Wild_Cat was referring to
21:37bbloomsorry
21:37Wild_Catbbloom: it was.
21:37bbloomoh then NOT sorry :-)
21:41bbloomgfredericks: the read-json function
21:44gfredericksbbloom: oh dear I think I misinterpreted the word "argument"
21:44bbloomgfredericks: ha! seems you need some sleep my friend
21:44gfredericksthis morning I slept in till 6:30
21:44hugoduncanin cheshire you can pass in an arbitrary function to apply to keys
21:50justin_smithhugod: which could as easily be a validator as a keywordizer :)