#clojure log - Jun 05 2015

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

0:00 * gfredericks going to bed

0:00 crocket: gfredericks, Why doesn't https://www.refheap.com/102108 work?

0:01 (if-let [a 2] (if-let [b 2] [a b])) is going to evaluate to [a b]

0:01 It's like (if-let [[a b] [a b]] "ok" "no")

0:03 Why does (if-let [a 2 b 3] a b) not work?

0:04 Why does (if-let-all [a 2 b 3] a b) not work?

0:09 ok

0:09 I understood why it doesn't work.

0:12 I need something like https://www.refheap.com/102109

0:14 All right....

0:17 turbofail: er, i don't think that's quite what you want either

0:18 then again i just got here so i'm not entirely certain what it is you want

0:20 i think that macroexpansion would always return either else or nil

0:21 and never then

0:26 crocket: Wow it works....

0:26 https://www.refheap.com/102107 works

0:27 https://www.refheap.com/102107 does what I want.

0:28 turbofail: ah yeah, that looks more like it

0:42 crocket: I forgot to give credit to "Gary Fredericks"

0:43 Don't worry I will mention your name in a reply.

2:02 m1dnight_: Is there somethig like compare-and-set! but with multiple values, or a custom predicate?

2:03 Now I have this code: (if (not (compare-and-set! (:status @tx) :RUNNING :COMMITTING)) (tx-retry tx))

2:04 But I would like to change it to either equal to :RUNNING or :SOMETHINGELSE

2:04 derp, regular swap will do

2:04 * m1dnight_ hasnt seen his bed yet

2:05 m1dnight_: oh no, that doesnt return true or false

5:06 xiang_wang: Is there any library which has implemented rfb protocol in clojure?

6:20 morfeen_: Hey guys, what sort of projects do you guys use Clojure for? Thanks.

6:21 ddellacosta: web applications, machine learning, and more

6:21 H4ns: data processing, conversion, generation and extraction (xml, custom formats, csv, x12)

6:24 ddellacosta: folks, 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

6:25 I'm wrapping chunks of clj specific namespaces like so: (ns my.namespace #?(:clj (:import [...]) (:require [...]))) ... is this incorrect?

6:26 previously this was cljx of course: (ns my.namespace #+cljx (:import [...]) #+cljx (:require [...]))) ...etc.

6:32 neeeeevermind, needed #?@(:clj [(:import ...) (:require ...)]), lesson learned...

8:42 nano-: clojurescript here as well? I want to pass a clojurescript function to an audiocontext node's onaudioprocess member. How do I do this?

8:43 oddcully: you might be better off with #clojurescript, but there is some overlap

8:43 nano-: cool, thanks.

9:54 tahmid: is there a way to integrate figwheel with Immutant 2 ?

10:01 jcrossley3: tahmid: i don't see why not

10:04 tahmid: jcrossley3: 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:05 jcrossley3: Figwheel works fine as long as the request and responses are just simple GET / POST etc

10:07 jcrossley3: tahmid: 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:14 tahmid: jcrossley3: please take a look here. Git repo https://github.com/tahmidsadik112/immutant-reagent-template

10:18 jcrossley3: tahmid: i'll take a look in a few

10:18 tahmid: jcrossley3: 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:19 by the way Immutant 2 is fantastic.

10:20 jcrossley3: tahmid: :)

10:30 tahmid: so yeah that trace clearly shows that figwheel is using http-kit which will cause as-channel to barf

10:30 looks like figwheel is pretty adamant about running http-kit and there doesn't appear to be a hook to run a different server

10:35 tahmid: jcrossley3: Thanks for confirming.

10:35 jcrossley3: tahmid: 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:35 maybe?

10:35 look at figwheel-sidecar.core/server

10:36 tahmid: jcrossley3: okay , tahking a look now, will confirm you if that works.

10:36 taking*

10:37 jcrossley3: tahmid: i expect bruce may be open to adding a hook for another server, possibly has an optional param to that server fn

