#clojure logs

2015-06-05

00:00crocketgfredericks, Why doesn't https://www.refheap.com/102108 work?
00:01crocket(if-let [a 2] (if-let [b 2] [a b])) is going to evaluate to [a b]
00:01crocketIt's like (if-let [[a b] [a b]] "ok" "no")
00:03crocketWhy does (if-let [a 2 b 3] a b) not work?
00:04crocketWhy does (if-let-all [a 2 b 3] a b) not work?
00:09crocketok
00:09crocketI understood why it doesn't work.
00:12crocketI need something like https://www.refheap.com/102109
00:14crocketAll right....
00:17turbofailer, i don't think that's quite what you want either
00:18turbofailthen again i just got here so i'm not entirely certain what it is you want
00:20turbofaili think that macroexpansion would always return either else or nil
00:21turbofailand never then
00:26crocketWow it works....
00:26crockethttps://www.refheap.com/102107 works
00:27crockethttps://www.refheap.com/102107 does what I want.
00:28turbofailah yeah, that looks more like it
00:42crocketI forgot to give credit to "Gary Fredericks"
00:43crocketDon't worry I will mention your name in a reply.
02:02m1dnight_Is there somethig like compare-and-set! but with multiple values, or a custom predicate?
02:03m1dnight_Now I have this code: (if (not (compare-and-set! (:status @tx) :RUNNING :COMMITTING)) (tx-retry tx))
02:04m1dnight_But I would like to change it to either equal to :RUNNING or :SOMETHINGELSE
02:04m1dnight_derp, regular swap will do
02:05m1dnight_oh no, that doesnt return true or false
05:06xiang_wangIs there any library which has implemented rfb protocol in clojure?
06:20morfeen_Hey guys, what sort of projects do you guys use Clojure for? Thanks.
06:21ddellacostaweb applications, machine learning, and more
06:21H4nsdata processing, conversion, generation and extraction (xml, custom formats, csv, x12)
06:24ddellacostafolks, I've got a library that, when I load up the cljc namespaces in the repl they work fine, but when I start up the app that uses the library as a dependency, it fails claiming that some references don't exist
06:25ddellacostaI'm wrapping chunks of clj specific namespaces like so: (ns my.namespace #?(:clj (:import [...]) (:require [...]))) ... is this incorrect?
06:26ddellacostapreviously this was cljx of course: (ns my.namespace #+cljx (:import [...]) #+cljx (:require [...]))) ...etc.
06:32ddellacostaneeeeevermind, needed #?@(:clj [(:import ...) (:require ...)]), lesson learned...
08:42nano-clojurescript here as well? I want to pass a clojurescript function to an audiocontext node's onaudioprocess member. How do I do this?
08:43oddcullyyou might be better off with #clojurescript, but there is some overlap
08:43nano-cool, thanks.
09:54tahmidis there a way to integrate figwheel with Immutant 2 ?
10:01jcrossley3tahmid: i don't see why not
10:04tahmidjcrossley3: The problem I am facing is that figwheel needs a ring handler and starts a jetty or http-kit server. But when I upgrade the request map of ring to handle websocket requests , I get some errors .
10:05tahmidjcrossley3: Figwheel works fine as long as the request and responses are just simple GET / POST etc
10:07jcrossley3tahmid: i know a lot more about immutant than figwheel, but if you can give me some steps to reproduce, i can take a look locally
10:14tahmidjcrossley3: please take a look here. Git repo https://github.com/tahmidsadik112/immutant-reagent-template
10:18jcrossley3tahmid: i'll take a look in a few
10:18tahmidjcrossley3: Steps to reproduce : 1. lein run will start the immutnat server without figwheel, go to localhost:9000, everything works there. 2. lein figwheel will start figwheel server. Then go to localhost:3449 , you will get some error.
10:19tahmidby the way Immutant 2 is fantastic.
10:20jcrossley3tahmid: :)
10:30jcrossley3tahmid: so yeah that trace clearly shows that figwheel is using http-kit which will cause as-channel to barf
10:30jcrossley3looks like figwheel is pretty adamant about running http-kit and there doesn't appear to be a hook to run a different server
10:35tahmidjcrossley3: Thanks for confirming.
10:35jcrossley3tahmid: seems like you could omit :ring-handler in figwheel's config to prevent it from starting a server, and then add its required routes to your handler started by immutant.web/run
10:35jcrossley3maybe?
10:35jcrossley3look at figwheel-sidecar.core/server
10:36tahmidjcrossley3: okay , tahking a look now, will confirm you if that works.
10:36tahmidtaking*
10:37jcrossley3tahmid: i expect bruce may be open to adding a hook for another server, possibly has an optional param to that server fn
10:53fourqWould someone mind helping me understand this line "let [[selected-id :as selected-id-cursor] (:selected-contact-id data)]" . I don't understand why "selected-id" is being referenced as "selected-id-cursor", couldn't this be accomplished by doing this instead: "let [:selected-id-cursor (:selected-contact-id data)]". Here's the full gist of the function: https://gist.github.com/fourq/fd848150aedb6c850db9#file-core-cljs-L18
10:53fourqsomeone (it's always about you ;))
10:54justin_smithfourq: the :as binds the whole collection
10:54justin_smithselected-id is only the first element
10:54justin_smith,(let [[a :as numbers] (range 5)] numbers)
10:54clojurebot(0 1 2 3 4)
10:55justin_smith,(let [[a :as numbers] (range 5)] a)
10:55clojurebot0
10:55fourqjustin_smith, thank you. I'll look over the code again now that I know.
10:55justin_smithalso, :selected-id-cursor is not a valid lhs of a let
10:56fourqoh right
10:56fourqty
10:56gfredericks,(deftype Foo [] Object (equals [_ o] true))
10:56clojurebotsandbox.Foo
10:56gfredericks,(deftype Foo [] Object (equals [_ ^Object o] true))
10:56clojurebot#error {\n :cause "Mismatched return type: equals, expected: boolean, had: java.lang.Object"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Mismatched return type: equals, expected: boolean, had: java.lang.Object, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalAr...
10:56gfredericks^ wat?
10:57justin_smithlooks like metadata sticking to the wrong thing?
10:57gfredericks,(deftype Foo [] Object (equals [_ ^Long o] true))
10:57clojurebot#error {\n :cause "Can't find matching method: equals, leave off hints for auto match."\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't find matching method: equals, leave off hints for auto match., compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalArgumentExce...
10:57gfredericksdunno :/
10:58gfredericksI realized I didn't need the hint anyhow so it doesn't matter I guess
10:59mmeixGreetings from Austria ...
10:59mmeixI'm thinking about a proper data structure to represent musical notes, which gets needed to a placement machinery (SVG). This is purely graphical, as I want to keep semantics strictly separated for some very good reasons. Now, there are notes with accidentals and some without.
10:59mmeixFour possibilities to encode this:
10:59mmeix[ [1 :none] [3 :flat] [5 :none] ]
10:59mmeix[ [1 nil] [3 :flat] [5 nil] ]
11:00mmeix[ [1] [3 :flat] [5] ]
11:00mmeixWhich would be the clojuriest way to do this?
11:00justin_smith{:value 1 :accidental :flat}
11:00dysfunis anyone using cemerick's "friend" i'm having difficulty using the interactive form workflow behind a proxy
11:01mmeixso a map buys me more flexibility in this case?
11:01justin_smithmmeix: the advantage being that if you need to expand, it's painless
11:01dysfunand makes everything more readable
11:01justin_smithas compared to adding more and more things to a vector
11:01mmeixah, ok
11:01mmeixthnks
11:01justin_smithmmeix: also, if the wrong data ends up in the wrong place, it becomes easier to figure out what kind of data it was *meant* to be :)
11:02justin_smithmmeix: also, if you end up wanting to use protocols for behaviors, maps are easy to upgrade to records
11:03mmeixthese are two strong points
11:03mmeixok
11:04mmeix(inc #clojure) :-)
11:09Bronsalazybot: you there?
11:09Bronsa:(
11:10Bronsa&(inc 1)
11:10lazybot⇒ 2
11:10justin_smith(inc #clojure)
11:10lazybot⇒ 9
11:10Bronsauh
11:10mmeixsorry for appending a smiley ...
11:10justin_smith(inc #clojure) :-) is different
11:10justin_smithyeah
11:11mmeixdidn't know, there is collective #clojure-Karma too
11:12justin_smith(inc anything at all can have karma)
11:12lazybot⇒ 1
11:12mmeixI see
11:12justin_smith(identity anything at all can have karma)
11:12lazybotanything at all can have karma has karma 1.
11:12fourqjustin_smith, it just sank in. =) thanks again
11:12justin_smithfourq: np
11:13justin_smith(identity karma karma karma karma chameleon)
11:13lazybotkarma karma karma karma chameleon has karma 1.
11:14PhagusShould one learn Java before learning Clojure?
11:15winkno, please don't :)
11:15justin_smithPhagus: absolutely not neccessary
11:15winkin all seriousness, it depends what you want to do.
11:15znurglPhagus: just learn Clojure, you don't really need Java for that. Just have a look at JVM stuff.
11:15justin_smithPhagus: if you can read a javadoc, that suffices (interop is neccessary)
11:15winkif you plan to interface with java code a lot, the basics help. like when creating wrapper libs
11:16winkif you just want to learn and use a language, ignore Java and read up as you stumble upon stufff
11:16justin_smithwink: even for that, being able to read the javadoc is not the same as knowing the language syntax - former is needed, latter is not
11:16PhagusThanks. I just find Clojure tracebacks a little obscure
11:16justin_smithPhagus: java syntax and rules won't help with that, but knowing its vm model will - those are not the same
11:17winkjustin_smith: I'm not sure I'm buying this. the java syntax is one of the easiest there is. but just doing some try/catch in clojure without ever having done java...
11:17justin_smithwe don't use the lang (clojure emits bytecode directly not java source) but we do use their vm
11:17PhagusI see.
11:17justin_smithwink: I don't find it easy
11:17justin_smithwink: I have done a lot of interop, and always get java syntax wrong when I try to write it
11:18PhagusAnother thing I've found. Clojure seems to be painstakingly slow to run on the OpenJDK... or is it just me?
11:18justin_smithPhagus: slow to run, or to start up?
11:18tbaldridgePhagus: define "slow to run..."
11:18PhagusStart-up I should say
11:18PhagusRuntime is fine, startup is a pain.
11:18winkjustin_smith: in my experience everyone who can do C and/or PHP can also use Java in a week. syntactically, not the best practices etc
11:19tbaldridgePhagus: clojure starts up pretty quickly (1.5 sec on my box), but things like lein, and other libs tend to slow down the startup process
11:19Phaguswink: Well, my question was more, "is it a necessary prereq to learn Java first?"
11:19justin_smithPhagus: if you break it down, in most cases when you run "lein repl", just over a third of the time is spent starting lein, just over a third of the time is spent starting up nrepl, and just under a third is clojure itself. If you use a cached classpath and invoke the clojure jar directly you can easily get a repl in under half a second.
11:19tbaldridgePhagus: No, absolutely not. I had written about 10 lines of Java when I learned Clojure
11:20justin_smith(without any of your project code loaded yet)
11:20Bronsaon my box java -jar clojure.jar starts in 0.5s compared to 5.3s of lein repl
11:20PhagusYes, it tends to be Lein that has the slow start-up times
11:20winkPhagus: it won't hurt (as with every language) but absolutely not necessary, especially beforehand.
11:21Bronsai wonder how much startup times of lein would improve if lein and its deps were distributed AOT
11:21Phaguswink: Dully noted.
11:21justin_smith~faster
11:21clojurebotI don't understand.
11:21justin_smith~faster-lein
11:21clojurebotIt's greek to me.
11:22justin_smithanyway - the best guide to faster clojure startup: https://github.com/technomancy/leiningen/wiki/Faster
11:22Phagusclojurebot should learn Greek then.
11:22justin_smith~faster is https://github.com/technomancy/leiningen/wiki/Faster
11:22clojurebotIk begrijp
11:22PhagusThanks all
11:23xeqiBronsa: they are AOTed
11:24Bronsawelp
11:29cemerickdysfun: probably looking for https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L42
11:32timvisher,(rand-nth nil)
11:33clojurebotnil
11:33timvisher,(rand-nth [])
11:33clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.PersistentVector arrayFor "PersistentVector.java" 153]}]\n :trace\n [[clojure.lang.PersistentVector arrayFor "PersistentVector.java" 153]\n [clojure.lang.PersistentVector nth "PersistentVector.java" 157]\n [clojure.lang.RT nth "RT.java" 839]\n [clojure.core$rand_nth invoke "core.clj...
11:33timvishershould that be?
11:33timvisher,(rand-nth (seq []))
11:33clojurebotnil
11:33timvisher,(rand-nth (list))
11:33clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.RT nthFrom "RT.java" 871]}]\n :trace\n [[clojure.lang.RT nthFrom "RT.java" 871]\n [clojure.lang.RT nth "RT.java" 840]\n [clojure.core$rand_nth invoke "core.clj" 6941]\n [sandbox$eval97 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.C...
11:33timvisher,(rand-nth '())
11:33clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.RT nthFrom "RT.java" 871]}]\n :trace\n [[clojure.lang.RT nthFrom "RT.java" 871]\n [clojure.lang.RT nth "RT.java" 840]\n [clojure.core$rand_nth invoke "core.clj" 6941]\n [sandbox$eval121 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang....
11:34timvisherseems like rand-nth on an empty seq should be nil.
11:34timvisher,(doc rand-nth)
11:34clojurebot"([coll]); Return a random element of the (sequential) collection. Will have the same performance characteristics as nth for the given collection."
11:34justin_smithtimvisher: a related fun one I discoverd in cljs - (rand-int Infinity) is always Infinity (I mean statistics would agree, but ...)
11:34justin_smithtimvisher: agreed that the behavior for nil and () should be the same
11:35justin_smithtimvisher: also ##(= '() ())
11:35lazybot⇒ true
11:35timvisher@justin_smith: heh. :)
11:43dysfuncemerick: awesome, thanks :)
11:54mmeixjustin_smith ok, everything gets a lot easier with maps ... feeling dumb again ... thanks for ongoing help
11:54mmeix(especially with juxt to pull out things for calculations)
12:04justin_smith~everything |gets| a lot easier with maps
12:04clojurebotIk begrijp
12:05mmeixlesson learned
12:13mmeixIs this the shortest form to find all maps containing :accidental?
12:13mmeix(filter #(contains? % :accidental))
12:13mmeixwith the coll at the end of course
12:14mmeix,(def n1 {:step 1 })
12:14clojurebot#'sandbox/n1
12:14mmeix,(def n2 {:step 2 :accidental :flat})
12:14clojurebot#'sandbox/n2
12:15mmeix,(def notes [n1 n2])
12:15clojurebot#'sandbox/notes
12:15mmeix,(filter #(contains? % :accidental) notes)
12:15clojurebot({:step 2, :accidental :flat})
12:17mmeix(I guess I'm not supposed to litter the sandbox with my vars, sorry)
12:18gfredericksmmeix: litter all you want
12:19mmeixok
12:19mmeix(a let would have been better)
12:19gfredericks,(defmacro def-a-thousand-things [name] (cons 'do (for [i (range 1000)] (list 'def (symbol (str name) "-" i)))))
12:19clojurebot#'sandbox/def-a-thousand-things
12:19gfredericks,(def-a-thousand-things haha)
12:19clojurebot#error {\n :cause "Wrong number of args (3) passed to: core/symbol"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (3) passed to: core/symbol"\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" 40]\n [sandbox$def_a_thousand_things$iter__118__122$fn__123$fn__124 invo...
12:20gfredericks,(defmacro def-a-thousand-things [name] (cons 'do (for [i (range 1000)] (list 'def (symbol (str name "-" i))))))
12:20clojurebot#'sandbox/def-a-thousand-things
12:20gfredericks,(def-a-thousand-things haha)
12:20clojurebot#'sandbox/haha-999
12:20gfredericks,haha-42
12:20clojurebot#object[clojure.lang.Var$Unbound 0x7b036374 "Unbound: #'sandbox/haha-42"]
12:20gfredericksnow that's what I call littering
12:20mmeixok :D
12:21mmeixcoming back to my beginner's question: (filter #(contains :% :mykey) coll)
12:22mmeixis this the shortest form?
12:22gfredericks(filter :mykey coll) is very similar
12:22mmeixah ok
12:22mmeixthanks
12:23mmeixlearning, learning ...
12:41ReefersleepHello everyone
12:41gfrederickshello
12:41mmeixhi!
12:41ReefersleepDoes anyone here know how to do the equivalent of Thread/sleep 500 inside a loop/recur in ClojureScript?
12:42ReefersleepI just want the recur to occur (hehe) in steps
12:42Reefersleepof a length that I can adjust :)
12:42mmeixmaybe ask in #clojurescript ...
12:42Reefersleepah
12:42ReefersleepI will
12:43ReefersleepI'm using a web client, how do you join a different channel? /join #clojurescript ?
12:44ReefersleepGuess so :)
12:44ReefersleepBeen a while since I used IRC.
12:47gfredericksReefersleep: I'm not sure you'll have that option in cljs; might have to look at core.async
12:48Reefersleepgfredericks: I stumbled upon a gist by David Nolen that accomplished the task using core.async, but thought that it seemed superfluous and assumed that he was solving a different problem - however, upon asking in #clojurescript, he said that it was indeed the only way
12:49ReefersleepHere it is: https://twitter.com/swannodette/status/350489657395523587
12:52gfredericksReefersleep: so goes javascript
13:04mmeixLooking for further enlightenment ... I'm still not sure, how this works:
13:04mmeix,(let [c [{:foo 1} {:foo 3 :mykey 7}]] (filter :mykey c))
13:04clojurebot({:foo 3, :mykey 7})
13:05mmeixDoes "filter :somekey" carry an implicit "contains?" ?
13:06tbaldridge,(:foo {:bar 42})
13:06clojurebotnil
13:06tbaldridgemmeix: if the key doesn't exist ^^ it returns nil
13:06tbaldridgemmeix: nil is falsey so yes, it happens to work like a implicit contains? but it doesn't include a contains?
13:09mmeixthose are fine points ...
13:09mmeixthanks
13:27mmeix(inc tbaldridge)
13:27lazybot⇒ 21
13:35ciphergothI use lein to pull in clj-time 0.9.0. I was using clj-time.format.instant->map on the Mac, then I moved over to my Linux machine and it vanished. How should I investigate?
13:38ciphergothas in I get "java.lang.RuntimeException: No such var: f/instant->map"
13:44mmeixwas clj-time.format :required :as f? (just a thought)
13:45ciphergothmmeix: yes
13:45mmeixok
13:45ciphergothThe Linux machine is Java 1.7 and the Mac Java 1.8
13:45mmeixcan't help with that, I fear
13:45ciphergothapart from that I can find no other difference, they both have Lein 2.5.1, the source directories are the same git version
13:45ciphergothf/unparse (for example) is present on both
13:46TimMclein clean?
13:46mmeixstrange
13:51ciphergoth"lein clean" seems to have done the trick!
13:51ciphergothweeeeeird!
13:51ciphergothThanks TimMc!
13:53TimMcciphergoth: That's my go-to for "well, that's impossible". After that is "AOTTTTT!" and then maybe "I wonder if I've got something in profiles.clj that's interfering."
13:55ciphergothI don't have a profiles.clj. I am doing AOT so I can deploy on Google App Engine.
13:55ciphergothbut I had this problem with a simple test from lein repl
13:57TimMcciphergoth: There are also ways to defeat AOT. Here's an example that just dynamically chains to another namespace so that most of the code base is AOT-free: https://gist.github.com/timmc/d0c18ec2ec3da13f3cfd
13:59TimMc(Yes that -main is ugly but it's a handy one-liner for "just gimme the var and call it".)
14:02TimMcI previously had this packaged up as the lein-otf plugin, but it broke one day and I decided it wasn't worth maintaining it for so simple a thing to do manually.
14:03justin_smithTimMc: yeah, that's pretty much how I do my gen-class shim (except I also implement the magic classes to make jsvc work)
14:05TimMc?
14:06TimMcTell me about these magic classes.
14:07justin_smithTimMc: http://www.rkn.io/2014/02/06/clojure-cookbook-daemons/
14:07justin_smithsorry, it's a magic interface
14:10TimMcah, neat
14:11ciphergothTimMc: yep, I remember doing something very similar for a website I did for work once
14:12ciphergothyour code is more elegant though I think, the way you use doto :)
14:15IAmMe643Is anybody here?
14:15mmeixyes
14:16IAmMe643mmeix: thx. just trying because the last semi-rare programming language channel I was in had no people online.
14:16mmeixI get lots of help here, recommended!
14:16IAmMe643mmeix: can you help me?
14:16mmeixnot sure, being e beginner ...
14:17mmeixcan try
14:17IAmMe643mmeix: I have not worked with clojure but I need to use it split a string of comma sperated numbers into an array and then sum them.
14:18justin_smithIAmMe643: sounds like a good beginner excersize, all the tools you would need to use to do that are here: http://conj.io (if you can get a clojure repl)
14:18justin_smithif you don't have a repl yet we can help with that too
14:19IAmMe643justin_smith: what is a repl?
14:20ciphergothIAmMe643, this isn't a homework problem is it?
14:20mmeixit would start with clojure.string/split I guess
14:21ToxicFrogIAmMe643: read/evaluate/print loop, a thing you can type code into and get results out of without a separate build process.
14:21IAmMe643mmeix: no. :) If it was I'd use javascript (JK). I have a program that manipulates data and clojure is one of the coding languages I can use in it. Not sure what version it has though.
14:24IAmMe643mmeix: I get java.lang.ClassNotFoundException: clojure.string (NO_SOURCE_FILE:1)
14:24TimMcciphergoth: Elegant... or obscure? You decide. :-)
14:25IAmMe643Just so you guys know, I cannot change much with my enviornment as I am using a packaged app that utilizes Clojure.
14:26eraserhdgfredericks: Are there any known issues with test.check's defspec not respecting the example count?
14:27eraserhdI literally cannot figure out what's happening here.
14:27IAmMe643justin_smith: I got java.lang.ClassNotFoundException: clojure.string (NO_SOURCE_FILE:1)
14:28eraserhdOh. Shrinking.
14:30mmeix;(let [numstring "1,2,3"](apply + (map #(Double/parseDouble %) (clojure.string/split numstring #","))))
14:30mmeix,(let [numstring "1,2,3"](apply + (map #(Double/parseDouble %) (clojure.string/split numstring #","))))
14:31clojurebot6.0
14:31mmeixIAmMe643 does this help?
14:32IAmMe643mmeix: EOF while reading.
14:32mmeixit worked here in clojurebot ...
14:32IAmMe643mmeix: I finally found a way that I think will work (w. their own programming languange)
14:32mmeixI guess you have to check your parens
14:32IAmMe643mmeix: my thing probably has an old version
14:33mmeixhm, ok
14:36IAmMe643mmeix: in case you were curious, here is the code I made (not clojure): sum(forRange(0, value.smartSplit().length(), 1, a, value.smartSplit()[a].toNumber()))
14:38mmeixthat's roughly the same the clojure version does, but not so elegant :)
14:41IAmMe643mmeix: well it is quicker, and smaller. If I had a super-big project that required clojure I would use the clujure version. This was only to do a mass edit of 119 cells.
14:41IAmMe643clojure*
14:44eraserhdIs there an easy way to profile code from the repl? By profile, in this case, I mean determine which sub-function in the call graph is taking the most amount of time?
14:45andyf_eraserhd: I've heard several people praise YourKit for profiling on the JVM. They have either a free version, or a free trial version, not sure which.
14:49oddcully,(let [s "11,222,3333"] (reduce + (map #(Long/parseLong %) (re-seq #"\d+" s))))
14:49clojurebot3566
14:50mmeixah, re-seq is better, yes
14:51Bronsaandyf_: eraserhd you can get a yourkit license for open source projects
14:52oddcullymaybe not better, but maybe there without requiring stuff
14:52mmeixthat's what I meant
14:53oddcullynow really dirty: , (let [s "11,222,3333"] (reduce + (read-string (str "[" s "]"))))
14:54mmeixwantes to avoid read-string ..
14:54mmeixwanted
14:54mmeix:)
14:55oddcullywell i guess that readstring took care of irccloud com ;P
15:08gfrederickseraserhd: ha yeah shrinking; I've been personally surprised by that one several times the last few days; only for a moment though
15:16amalloyoddcully: (let [s "1; 2 ; 3"] ...)
15:17amalloymy point is you should never just wrap something with parens and then read-string it, as an attempt to read multiple forms
15:19gfredericksamalloy: is there any reason you can't safely wrap it with "(\n%s\n)"?
15:19TEttinger#_
15:20TEttinger,(let [s "#_"] (read-string (str "(\n" s "\n)")))
15:20clojurebot#error {\n :cause "Unmatched delimiter: )"\n :via\n [{:type java.lang.RuntimeException\n :message "Unmatched delimiter: )"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n [[clojure.lang.Util runtimeException "Util.java" 221]\n [clojure.lang.LispReader$UnmatchedDelimiterReader invoke "LispReader.java" 1176]\n [clojure.lang.LispReader read "LispReader.java" 263]\n [clo...
15:22TEttinger,(let [s "#_"] (read-string (str "(\n" s "#_()\n)")))
15:22clojurebot#error {\n :cause "Unmatched delimiter: )"\n :via\n [{:type java.lang.RuntimeException\n :message "Unmatched delimiter: )"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n [[clojure.lang.Util runtimeException "Util.java" 221]\n [clojure.lang.LispReader$UnmatchedDelimiterReader invoke "LispReader.java" 1176]\n [clojure.lang.LispReader read "LispReader.java" 263]\n [clo...
15:22TEttingerhmm
15:22whodidthisis there some separate command on emacs clojure-mode to newline with indent, enter just newlines and then i have to tab
15:23tahmidC-j
15:23TEttingergfredericks, shrinking?
15:23whodidthissweet, thanks
15:24gfredericksTEttinger: shrinking as in test.check
15:24TEttinger,(let [s "#_s"] (read-string (str "(\n" s "\n)")))
15:24clojurebot()
15:25TEttingergfredericks: should I care about test.check or only test.chuck?
15:25TEttingerbecause that regex generator is sweet
15:25justin_smithwhodidthis: I think there is something like "electric-indent" that you can turn on too
15:26gfredericksTEttinger: test.chuck is a util lib for test.check, so only makes sense with it
15:27TEttingerit was partially a joke!
15:28justin_smith,(into #{} (repeatedly 10000 #(rand Double/POSITIVE_INFINITY))
15:28clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:28justin_smith,(into #{} (repeatedly 10000 #(rand Double/POSITIVE_INFINITY)))
15:28clojurebot#{Infinity}
15:29TEttinger,(into #{} (repeatedly 10 #(rand Double/POSITIVE_INFINITY)))
15:29clojurebot#{Infinity}
15:29TEttinger,(into #{} (repeatedly 2 #(rand Double/POSITIVE_INFINITY)))
15:29clojurebot#{Infinity}
15:29TEttingerheh
15:29TEttinger,(rand Double/POSITIVE_INFINITY)
15:29clojurebotInfinity
15:29TEttingerthere you go!
15:30justin_smith(doc rand)
15:30clojurebot"([] [n]); Returns a random floating point number between 0 (inclusive) and n (default 1) (exclusive)."
15:30TEttingerexclusive, ha
15:30justin_smith"exclusive"
15:30TEttingercan't exclude infinity
15:30TEttingerthere's always a bigger one
15:30TEttinger(I think any range of (-oo to oo)
15:31TEttingeris the same as [-oo to oo]
15:31justin_smithTEttinger: I guess the into result makes sense, most numbers between 0 and oo are oo
15:31TEttingerheh
15:31TEttingereven the rand!
15:32TEttingerany operation on an infinite number that does not reduce by an infinite number is an infinite number
15:32TEttinger,(+ Double/POSITIVE_INFINITY Double/NEGATIVE_INFINITY)
15:33clojurebotNaN
15:33TEttingerheh
15:33TEttingernot... what I expected
15:33TEttinger,(- Double/POSITIVE_INFINITY Double/POSITIVE_INFINITY)
15:33clojurebotNaN
15:33TEttingersame
15:33gfredericksTEttinger: what would you expect?
15:34eraserhdgfredericks: So, how does such-that interact with shrinking? I have a test that shrinking generated UUIDs so that they collide. If I add a such-that they are unique, will that make shrinking abort?
15:34TEttingergfredericks, infinity doesn't make sense, really
15:34TEttingerso, the answer is ???
15:34lazybotTEttinger: Oh, absolutely.
15:34gfrederickseraserhd: shrinking won't generate invalid things if that's what you're asking; my guess is you don't really need to shrink these?
15:35gfrederickseraserhd: but I have some generators for distinct sets cooked up for the next release, that should make this stuff a lot easier
15:35TEttingerinfinity kinda makes sense if you're in the hyper-real ring and not the real ring. but that's mathematician cocaine binge territory right there
15:36gfredericksevery time I've used uuids I've run them through gen/no-shrink because why bother
15:36gfredericksTEttinger: which infinity though?
15:36eraserhdmakes sense.
15:37gfredericksI'm writing a generator for ordered integer partitions right now SUPER FUN TIMES
15:38TEttingergfredericks, in hyper-reals, you can define (< (+ infinity 1) (+ infinity 2))
15:38TEttingerand it will make sense
15:38gfredericksTEttinger: I'm talking about in Double-land where you have exactly 2 infinities
15:39TEttingerpfft
15:39TEttingerwhat are we, Java programmers?
15:39TEttingerhttps://en.wikipedia.org/wiki/Hyperreal_number
15:41gfredericksTEttinger: well that was what you were playing with initially
15:41TEttingerheh
15:41TEttinger,(== Double/POSITIVE_INFINITY Double/POSITIVE_INFINITY)
15:41clojurebottrue
15:42TEttingerinteresting...
15:43borkdudewhy would someone put lein plugins explicitly in the :dev profile in leiningen?
15:44borkdudein project.clj
15:44borkdudewhat benefit does it have
15:46gfrederickscan't think of any
15:47borkdudefaster load times of other tasks?
15:48iamjarvodoes anyone have a solid article explaining reify?
15:48TEttingerwowza, this stuff has some fun names... https://en.wikipedia.org/wiki/Boolean_prime_ideal_theorem#The_ultrafilter_lemma
15:48iamjarvoive read this one http://decomplecting.org/blog/2014/10/29/reify-this/
15:48TEttingerultrapower theorem for proving hyperreal numbers
15:49TEttingernext up, hyper-ultra-yowza-numbers
15:54gfredericksTEttinger: ordinals are pretty trippy
15:55TEttingeris this related to your ordered partitioning?
16:01gfredericksnope
16:20TimMcborkdude: Come to think of it, maybe there's no difference.
16:24amalloygfredericks: no, i think wrapping with [\n] is technically fine but just feels sloppy to me, compared to using read
16:27TEttingeramalloy: what is this for?
16:28TEttingeryou have #_ and ; as two different ways to cause something to be ignored
17:18arohnerarg. Exceptions with no stacktrace are the worst
17:32lodin_Huh, turns out someone just registered nickname lodin.
17:44jtmarmoncan anyone give me a suggestion on how I can clean this up a bit: https://gist.github.com/jtmarmon/cd10b0329cf646c107ca . I'd like to not have to pass this map down the call stack, but I also don't want to use a macro because it just seems kinda hacky here
17:49lodin_jtmarmon: Where does GET* come from?
17:49jtmarmonhttps://github.com/metosin/compojure-api/ - it's a modified version of compojure's GET which allows for some custom let bindings, like those components. i'm really asking about the body's call stack, not so much about how the body is invoked
17:50amalloyjtmarmon: pass the map down the call stack, to the places that actually need it. if your entire program needs access to your entire set of components, the structure seems kinda murky and it's nice to have a reminder there that you should clean up
17:51jtmarmonamalloy: fair nuff. I simplified call-fn to an anonymous function which makes it read a bit cleaner. definitely will earmark for a bit of cleanup here. thanks guys
17:58lodin_jtmarmon: Do these components have anything to do with the components in https://github.com/stuartsierra/component?
17:58jtmarmonlodin_: yes, they are actual components
18:38Deraenjtmarmon: You can use :components [:as system] to access the whole system
18:39jtmarmonahh good pint, that does clean it up a bit. thanks @Deraen. btw going to work on that vector coercion thing sunday :) we're shipping monday so gotta get it out of the way ;)
18:42Deraenjtmarmon: ring-swagger #50 should implement most of the stuff needed for query parameter coercions, I've been busy lately but I think I'll have time this weekend to finish that
18:43jtmarmonDeraen: got it. i'll keep an eye out then :D
22:46chomwitthi. in a small tutorial i found in project.clj the ring/ring-util-response dependencie but lein can find it in clojars. is it depracated or sth?
22:49zodiakchomwitt, ring.util.response is in ring-core .. so if you have core, you should have it already. You could always (:require [ring.util.response :refer [whatever])
22:52chomwittzodiak: one moment to try that..
22:58chomwittzodiak: thanks!! it worked
22:59zodiaknp
23:35luxbockwhat do you call a macro that uses try and catch to return nil on Exceptions? I'm sure most people have written it before