10:53 fourq: Would 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:53 someone (it's always about you ;))

10:54 justin_smith: fourq: the :as binds the whole collection

10:54 selected-id is only the first element

10:54 ,(let [[a :as numbers] (range 5)] numbers)

10:54 clojurebot: (0 1 2 3 4)

10:55 justin_smith: ,(let [[a :as numbers] (range 5)] a)

10:55 clojurebot: 0

10:55 fourq: justin_smith, thank you. I'll look over the code again now that I know.

10:55 justin_smith: also, :selected-id-cursor is not a valid lhs of a let

10:56 fourq: oh right

10:56 ty

10:56 gfredericks: ,(deftype Foo [] Object (equals [_ o] true))

10:56 clojurebot: sandbox.Foo

10:56 gfredericks: ,(deftype Foo [] Object (equals [_ ^Object o] true))

10:56 clojurebot: #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:56 gfredericks: ^ wat?

10:57 justin_smith: looks like metadata sticking to the wrong thing?

10:57 gfredericks: ,(deftype Foo [] Object (equals [_ ^Long o] true))

10:57 clojurebot: #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:57 gfredericks: dunno :/

10:58 I realized I didn't need the hint anyhow so it doesn't matter I guess

10:59 mmeix: Greetings from Austria ...

10:59 I'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:59 Four possibilities to encode this:

10:59 [ [1 :none] [3 :flat] [5 :none] ]

10:59 [ [1 nil] [3 :flat] [5 nil] ]

11:00 [ [1] [3 :flat] [5] ]

11:00 Which would be the clojuriest way to do this?

11:00 justin_smith: {:value 1 :accidental :flat}

11:00 dysfun: is anyone using cemerick's "friend" i'm having difficulty using the interactive form workflow behind a proxy

11:01 mmeix: so a map buys me more flexibility in this case?

11:01 justin_smith: mmeix: the advantage being that if you need to expand, it's painless

11:01 dysfun: and makes everything more readable

11:01 justin_smith: as compared to adding more and more things to a vector

11:01 mmeix: ah, ok

11:01 thnks

11:01 justin_smith: mmeix: 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:02 mmeix: also, if you end up wanting to use protocols for behaviors, maps are easy to upgrade to records

11:03 mmeix: these are two strong points

11:03 ok

11:04 (inc #clojure) :-)

11:09 Bronsa: lazybot: you there?

11:09 :(

11:10 &(inc 1)

11:10 lazybot: ⇒ 2

11:10 justin_smith: (inc #clojure)

11:10 lazybot: ⇒ 9

11:10 Bronsa: uh

11:10 mmeix: sorry for appending a smiley ...

11:10 justin_smith: (inc #clojure) :-) is different

11:10 yeah

11:11 mmeix: didn't know, there is collective #clojure-Karma too

11:12 justin_smith: (inc anything at all can have karma)

11:12 lazybot: ⇒ 1

11:12 mmeix: I see

11:12 justin_smith: (identity anything at all can have karma)

11:12 lazybot: anything at all can have karma has karma 1.

11:12 fourq: justin_smith, it just sank in. =) thanks again

11:12 justin_smith: fourq: np

11:13 (identity karma karma karma karma chameleon)

11:13 lazybot: karma karma karma karma chameleon has karma 1.

11:14 Phagus: Should one learn Java before learning Clojure?

11:15 wink: no, please don't :)

11:15 justin_smith: Phagus: absolutely not neccessary

11:15 wink: in all seriousness, it depends what you want to do.

11:15 znurgl: Phagus: just learn Clojure, you don't really need Java for that. Just have a look at JVM stuff.

11:15 justin_smith: Phagus: if you can read a javadoc, that suffices (interop is neccessary)

11:15 wink: if you plan to interface with java code a lot, the basics help. like when creating wrapper libs

11:16 if you just want to learn and use a language, ignore Java and read up as you stumble upon stufff

11:16 justin_smith: wink: 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:16 Phagus: Thanks. I just find Clojure tracebacks a little obscure

11:16 justin_smith: Phagus: java syntax and rules won't help with that, but knowing its vm model will - those are not the same

11:17 wink: justin_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:17 justin_smith: we don't use the lang (clojure emits bytecode directly not java source) but we do use their vm

11:17 Phagus: I see.

11:17 justin_smith: wink: I don't find it easy

11:17 wink: I have done a lot of interop, and always get java syntax wrong when I try to write it

11:18 Phagus: Another thing I've found. Clojure seems to be painstakingly slow to run on the OpenJDK... or is it just me?

11:18 justin_smith: Phagus: slow to run, or to start up?

11:18 tbaldridge: Phagus: define "slow to run..."

11:18 Phagus: Start-up I should say

11:18 Runtime is fine, startup is a pain.

11:18 wink: justin_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:19 tbaldridge: Phagus: 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:19 Phagus: wink: Well, my question was more, "is it a necessary prereq to learn Java first?"

11:19 justin_smith: Phagus: 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:19 tbaldridge: Phagus: No, absolutely not. I had written about 10 lines of Java when I learned Clojure

11:20 justin_smith: (without any of your project code loaded yet)

11:20 Bronsa: on my box java -jar clojure.jar starts in 0.5s compared to 5.3s of lein repl

11:20 Phagus: Yes, it tends to be Lein that has the slow start-up times

11:20 wink: Phagus: it won't hurt (as with every language) but absolutely not necessary, especially beforehand.

11:21 Bronsa: i wonder how much startup times of lein would improve if lein and its deps were distributed AOT

11:21 Phagus: wink: Dully noted.

11:21 justin_smith: ~faster

11:21 clojurebot: I don't understand.

11:21 justin_smith: ~faster-lein

11:21 clojurebot: It's greek to me.

11:22 justin_smith: anyway - the best guide to faster clojure startup: https://github.com/technomancy/leiningen/wiki/Faster

11:22 Phagus: clojurebot should learn Greek then.

11:22 justin_smith: ~faster is https://github.com/technomancy/leiningen/wiki/Faster

11:22 clojurebot: Ik begrijp

11:22 Phagus: Thanks all

11:23 xeqi: Bronsa: they are AOTed

11:24 Bronsa: welp

11:29 cemerick: dysfun: probably looking for https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L42

11:32 timvisher: ,(rand-nth nil)

11:33 clojurebot: nil

11:33 timvisher: ,(rand-nth [])

11:33 clojurebot: #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:33 timvisher: should that be?

11:33 ,(rand-nth (seq []))

11:33 clojurebot: nil

11:33 timvisher: ,(rand-nth (list))

11:33 clojurebot: #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:33 timvisher: ,(rand-nth '())

11:33 clojurebot: #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:34 timvisher: seems like rand-nth on an empty seq should be nil.

11:34 ,(doc rand-nth)

11:34 clojurebot: "([coll]); Return a random element of the (sequential) collection. Will have the same performance characteristics as nth for the given collection."

11:34 justin_smith: timvisher: a related fun one I discoverd in cljs - (rand-int Infinity) is always Infinity (I mean statistics would agree, but ...)

11:34 timvisher: agreed that the behavior for nil and () should be the same

11:35 timvisher: also ##(= '() ())

11:35 lazybot: ⇒ true

11:35 timvisher: @justin_smith: heh. :)

11:43 dysfun: cemerick: awesome, thanks :)

11:54 mmeix: justin_smith ok, everything gets a lot easier with maps ... feeling dumb again ... thanks for ongoing help

11:54 (especially with juxt to pull out things for calculations)

12:04 justin_smith: ~everything |gets| a lot easier with maps

12:04 clojurebot: Ik begrijp

12:05 mmeix: lesson learned

12:13 Is this the shortest form to find all maps containing :accidental?

12:13 (filter #(contains? % :accidental))

12:13 with the coll at the end of course

12:14 ,(def n1 {:step 1 })

12:14 clojurebot: #'sandbox/n1

12:14 mmeix: ,(def n2 {:step 2 :accidental :flat})

12:14 clojurebot: #'sandbox/n2

12:15 mmeix: ,(def notes [n1 n2])

12:15 clojurebot: #'sandbox/notes

12:15 mmeix: ,(filter #(contains? % :accidental) notes)

12:15 clojurebot: ({:step 2, :accidental :flat})

12:17 mmeix: (I guess I'm not supposed to litter the sandbox with my vars, sorry)

12:18 gfredericks: mmeix: litter all you want

12:19 mmeix: ok

12:19 (a let would have been better)

12:19 gfredericks: ,(defmacro def-a-thousand-things [name] (cons 'do (for [i (range 1000)] (list 'def (symbol (str name) "-" i)))))

12:19 clojurebot: #'sandbox/def-a-thousand-things

12:19 gfredericks: ,(def-a-thousand-things haha)

12:19 clojurebot: #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:20 gfredericks: ,(defmacro def-a-thousand-things [name] (cons 'do (for [i (range 1000)] (list 'def (symbol (str name "-" i))))))

12:20 clojurebot: #'sandbox/def-a-thousand-things

12:20 gfredericks: ,(def-a-thousand-things haha)

12:20 clojurebot: #'sandbox/haha-999

12:20 gfredericks: ,haha-42

12:20 clojurebot: #object[clojure.lang.Var$Unbound 0x7b036374 "Unbound: #'sandbox/haha-42"]

12:20 gfredericks: now that's what I call littering

12:20 mmeix: ok :D

12:21 coming back to my beginner's question: (filter #(contains :% :mykey) coll)

12:22 is this the shortest form?

12:22 gfredericks: (filter :mykey coll) is very similar

12:22 mmeix: ah ok

12:22 thanks

12:23 learning, learning ...

12:41 Reefersleep: Hello everyone

12:41 gfredericks: hello

12:41 mmeix: hi!

12:41 Reefersleep: Does anyone here know how to do the equivalent of Thread/sleep 500 inside a loop/recur in ClojureScript?

12:42 I just want the recur to occur (hehe) in steps

12:42 of a length that I can adjust :)

12:42 mmeix: maybe ask in #clojurescript ...

12:42 Reefersleep: ah

12:42 I will

12:43 I'm using a web client, how do you join a different channel? /join #clojurescript ?

12:44 Guess so :)

12:44 Been a while since I used IRC.

12:47 gfredericks: Reefersleep: I'm not sure you'll have that option in cljs; might have to look at core.async

12:48 Reefersleep: gfredericks: 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:49 Here it is: https://twitter.com/swannodette/status/350489657395523587

12:52 gfredericks: Reefersleep: so goes javascript

13:04 mmeix: Looking for further enlightenment ... I'm still not sure, how this works:

13:04 ,(let [c [{:foo 1} {:foo 3 :mykey 7}]] (filter :mykey c))

13:04 clojurebot: ({:foo 3, :mykey 7})

13:05 mmeix: Does "filter :somekey" carry an implicit "contains?" ?

13:06 tbaldridge: ,(:foo {:bar 42})

13:06 clojurebot: nil

13:06 tbaldridge: mmeix: if the key doesn't exist ^^ it returns nil

13:06 mmeix: nil is falsey so yes, it happens to work like a implicit contains? but it doesn't include a contains?

13:09 mmeix: those are fine points ...

13:09 thanks

13:27 (inc tbaldridge)

13:27 lazybot: ⇒ 21

13:35 ciphergoth: I 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:38 as in I get "java.lang.RuntimeException: No such var: f/instant->map"

13:44 mmeix: was clj-time.format :required :as f? (just a thought)

13:45 ciphergoth: mmeix: yes

13:45 mmeix: ok

13:45 ciphergoth: The Linux machine is Java 1.7 and the Mac Java 1.8

13:45 mmeix: can't help with that, I fear

13:45 ciphergoth: apart from that I can find no other difference, they both have Lein 2.5.1, the source directories are the same git version

13:45 f/unparse (for example) is present on both

13:46 TimMc: lein clean?

13:46 mmeix: strange

13:51 ciphergoth: "lein clean" seems to have done the trick!

13:51 weeeeeird!

13:51 Thanks TimMc!

13:53 TimMc: ciphergoth: 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:55 ciphergoth: I don't have a profiles.clj. I am doing AOT so I can deploy on Google App Engine.

13:55 but I had this problem with a simple test from lein repl

13:57 TimMc: ciphergoth: 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:59 (Yes that -main is ugly but it's a handy one-liner for "just gimme the var and call it".)

14:02 I 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:03 justin_smith: TimMc: yeah, that's pretty much how I do my gen-class shim (except I also implement the magic classes to make jsvc work)

14:05 TimMc: ?

14:06 Tell me about these magic classes.

14:07 justin_smith: TimMc: http://www.rkn.io/2014/02/06/clojure-cookbook-daemons/

14:07 sorry, it's a magic interface

14:10 TimMc: ah, neat

14:11 ciphergoth: TimMc: yep, I remember doing something very similar for a website I did for work once

14:12 your code is more elegant though I think, the way you use doto :)

14:15 IAmMe643: Is anybody here?

14:15 mmeix: yes

14:16 IAmMe643: mmeix: thx. just trying because the last semi-rare programming language channel I was in had no people online.

14:16 mmeix: I get lots of help here, recommended!

14:16 IAmMe643: mmeix: can you help me?

14:16 mmeix: not sure, being e beginner ...

14:17 can try

14:17 IAmMe643: mmeix: 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:18 justin_smith: IAmMe643: 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:18 if you don't have a repl yet we can help with that too

14:19 IAmMe643: justin_smith: what is a repl?

14:20 ciphergoth: IAmMe643, this isn't a homework problem is it?

14:20 mmeix: it would start with clojure.string/split I guess

14:21 ToxicFrog: IAmMe643: read/evaluate/print loop, a thing you can type code into and get results out of without a separate build process.

14:21 IAmMe643: mmeix: 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:24 mmeix: I get java.lang.ClassNotFoundException: clojure.string (NO_SOURCE_FILE:1)

14:24 TimMc: ciphergoth: Elegant... or obscure? You decide. :-)

14:25 IAmMe643: Just so you guys know, I cannot change much with my enviornment as I am using a packaged app that utilizes Clojure.

14:26 eraserhd: gfredericks: Are there any known issues with test.check's defspec not respecting the example count?

14:27 I literally cannot figure out what's happening here.

14:27 IAmMe643: justin_smith: I got java.lang.ClassNotFoundException: clojure.string (NO_SOURCE_FILE:1)

14:28 eraserhd: Oh. Shrinking.

14:30 mmeix: ;(let [numstring "1,2,3"](apply + (map #(Double/parseDouble %) (clojure.string/split numstring #","))))

14:30 ,(let [numstring "1,2,3"](apply + (map #(Double/parseDouble %) (clojure.string/split numstring #","))))

14:31 clojurebot: 6.0

14:31 mmeix: IAmMe643 does this help?

14:32 IAmMe643: mmeix: EOF while reading.

14:32 mmeix: it worked here in clojurebot ...

14:32 IAmMe643: mmeix: I finally found a way that I think will work (w. their own programming languange)

14:32 mmeix: I guess you have to check your parens

14:32 IAmMe643: mmeix: my thing probably has an old version

14:33 mmeix: hm, ok

14:36 IAmMe643: mmeix: 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:38 mmeix: that's roughly the same the clojure version does, but not so elegant :)

14:41 IAmMe643: mmeix: 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:41 clojure*

14:44 eraserhd: Is 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:45 andyf_: 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:49 oddcully: ,(let [s "11,222,3333"] (reduce + (map #(Long/parseLong %) (re-seq #"\d+" s))))

14:49 clojurebot: 3566

14:50 mmeix: ah, re-seq is better, yes

14:51 Bronsa: andyf_: eraserhd you can get a yourkit license for open source projects

14:52 oddcully: maybe not better, but maybe there without requiring stuff

14:52 mmeix: that's what I meant

14:53 oddcully: now really dirty: , (let [s "11,222,3333"] (reduce + (read-string (str "[" s "]"))))

14:54 mmeix: wantes to avoid read-string ..

14:54 wanted

14:54 :)

14:55 oddcully: well i guess that readstring took care of irccloud com ;P

15:08 gfredericks: eraserhd: ha yeah shrinking; I've been personally surprised by that one several times the last few days; only for a moment though

15:16 amalloy: oddcully: (let [s "1; 2 ; 3"] ...)

15:17 my point is you should never just wrap something with parens and then read-string it, as an attempt to read multiple forms

15:19 gfredericks: amalloy: is there any reason you can't safely wrap it with "(\n%s\n)"?

15:19 TEttinger: #_

15:20 ,(let [s "#_"] (read-string (str "(\n" s "\n)")))

15:20 clojurebot: #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:22 TEttinger: ,(let [s "#_"] (read-string (str "(\n" s "#_()\n)")))

15:22 clojurebot: #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:22 TEttinger: hmm

15:22 whodidthis: is there some separate command on emacs clojure-mode to newline with indent, enter just newlines and then i have to tab

15:23 tahmid: C-j

15:23 TEttinger: gfredericks, shrinking?

15:23 whodidthis: sweet, thanks

15:24 gfredericks: TEttinger: shrinking as in test.check

15:24 TEttinger: ,(let [s "#_s"] (read-string (str "(\n" s "\n)")))

15:24 clojurebot: ()

15:25 TEttinger: gfredericks: should I care about test.check or only test.chuck?

15:25 because that regex generator is sweet

15:25 justin_smith: whodidthis: I think there is something like "electric-indent" that you can turn on too

15:26 gfredericks: TEttinger: test.chuck is a util lib for test.check, so only makes sense with it

15:27 TEttinger: it was partially a joke!

15:28 justin_smith: ,(into #{} (repeatedly 10000 #(rand Double/POSITIVE_INFINITY))

15:28 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

15:28 justin_smith: ,(into #{} (repeatedly 10000 #(rand Double/POSITIVE_INFINITY)))

15:28 clojurebot: #{Infinity}

15:29 TEttinger: ,(into #{} (repeatedly 10 #(rand Double/POSITIVE_INFINITY)))

15:29 clojurebot: #{Infinity}

15:29 TEttinger: ,(into #{} (repeatedly 2 #(rand Double/POSITIVE_INFINITY)))

15:29 clojurebot: #{Infinity}

15:29 TEttinger: heh

15:29 ,(rand Double/POSITIVE_INFINITY)

15:29 clojurebot: Infinity

15:29 TEttinger: there you go!

15:30 justin_smith: (doc rand)

15:30 clojurebot: "([] [n]); Returns a random floating point number between 0 (inclusive) and n (default 1) (exclusive)."

15:30 TEttinger: exclusive, ha

15:30 justin_smith: "exclusive"

15:30 TEttinger: can't exclude infinity

15:30 there's always a bigger one

15:30 (I think any range of (-oo to oo)

15:31 is the same as [-oo to oo]

15:31 justin_smith: TEttinger: I guess the into result makes sense, most numbers between 0 and oo are oo

15:31 TEttinger: heh

15:31 even the rand!

15:32 any operation on an infinite number that does not reduce by an infinite number is an infinite number

15:32 ,(+ Double/POSITIVE_INFINITY Double/NEGATIVE_INFINITY)

15:33 clojurebot: NaN

15:33 TEttinger: heh

15:33 not... what I expected

15:33 ,(- Double/POSITIVE_INFINITY Double/POSITIVE_INFINITY)

15:33 clojurebot: NaN

15:33 TEttinger: same

15:33 gfredericks: TEttinger: what would you expect?

15:34 eraserhd: gfredericks: 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:34 TEttinger: gfredericks, infinity doesn't make sense, really

15:34 so, the answer is ???

15:34 lazybot: TEttinger: Oh, absolutely.

15:34 gfredericks: eraserhd: 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:35 eraserhd: but I have some generators for distinct sets cooked up for the next release, that should make this stuff a lot easier

15:35 TEttinger: infinity 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:36 gfredericks: every time I've used uuids I've run them through gen/no-shrink because why bother

15:36 TEttinger: which infinity though?

15:36 eraserhd: makes sense.

15:37 gfredericks: I'm writing a generator for ordered integer partitions right now SUPER FUN TIMES

15:38 TEttinger: gfredericks, in hyper-reals, you can define (< (+ infinity 1) (+ infinity 2))

15:38 and it will make sense

15:38 gfredericks: TEttinger: I'm talking about in Double-land where you have exactly 2 infinities

15:39 TEttinger: pfft

15:39 what are we, Java programmers?

15:39 https://en.wikipedia.org/wiki/Hyperreal_number

15:41 gfredericks: TEttinger: well that was what you were playing with initially

15:41 TEttinger: heh

15:41 ,(== Double/POSITIVE_INFINITY Double/POSITIVE_INFINITY)

15:41 clojurebot: true

15:42 TEttinger: interesting...

15:43 borkdude: why would someone put lein plugins explicitly in the :dev profile in leiningen?

15:44 in project.clj

15:44 what benefit does it have

15:46 gfredericks: can't think of any

15:47 borkdude: faster load times of other tasks?

15:48 iamjarvo: does anyone have a solid article explaining reify?

15:48 TEttinger: wowza, this stuff has some fun names... https://en.wikipedia.org/wiki/Boolean_prime_ideal_theorem#The_ultrafilter_lemma

15:48 iamjarvo: ive read this one http://decomplecting.org/blog/2014/10/29/reify-this/

15:48 TEttinger: ultrapower theorem for proving hyperreal numbers

15:49 next up, hyper-ultra-yowza-numbers

15:54 gfredericks: TEttinger: ordinals are pretty trippy

15:55 TEttinger: is this related to your ordered partitioning?

16:01 gfredericks: nope

16:20 TimMc: borkdude: Come to think of it, maybe there's no difference.

16:24 amalloy: gfredericks: no, i think wrapping with [\n] is technically fine but just feels sloppy to me, compared to using read

16:27 TEttinger: amalloy: what is this for?

16:28 you have #_ and ; as two different ways to cause something to be ignored

17:18 arohner: arg. Exceptions with no stacktrace are the worst

17:32 lodin_: Huh, turns out someone just registered nickname lodin.

17:44 jtmarmon: can 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:49 lodin_: jtmarmon: Where does GET* come from?

17:49 jtmarmon: https://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:50 amalloy: jtmarmon: 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:51 jtmarmon: amalloy: 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:58 lodin_: jtmarmon: Do these components have anything to do with the components in https://github.com/stuartsierra/component?

17:58 jtmarmon: lodin_: yes, they are actual components

18:38 Deraen: jtmarmon: You can use :components [:as system] to access the whole system

18:39 jtmarmon: ahh 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:42 Deraen: jtmarmon: 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:43 jtmarmon: Deraen: got it. i'll keep an eye out then :D

22:46 chomwitt: hi. 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:49 zodiak: chomwitt, 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:52 chomwitt: zodiak: one moment to try that..

22:58 zodiak: thanks!! it worked

22:59 zodiak: np

23:35 luxbock: what do you call a macro that uses try and catch to return nil on Exceptions? I'm sure most people have written it before

Logging service provided by n01se.net