#clojure log - Aug 15 2012

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

0:34 tolstoy: Is there a way to shut down Emacs (when slime is attached to swank) without killing the JVM and/or causing an exception in Swank?

0:35 ,sayonara and ,quit cause swank to shut down the JVM, so that's not it….

0:35 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sayonara in this context, compiling:(NO_SOURCE_PATH:0)>

0:35 tolstoy: Oops. Sorry clojurebot.

0:41 amalloy: tolstoy: the only way i know is to start a swank server independent of emacs (ie, lein-swank+slime-connect, rather than clojure-jack-in)

0:41 then you can just kill the *swank* buffer to disconnect

0:42 tolstoy: amalloy: That's what I've done. "lein trampoline run" and in the start up sequence I start up swank (just for fun).

0:42 shawnlewis: any opinions on clojure (sql) database migration and query libraries?

0:43 tolstoy: When I kill emacs and hit "yes" when it asks me to terminate that connection, the app throws a stack trace, but still works. So there's that.

0:44 amalloy: tolstoy: you're doing something weird, then. i do the same thing and it works fine

0:44 tolstoy: Okay. Good to know.

0:44 shawnlewis: looks like lobos and korma were good options, but no longer work together due to https://github.com/budu/lobos/issues/43

0:45 amalloy: the startup code looks like (do (stuff) (swank/start-server :host host :port port) (stuff))

0:46 tolstoy: Yeah, that's what I have, except no :host param.

0:47 (defn- start-swank() (log/info "starting swank") (swank/start-server :port 4005))

0:48 exception in control loop java.lang.InterruptedException java.lang.Exception: Error reading swank message

0:49 Oops, that's a [] not (). Anyway, probably just some mismatch somewhere along the line.

0:51 Hm. Maybe I need slime-clj.

0:51 amalloy: NOOO

0:51 so old and evil

0:51 tolstoy: Ah, ok. Phew!

0:54 xeqi: tolstoy: I would get a stack trace when I closed emacs as well, can't remember if M-x slime-disconnect would cause it

0:55 amalloy: you're talking about closing all of emacs, not just disconnecting? i dunno then; i never close emacs

0:56 tolstoy: xeqi: Yeah, slime-disconnect gives me the same stack trace in the JVM/swank process.

0:56 The st happens regardless. But "slime-disconnect" was what I was looking for.

0:57 amalloy: https://gist.github.com/3356076 to fix the bug that allows emacs to stop running

0:58 xeqi: shawnlewis: theres also https://github.com/weavejester/ragtime for migrations

0:58 tutysra_: can i tell whether a project should use lein2 or can be used with lein1 by looking at the project.clj file

0:58 xeqi: though in clojars technomancy just made his own script for us https://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj

0:59 tutysra_: some have a :min-lein-version, :source-path vs :source-paths is a way, :profiles are lein2 only

1:00 there are other keys, but those seem to be the main ones

1:01 amalloy: tutysra_: a strong indicator is whether the dependency is listed as [clojure "1.4.0"] or [org.clojure/clojure "1.4.0"] -- lein2 no longer allows the shorthand

1:01 shawnlewis: xeqi: cool

1:01 uvtc: amalloy: interesting. Thanks.

1:02 xeqi: amalloy: ohh, thats a good one

1:02 uvtc: Oh, also, I think a ":profiles" keyword would indicate lein2.

1:03 whoops --- xeqi said that already.

1:05 tutysra_: amalloy, I could see all dependencies having full path - org.clojure/clojure "1.4.0" etc, there is no :min-lein-version or : profiles does it still indicate it is lein2?

1:05 amalloy: *shrug*

1:06 most of the time lein2 works. if it doesn't, try lein1

1:06 uvtc: tutysra_: this might be helpful to you: https://github.com/technomancy/leiningen/wiki/Upgrading

1:11 tutysra_: amalloy, uvtc - issue is resolved, I was using a library which uses clojure 1.4.0 with my project which uses clojure 1.3.0, changed my project version and I could compile the files

1:13 uvtc: tutysra_: nice ☺

1:17 samrat: how can I do this: https://www.refheap.com/paste/4359 without using :when twice?

1:19 uvtc: Maybe :when (or (> v 1) (< v 20)) ?

1:20 xeqi: I was thinking `and`, but I never use :when

1:20 uvtc: Oh, whoops. :)

1:21 samrat: uvtc: thanks, putting `and` worked

1:21 uvtc: xeqi: what do you use instead?

1:21 samrat: y/w :)

1:22 xeqi: filter

1:23 not for any good reason

1:23 just the habits I brought with me

1:24 uvtc: Ah. Seems like a `for` with `:when` might be better for perf; instead of first creating a big seq then filtering it afterwards.

1:25 But I guess for most mortal-sized lists it doesn't matter too much. :)

1:25 xeqi: yeah, lack of stream fusion would hurt there

1:27 uvtc: I don't know what "stream fusion" is. Perhaps a new style of music? :)

1:31 xeqi: think smart compiler that turns multiple map/filter/reduce calls into a single walk down the seq

1:33 * uvtc needs to listen to some stream fusion while contemplating that funkadelic notion.

11:41 rplevy: jcromartie: https://github.com/technomancy/swank-clojure/ , M-x clojure-jack-in

11:42 jcromartie: thanks

11:46 dnolen: SWEET, http://www.50ply.com/cljs-bench/

11:46 http://www.50ply.com/blog/2012/08/14/cljs-bench-facelift/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+50plyBlog+%2850Ply+Blog%29

11:47 mmitchell: technomancy: hey there, still hacking on my app trying to get s3wagon private to work. You mentioned hooking into leiningen via repl to do some debugging, how would I do that?

11:49 does my repo key name (in :dependencies) need to be "private", literally? Or is it by the mere presence of "s3p://" that s3 wagon kicks in?

11:53 jcromartie: wow, Emacs 24, latest clojure-mode and paredit

11:53 and "{" still doesn't work!

11:55 clgv: humm repl-y in lein2 is a backstep compared to lein1.x + rlwrap...

11:57 nDuff: jcromartie: I'm using emacs 24 with the emacs live package, and {} works fine for me.

11:58 jcromartie: emacs live package?

11:58 nDuff: jcromartie: https://github.com/overtone/emacs-live/

11:58 ...watch the video linked from the README; it's pretty awesome.

11:59 mmitchell: anyone here using s3wagon private for their dependencies?

11:59 jcromartie: hah, does it actually add that glow to Emacs?

11:59 for some reason I thin that's an embellishment

12:00 nDuff: jcromartie: It's from a video of a presentation

12:00 jcromartie: ...so not an intentional post-processing as much as a camera-in-a-dark-room effect.

12:00 jcromartie: no

12:00 "@Pat Sadly it's post-recording FX."

12:00 :)

12:00 nDuff: Huh.

12:01 rplevy: clgv: I've been wondering if repl-y plans to clean up its act. All I ever see are spews of terminal escape codes

12:01 but it's fine

12:01 borkdude: rplevy what version of lein2/reply are you using (just wondering)

12:02 rplevy: borkdude: let me check...

12:02 preview 7

12:03 clgv: rplevy: yeah thats pretty annoying. I use Pos1 or End often...

12:04 borkdude: rplevy maybe you should file it as a bug on github

12:05 rplevy: good idea, I will make it a point to do that. I just assumed it was known.

12:16 clgv: I hope repl-y improves vastly until lein2 goes stable...

12:16 S11001001: nDuff: the lines in the screenshots are perfectly straight

12:17 clgv: I guess there is no rlwrap-fallback built-in anymore?

12:17 S11001001: implying the camera was very, very far away

12:18 nDuff: S11001001: Conferences tend to have good video recording setups in terms of ideal positioning..

12:18 S11001001: not that perfect

12:20 the CCD pixels would have to perfectly line up with those displaying the different color of the statusbar

12:22 technomancy: clgv: you can trampoline to running clojure.main/main with rlwrap

12:22 clgv: but if you're having problems with reply, please report them; for most people it works way better than the horrid stuff I put in 1.x

12:23 clgv: technomancy: fuctional keys seem not to work, e.g. Pos1, End

12:23 rplevy: I just opened an issue on repl-y for the escape code noise in emacs shell buffer

12:23 technomancy: the only problems I've heard are from having .inputrc interfere and not honoring TERM=dumb

12:23 rplevy: that's the TERM=dumb issue, I think it's fixed if you run from master

12:24 I don't know of a good solution around .inputrc other than just deleting it unfortunately

12:24 clgv: oh ok. so it might improve next preview/stable of leiningen?

12:24 rplevy: ok great, repl-y master or lein master?

12:24 technomancy: clgv: if it's TERM=dumb, yes. I don't know about the inputrc issues or end key.

12:25 rplevy: lein master. if you have a checkout try removing .lein-classpath just to be sure

12:25 rplevy: great, thanks

12:25 technomancy: but honestly there's not much point to running it in an emacs buffer unless nrepl.el isn't working for you

12:25 clgv: rplevy: your name is too similar to "repl-y". I always read you like this ;)

12:27 rplevy: clgv: haha

12:29 clgv: if I were to write a repl (as if there aren't enough) I would call it replevy, which is an actual word. my nick is based on first, middle initials and last name,

12:29 .

12:31 clgv: write a customizable + extendable swing repl ;)

12:32 rplevy: I haven't tried out nrepl, because I mostly use swank-clojure. But sometimes it is easiest to use lein repl within a project, and I live in emacs.

12:33 trptcolin: clgv: we just found out about the home/end thing - see https://github.com/jline/jline2/issues/54

12:33 rplevy: repl-y is a lot nicer than the lein 1.x repl

12:34 technomancy: as the author of 1.x repl, I feel qualified to assert that it sucks

12:34 trptcolin: on ubuntu, anyway, it seems there's something outside of any INPUTRC that sets up keybindings in bash/zsh

12:37 … which we don't [yet?] have access to in jline

12:38 technomancy: you say in the issue it'll be in the next preview of lein; does that mean it's in beta10 of reply or are you shooting for getting beta11 into leiningen preview8?

12:39 otfrom: right. I'm off to the Clojure dojo. Catch you all tomorrow.

12:39 technomancy: trptcolin: ^

12:39 trptcolin: in beta10. i don't have any commits on top of beta10 yet

12:39 technomancy: ok, cool

12:40 trptcolin: this home/end thing is jline, but [at least so far] appears to be fixable via adding bindings to ~/.inputrc

12:40 clgv: technomancy: remaining question: when will preview8 be released?

12:40 technomancy: trptcolin: is there a wiki page or something that covers inputrc?

12:40 hyPiRion: clgv: When it's done, I suspect.

12:40 technomancy: I seem to see a fair number of questions about it

12:40 trptcolin: that's a good idea

12:40 technomancy: clgv: by the end of the week

12:41 clgv: technomancy: oh that's sooner than I expected for "when it's done" ;)

12:43 trptcolin: clgv: if you have a chance, i'd be interested to know whether this workaround fixes your Home/End issue: https://github.com/jline/jline2/issues/54#issuecomment-7747262

12:44 technomancy: if anyone has other considerations for things to go into preview8, please speak up

12:46 clgv: trptcolin: no it did not. I directly uncommented those two lines in /etc/inputrc

12:48 trptcolin: oh right. it *has* to be in the local .inputrc -- there it works!

12:50 cemerick: technomancy: this is happening today?

12:50 preview8, I mean?

12:50 technomancy: cemerick: possibly. at least before the weekend.

12:51 cemerick: OK. Hopefully I can get a beta9 of nREPL out tomorrowish

12:51 Though maybe that's cutting it too close.

12:51 technomancy: what kind of changes does it have?

12:51 in terms of potential for instability

12:52 cemerick: No changes, just additions; though I should probably read the changelog before guaranteeing that.

12:52 technomancy: nevermind, just run with what's been in there.

12:53 technomancy: oh yeah?

12:53 eggsby: M-. in nrepl is magic

12:53 nrepl.el *

12:53 cemerick: Yeah. beta9 will happen this week, and then I can get to grinding down all the rough edges for a final release.

12:54 But whatever goes out should percolate in master for at least a little while before being flung at innocents.

12:54 technomancy: heh; sure.

12:54 leiningen actually doesn't even pull in nrepl directly, just via reply

13:07 spurrow: hi... i have a question about a general programming concept, but i'm not sure what the name is... the idea is you define different method bodies for particular values of the methods arguments

13:08 is it just multi methods?

13:08 ivan: variable-arity functions

13:08 er, maybe multiple arity

13:09 er, pattern matching?

13:09 * ivan should wake up first

13:09 spurrow: so i might do something like: fib(0) = 1; fib(1) = 1; fib(n) = fib(n-1) + fib(n-2);

13:09 (not clojure, sorry!)

13:10 ivan: looks like pattern matching

13:10 https://github.com/clojure/core.match/

13:10 technomancy: yeah, that's pattern matching

13:10 you could sorta do it with multimethods, but they're lower-level

13:11 spurrow: oh great, core.match is exactly what i'm looking for

13:12 S11001001: compiling code that uses core.match brings some of the scalac experience to clojure.core/load :)

13:12 spurrow: S11001001: what do you mean by that?

13:12 is scala famed for its pattern matching?

13:12 S11001001: scalac is famed for taking ages to compile things

13:12 spurrow: lol

13:14 dnolen: S11001001: heh, you must have lots of crazy patterns. haven't put much thought yet on possible optimizations ...

13:15 spurrow: it's an idea that popular outside of mainstream languages - you should read up on pattern matching, CLOS generic methods, predicate dispatch

13:16 S11001001: dnolen: maybe; I'll break it down for you if you're interested, but I think only https://bazaar.launchpad.net/~scompall/+junk/clojure-stuff/view/head:/src/com/nocandysw/cloj_dummy/scala/adt.clj#L80

13:18 dnolen: S11001001: i don't see any relevant to core.match there.

13:18 s/any/anything

13:18 S11001001: fnmatch is a thin wrapper for match

13:20 dnolen: S11001001: ah, w/o seeing what kind of code that typically generates and w/o seeing how often you rely on it - can't say much.

13:20 S11001001: I figured as much

13:25 spurrow: in clj files, why is code not nested within (ns) ?

13:29 nbeloglazov: spurrow: I think it's like syntactic sugar: to avoid indent before each top level command like defn or def.

13:30 spurrow: bummer...why negotiate with terrorists?

13:34 dnolen: S11001001: I poked around is the only place you're using those macros in scala.clj? If so then long compile times seem strange. running all the tests w/ a warmed up JVM takes 1s

13:40 l1x: o hai!

13:40 i am trying to get java.jmx working with my project but no luck yet

13:40 uvtc: hi, l1x.

13:40 l1x: i am following this doc

13:41 https://github.com/clojure/java.jmx/

13:42 S11001001: dnolen: yes

13:42 l1x: https://github.com/l1x/cljmx/blob/master/src/cljmx/core.clj#L10

13:42 this errors out that \* is not supported

13:43 https://gist.github.com/3361874

13:43 if somebody have a minute for a clojure noob, i would appreciate

13:43 dnolen: S11001001: how long does it take for you? and how are you compiling? interactively or at the command line w/ lein?

13:45 S11001001: alternately with C-c C-l and C-c C-k depending on mood

13:45 uvtc: l1x: if that thing on line 10 is a string, you need to put double-quotes around it "\"*:*\""

13:46 s/is/is supposed to be/

13:46 l1x: thx i try that

13:49 uvtc: actually (jmx/mbean-names "*:*") works

13:49 now i need to find a way to print out what it returns

13:51 uvtc: l1x: maybe `(doseq [i (jmx/mbean-names "*:*")] (println i))`?

13:52 treehug: l1x: that line 10 looks like it was copied out of the clojure doc string which would have required the quotes

13:52 l1x: you are awesome dude!

13:52 thx!

13:52 uvtc: l1x: sure, y/w :)

13:59 dnolen: S11001001: so does it take 1s to compile? 10s? 1 minute?

14:02 S11001001: dnolen: 6s

14:04 dnolen: S11001001: slow enough to be annoying. I'll look into possible optimizations when I pick up core.match again.

14:04 l1x: treehug: yep

14:04 treehug: using "*:*" works

14:07 S11001001: not too bad, considering: https://bazaar.launchpad.net/~scompall/+junk/interp-mixed--mainline/view/head:/src/main/scala/com/nocandysw/interpmixed/Tree.scala takes 14s to compile :)

14:20 l1x: how can i iterate through a hashmap?

14:20 (doseq [[k v] (jmx/mbean-names "*:*")] (prn k v))

14:20 this does not work :(

14:20 Exception in thread "main" java.lang.UnsupportedOperationException: nth not supported on this type: ObjectName

14:21 hiredman: l1x: I don't thing mbeen-names returns a hashmap

14:22 l1x: sorry i meant hashset

14:22 hiredman: do you understand what a hashset is?

14:22 and do you understand what the [k v] destructuring in the doseq above is doing?

14:24 l1x: yep, my bad

14:27 hiredman: is there something like in ruby the puts variable.class which tells me what is what

14:29 dnolen: craziness, core.logic querying for Eclipse project from a Smalltalk SOUL dev

14:34 `fogus: I have no idea what that sentence means

14:35 dnolen: `fogus: http://soft.vub.ac.be/SOUL/

14:36 `fogus: SOUL embeds Prolog into Smalltalk, they did some incredible pattern directed metaprogramming work w/ it.

14:36 `fogus: ooooo! Now it's starting to make sense

14:36 (for some value of sense)

14:36 This just gave me an idea for my EL talk

14:50 nDuff: ...so, I'm looking at korma, and it's not clear to me what the expected workflow is for injecting runtime configuration values.

14:51 acheng: hello. destructuring fn args question: can defaults specified by :or be computed from other key/values that were supplied in the call? i.e. :or {key2 (inc key1)}

14:52 l1x: if prn print this [:HeapMemoryUsage {:committed 85000192, :init 0, :max 129957888, :used 17351208}], how can i access the individual elements in the hash?

14:52 nDuff: ...since defdb assigns directly to a var, and expects all the settings for a database to be already present when it's run, I'm not clear on what the sane approach is to wire up connections after namespace load time.

14:53 dnolen: ibdknox: my last bit about SOUL might interest you as well ...

14:55 haspaker: Why won't Clojure read numbers beginning with zero?

14:55 hyPiRion: ,012

14:56 clojurebot: 10

14:56 hyPiRion: octal.

14:56 Chouser1: acheng: that's a great question

14:56 haspaker: Ah

14:56 Chouser1: apparently it depends

14:56 haspaker: Thanks

14:56 uvtc: ,0000

14:56 clojurebot: 0

14:56 `fogus: ,08

14:56 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 08>

14:56 `fogus: That's where octal gets ya!

14:57 hyPiRion: It's kind of scary when you work with floats though.

14:57 ,065.4321

14:57 clojurebot: 65.4321

14:58 hyPiRion: ...well, in Java at least.

14:58 chouser: ,((fn [{a :a, b :b, :or {b (inc a)}}] [a b]) {:a 5})

14:58 clojurebot: [5 6]

14:59 chouser: ((fn [{a :a, :keys [b], :or {b (inc a)}}] [a b]) {:a 5})

14:59 ,((fn [{a :a, :keys [b], :or {b (inc a)}}] [a b]) {:a 5})

14:59 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>

15:01 acheng: chouser: i wonder why that would be the case when you use :keys

15:02 chouser: seems like one can choose between [1] using :keys and adding a let binding to the body of fn to handle those cases and [2] not using :keys and having a more verbose arg list

15:04 chouser: ,(destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}])

15:04 clojurebot: [map__187 {:a 5} map__187 (if (clojure.core/seq? map__187) (clojure.core/apply clojure.core/hash-map map__187) map__187) b ...]

15:04 technomancy: nDuff: indeed; that's a major design flaw in korma

15:05 chouser: hmph. cut off.

15:05 ,(prn (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))

15:05 clojurebot: [map__214 {:a 5} map__214 (if (clojure.core/seq? map__214) (clojure.core/apply clojure.core/hash-map map__214) map__214) b ...]

15:05 chouser: ,(pr-str (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))

15:05 clojurebot: "[map__241 {:a 5} map__241 (if (clojure.core/seq? map__241) (clojure.core/apply clojure.core/hash-map map__241) map__241) b ...]"

15:05 chouser: heh

15:05 acheng: chouser: running low on quarters?

15:06 chouser: (didn't mean for that to sound snarky in any way)

15:06 chouser: heh, I'm not sure what you mean

15:06 anyway, here is the order the bindings are done in: && (take-nth 2 (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))

15:07 ,(take-nth 2 (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))

15:07 clojurebot: (map__29 map__29 b a)

15:07 hyPiRion: Seems like order is important here.

15:07 chouser: ,(take-nth 2 (destructure '[{a :a b :b :or {b (inc a)}} {:a 5}]))

15:07 clojurebot: (map__56 map__56 a b)

15:08 chouser: yeah, so the "or" part is done at the moment the target (b in this case) is bound

15:08 hyPiRion: ,((fn [{a :a, b :b :or {b 2, a (inc b)}}] [a b]) {})

15:08 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>

15:08 hyPiRion: But when reversed, it's okay.

15:08 ,((fn [{b :b, a :a :or {b 2, a (inc b)}}] [a b]) {})

15:08 clojurebot: [3 2]

15:09 chouser: ,(take-nth 2 (destructure '[{:keys [a b c d e]} {}]))

15:09 clojurebot: (map__145 map__145 e d c ...)

15:09 chouser: :keys are bound in reverse order (!)

15:10 acheng: chouser: is that for a good reason?

15:10 chouser: I doubt it was intentional

15:10 hyPiRion: I suspect it's conj on a list in action.

15:11 acheng: chouser: hyPiRion: would it be bad to rely on this behavior of :keys then?... and so one should just skip the use of :keys for this situation?

15:11 chouser: seems like relying on :or expressions having access to other keys in the same map would be to rely on an undocumented implementation detail. Risky in the long term.

15:11 acheng: yeah

15:12 nbeloglazov: &(doc destructure)

15:12 lazybot: ⇒ "([bindings]); "

15:12 acheng: thanks both! followup question: how does one become awesome?

15:12 chouser: You're already awesome, you just have to find people who agree.

15:13 Wait, scratch that. I don't think that's a good philosophy.

15:13 trptcolin: lol

15:13 nbeloglazov: I like it :)

15:13 hiredman: chouser: too late

15:13 you said it, someone slap it on a tshirt

15:13 chouser: acheng: Commenting on Yegge posts makes one awesome.

15:14 no, this is getting worse.

15:14 hiredman: chouser: why don't you stick to "reading is good", seems pretty safe

15:14 chouser: :-)

15:15 hyPiRion: We can do it the Hickey way:

15:16 Awesome - Causing awe or terror; inspiring wonder or excitement.

15:16 mattmoss: Faster? Stronger? More functional?

15:16 hyPiRion: (Look it up in a dictionary)

15:17 uvtc: hammock-driven awesomeness

15:17 acheng: he also said not everything is awesome. so there's a limited number of spots

15:18 hiredman: https://www.youtube.com/watch?v=UPq1_9DsLKk

15:20 chouser: hiredman: now that is awesome.

15:21 hiredman: and it describes software developement pretty well

15:21 mattmoss: hiredma: I actually had six billion dollar man in mind, but that works too.

15:22 uvtc: mattmoss: six *million?

15:22 acheng: uvtc: inflation

15:24 qmx: cemerick: fwiw, bought your book :)

15:24 pandeiro: cemerick: you mentioned an http lib to me last week, specializing in API routing, can you remind me what it's called please?

15:25 cemerick: pandeiro: bishop, perhaps? That's cmiles74's.

15:25 qmx: Hey, thanks :-D

15:25 I hope you like it.

15:26 pandeiro: cemerick: i think that's it; cheers

15:26 clojurebot: cemerick: Yeah, MacKay's book is great too.

15:38 georgek: hi, I just found twhile using hiccup hat there's a bug in java.net.uri such that it chokes on the pipe character; is this something I can file a bug report with Java for? I'm Googling around but not seeing where to go. Also what might be a fix?

15:39 emezeske: georgek: http://stackoverflow.com/questions/1828641/how-to-parse-a-uri-like-this-in-java

15:39 georgek: I don't think it's a bug in java.net.uri -- you just need to encode the special character

15:40 georgek: ah cool, thanks emezeske

15:40 hiredman: georgek: http://www.ietf.org/rfc/rfc2396.txt says pipes are "unwise" in uris and must be escaped

15:40 oh, bleh, I guess stackoverflow works too

15:41 hyPiRion: Use "%7C" instead of "|".

15:41 hiredman: use a a urlencoder

15:42 I like how the rfc defines a character class called "unwise"

15:42 those guys are a hoot and a half

15:43 emezeske: hiredman: Heh, stackoverflow was just the first hit on google :)

15:43 hiredman: !!!!

15:43 new loper-os.org post

15:44 fuh, not about lips though

15:44 lisp

15:47 zerokarmaleft: hiredman: but still proclaiming himself a prophet, more or less?

15:48 hiredman: zerokarmaleft: with an extensive self quotation

16:05 TimMc: Well, he's spot-on here.

16:12 zeromodulus: I tried getting my compojure project to recognize my main namespace, i.e. :main hello-world.core, but it says it can't be found. what am I doing wrong?

16:13 the code is there, under src/hello-world/core.clj

16:13 georgek: does anyone know if I can use pomegranate with nrepl.el? When I did (require '[cemerick.pomegranate :as pomegranate]) it wasn't found on classpath

16:14 I mean as you can with lein2

16:17 solussd: does assoc create a new record when used with records? I thought it returned a hash-map…. is that a recent change?

16:17 zeromodulus: welp, I give up, I'll try again when things are more mature and documented. see ya.

16:17 gfredericks: solussd: I believe it will only switch to a hash-map if you dissoc one of the declared keys

16:18 solussd: so under the hood it's newing up a new record

16:18 gfredericks: solussd: and afaik it's been the same behavior since the beginning

16:18 solussd: cool

16:18 cemerick: I guess 4 minutes is the half-life of a question on irc. Verified experientially. :-P

16:19 S11001001: solussd: try dissocing a vital key

16:20 solussd: yup, that turns it into a hash-map

16:20 cool, that's exactly how I expect/want it to work

16:21 S11001001: oh gfredericks said that already

16:21 gfredericks: indeed it's always been like this

16:27 djanatyn: quick question. I have a list of cities, and a function that takes two cities and finds the distance between them.

16:27 how I can I find the totaly distance in an idiomatic way?

16:27 gfredericks: between all pairs?

16:28 S11001001: shortest route that visits all cities :)

16:28 gfredericks: :P

16:28 Chouser: Heh, I was about to suggest that.

16:28 djanatyn: Well, no, not yet. I just want to find out the length of a route given a list of cities

16:29 that's next!

16:29 gfredericks: djanatyn: partition 2

16:29 S11001001: gfredericks: needs less skipping

16:29 TimMc: djanatyn: Is this a closed loop?

16:29 aperiodic: partition 2 1

16:29 S11001001: ,(doc partition-by)

16:29 metellus: why not reduce?

16:29 clojurebot: "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions."

16:29 Chouser: and reduce

16:29 gfredericks: (apply + (for [[a b] (partition 2 1 cities)] (distance a b)))

16:29 metellus: wait, I know why not.

16:29 S11001001: gfredericks: ah, there it is

16:29 gfredericks: man that was like 8 people answering at once

16:29 djanatyn: mmm. I wanted to use reduce but my function wasn't set up in a way that would work.

16:30 Chouser: djanatyn: it's good for your function to just take two cities. And wanting reduce was also right

16:30 gfredericks: (->> cities (partition 2 1) (map (partial apply distance)) (reduce +))

16:30 Chouser: you just need gfredericks's use of 'for' or similar to glue them together

16:31 djanatyn: I knew to find the sum of the cities I could just #(reduce + %)

16:31 errm, the sum of the distances. I bet there's even a sum function already implemented in contrib or something too

16:31 TimMc: I believe (apply + ...) is better since it allows + to decide on a computation order.

16:31 acheng: zeromodulus: you're gone but i wonder if you have the - vs _ issue.

16:32 Chouser: TimMc: for reasons I don't deeply understand, Rich has recommend 'reduce' in general and for + in particular, though of course your argument is exactly why 'apply' is better for 'str'

16:33 gfredericks: when I run a ring/jetty server, what would cause it to return a gzip'd response?

16:33 TimMc: reduce makes me feel like more of a badass, but apply seems more correct.

16:34 gfredericks: does the response have to be above some threshold size?

16:34 dnolen: @Chouser: I've always suspected that something like reducers was the reason.

16:35 gfredericks: but reduce has order as part of its API

16:35 Chouser: dnolen: yeah I wondered that as I was typing just now, but of course multi-arg + could choose to use reducers if it wants to.

16:35 gfredericks: so it couldn't really do anything else without breaking backwards compat

16:35 dnolen: Chouser: which wouldn't compose right?

16:35 Chouser: gfredericks: good point, where + could know that order doesn't matter and use reducers.

16:37 hm, of course apply calling a variatic fn promises to give you a lazy seq, which is itself ordered and so can't use reducers, right?

16:37 gfredericks: well that's prior to adding

16:38 hiredman: Chouser: I don't recall seeing rich recommend reduce in general and for + in particular

16:38 I seem to recall apply + being faster

16:38 gfredericks: so assymptotically it can still be more efficient but for something fast like + probably not

16:38 Chouser: while if you were using reduce yourself you might have an easier time realizing you could use a reducer to good effect for the particular collection at hand.

16:39 hiredman: ,(time (reduce + (range 1e4)))

16:39 clojurebot: "Elapsed time: 1.349744 msecs"

16:39 49995000

16:39 hiredman: ,(time (apply + (range 1e4)))

16:39 clojurebot: "Elapsed time: 5.568422 msecs"

16:39 49995000

16:39 hiredman: huh

16:39 ~clojurebot

16:39 clojurebot: clojurebot is a multimap

16:39 hiredman: ~benchmarking

16:39 clojurebot: Cool story bro.

16:39 Bronsa: i remembered apply + being faster too

16:39 hiredman: ~clojurebot

16:39 clojurebot: clojurebot is amazing

16:39 hiredman: clojurebot: no you are not

16:39 clojurebot: Excuse me?

16:40 Bronsa: *remember

16:40 Chouser: hiredman: you're going to make me grep the IRC logs, huh?

16:41 metellus: ,(time (reduce + (range 1e4)))

16:41 clojurebot: "Elapsed time: 154.705691 msecs"

16:41 49995000

16:41 metellus: there's more than just apply vs. reduce going on here

16:42 hiredman: Chouser: I think I found it

16:42 b

16:43 Chouser: http://clojure-log.n01se.net/date/2009-01-12.html#13:48

16:43 hiredman: apply lets the function choose how to handle var args, reduce (with the protocol stuff) lets the collection drive how reduction is done

16:45 hyPiRion: Oh, the old common lisp loop.

16:46 TimMc: Function vs. collection: FIGHT!

16:46 What we need here is a protocol.

16:48 gfredericks: amalloy: ping

17:06 djanatyn: wow, I didn't know there was a clojure meetup group in pittsburgh :O

17:07 TimMc: Is it active?

17:07 djanatyn: Yes, they're having a meetup on September 11th. I plan on attending.

17:07 The only other usergroup I've been to was the ruby usergroup, and to be honest, I'm not really into Ruby.

17:09 haspaker: Is there an equivalent of "reduce" that returns all values instead of just the very last one?

17:10 brehaut: reductions

17:10 ,(reductions conj [] [1 2 3])

17:10 clojurebot: ([] [1] [1 2] [1 2 3])

17:10 haspaker: Brilliant

17:12 leandro: how do i get the current function's name?

17:13 nDuff: leandro: The current function often won't _have_ a name at all. What's the context?

17:13 leandro: log, i'd line to log this information.

17:13 line=like

17:14 nDuff: *nod*; ahh.

17:14 The normal JVM-centric methods work, though they're pretty slow.

17:14 IIRC, log4j has that support built in

17:14 so there's something you can use in your format strings which will indicate where your code is

17:15 having it be user-configured that way is probably best -- that way they can choose whether to eat the performance penalty

17:15 leandro: it helped soo much. ty.

17:17 nDuff: i'll continue to use a hardcoded string. =)

17:40 solussd: why does this fail? &(let [b 5] (for [item '[b]] (eval item)))

17:40 ,(let [b 5] (for [item '[b]] (eval item)))

17:40 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

17:40 solussd: well, it fails with a b doesn't exist in my repl

17:40 if I (def b 5), it works

17:41 emezeske: solussd: Why do you have the quote on '[b] ?

17:41 dnolen: solussd: eval doesn't work with locals.

17:41 solussd: emezeske: bc I want the name of the symbol in the body of the for

17:41 dnolen: thanks

17:41 bosie: is there a documentation that is better than the official one?

17:42 acagle_: /flush

17:42 solussd: dnolen: is there a way to get the local value?

17:42 dnolen: bosie: Clojure official docs are nice IMO - but there are some truly excellent books now as well if you're just starting.

17:42 solussd: not w/ eval.

17:43 bosie: dnolen: just starting. java/ruby background

17:43 solussd: clojuredocs.org is nice, sometimes.

17:43 dnolen: bosie: O'Reilly Clojure Programming is pretty darn good

17:43 bosie: dnolen: i find them undigestable, like examples would be helpful ;)

17:43 solussd: nice

17:44 dnolen: bought it

17:44 Raynes: $examples eval

17:44 lazybot: You must pass a name like clojure.core/foo or, as two arguments, clojure.core foo.

17:44 dnolen: bosie: covers language, idioms & tooling. clojuredocs.org is nice for examples. accessible from lein2 repl as well.

17:44 Raynes: $examples clojure.core/eval

17:44 lazybot: https://www.refheap.com/paste/4400

17:44 Raynes: These are extracted from clojuredocs.

17:44 bosie: how would i go about figuring out what line 1 does: http://biomunky.wordpress.com/2010/03/17/clojure-read-a-file/

17:44 Raynes: Well you could ask here like you just did.

17:44 :p

17:45 bosie: Raynes: hah, sure but i couldn't figure out from the docs how to read it

17:45 Raynes: Line one of the first example?

17:45 bosie: Raynes: yes

17:45 Raynes: The namespace stuff is particular hard to understand.

17:45 bosie: Raynes: the whole '[] business

17:45 Raynes: The docs for them are designed to be thorough and not necessarily easy.

17:46 In this case, it's "Mr. Clojure sir, could you please let me use the 'reader' function/macro from the 'clojure.java.io' namespace? I don't want to be able to access everything, just 'reader'."

17:47 bosie: the equivalent of import clojure.java.io.reader

17:47 i take it?

17:47 solussd: dnolen, I can accomplish what I want with macrolet!!!! :D

17:47 dnolen: bosie: one thing you'll encounter is a lot of things that require special syntax in other languages tend to be first class features in Clojure.

17:47 solussd: nice

17:47 Raynes: Well, no, because you just said has no meaning in Clojure.

17:47 :p

17:47 bosie: Raynes: sure

17:47 solussd: i've wanted an excuse to use it.

17:48 bosie: Raynes: so what is '[] ?

17:48 a function in itself?

17:48 dnolen: bosie: so yes, that dynamically loads the file according. '[...] will contain the usual syntax for importing.

17:48 Raynes: It's a quoted vector.

17:48 bosie: hm

17:49 Raynes: It means "Hey, please don't evaluate the things inside this vector." Since 'use' is a function and not a macro, it can't control evaluation and thus if you did (use [foo :only [bar]]), Clojure would try to resolve the symbols 'foo' and 'bar' and it would fail.

17:49 bosie: oh

17:50 hm

17:50 so in what "state" is [] in?

17:50 nDuff: "state"?

17:50 clojurebot: mutable state is bad

17:50 dnolen: bosie: it's just a piece of data.

17:51 bosie: nDuff: in the sense that it kindad is a vector but apparently not evaluated, so it just gets 'held' somehow without being executed?

17:51 like a lazy sequence?

17:51 dnolen: ,(let [a b] [[a b] '[a b]])

17:51 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>

17:51 metellus: ,(let [a 1, b 2] [[a b] '[a b]])

17:51 clojurebot: [[1 2] [a b]]

17:51 dnolen: oops, thx metellus

17:52 bosie: ^

17:52 Raynes: bosie: It isn't anything spectacular. It just isn't evaluated.

17:52 bosie: k

17:52 Raynes: bosie: In Clojure, things are read and then they are evaluated. A quote prevents that evaluation part of things.

17:52 bosie: Raynes: so its simply held as a string until needed?

17:53 nDuff: bosie: The vector is evaluated as a vector.

17:53 bosie: ...the symbols within it aren't resolved.

17:53 bosie: ...but there's no kind of lazy / just-in-time behavior involved.

17:53 bosie: k

17:53 Raynes: FWIW, Clojure behavior is often a lot more simpler than you think.

17:54 bosie: Raynes: so it isn't like haskell? ;)

17:54 Raynes: Haskell is super easy.

17:54 :D

17:54 bosie: Raynes: i didn't find it easy at all :(

17:54 makes me wonder if i am not cut out for FP

17:54 nDuff: bosie: ...you just get clojure.lang.Symbol objects rather than, well, whatever foo or bar would point to if they were defined.

17:54 Raynes: bosie: I was kidding.

17:54 Haskell can be overwhelming sometimes.

17:55 Things like what we're talking about here can be difficult to understand at a distance. Once you've used things a bit, it'll start to make sense.

17:56 bosie: Raynes: k

17:56 Raynes: i honestly hope so ;)

17:57 metellus: ,(let [a 1] [(class a) (class 'a)])

17:57 clojurebot: [java.lang.Long clojure.lang.Symbol]

17:57 haspaker: Is there a function that returns the first item of a lazy sequence that satisfy a certain condition?

17:58 joegallo: (first (filter ... ...))

17:58 haspaker: Of course

17:58 Feel a bit stupid now :>

17:59 Raynes: haspaker: It isn't immediately obvious to most people, but it works because filter is lazy and thus just getting the first element doesn't cause (much) unnecessary computation.

17:59 joegallo: sometimes (some .......) is the right thing, though, too. But the semantics are different.

18:00 haspaker: Yeah

18:00 joegallo: (first (filter x y)) returns the first value from y for which x returns truthy

18:00 (some x y) returns the first truthy return value of x, which *always* tricks me.

18:00 haspaker: I mostly felt stupid because I have used (first (filter …)) on other occasions but did not realize I could do it here as well

18:01 joegallo: no worries. we shall strike this conversation from the chat logs, it'll be like it never happened.

18:01 ;)

18:01 haspaker: Brilliant :P

18:03 dnolen: bosie: lots of new stuff to learn. fortunately people here are nice and helpful :)

18:03 bosie: dnolen: yup that seems

18:03 dnolen: to be the case. seems to be the case in quite a few FP languages ;)

18:06 thanks Raynes / dnolen

18:11 eggsby: why can't you use == on keywords?

18:11 ,(== :foo :foo)

18:12 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>

18:12 hiredman: ,(doc ==)

18:12 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums all have the equivalent value (type-independent), otherwise false"

18:12 hiredman: == is for numbers only

18:12 eggsby: ah, and =

18:12 I see

18:13 thanks hiredman

18:15 joegallo: ,(doc identical?)

18:15 clojurebot: "([x y]); Tests if 2 arguments are the same object"

18:15 joegallo: (== :foo :foo)

18:15 ,(== :foo :foo)

18:15 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>

18:15 joegallo: ,(identical? :foo :foo)

18:15 clojurebot: true

18:15 eggsby: hm

18:15 joegallo: phew, just checkin'

18:15 nkoza: there is a more succint way to do this, without using update-in?: (update-in {:a 1} [:a] #(inc %))

18:16 eggsby: nkoza: the #(%) is unnecessary

18:16 ,(update-in {:a 1} :a inc)

18:16 clojurebot: #<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Keyword>

18:16 eggsby: oops

18:16 ,(update-in {:a 1} [:a] inc)

18:16 clojurebot: {:a 2}

18:16 nkoza: using update-in is the common idiom to update a key in a map?

18:17 hyPiRion: ,(merge-with + {:a 1} {:a 1})

18:17 clojurebot: {:a 2}

18:17 nDuff: nkoza: Very.

18:17 nkoza: (without nested maps)

18:17 metellus: ,(assoc {:a 1} :a 2)

18:17 clojurebot: {:a 2}

18:17 nkoza: I thought update-in was only for nested maps

18:17 eggsby: nkoza: it works with nested maps, you just define your 'path' to the data

18:17 ,(update-in {:a {:b 1} [:a :b] inc)

18:17 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>

18:17 eggsby: oops

18:17 :3

18:17 you get the idea

18:17 amalloy: nkoza: yes, use update-in whether you have nested maps or not

18:17 nkoza: ok, thanks

18:18 ToxicFrog: amalloy: why is it preferred to use update-in for non-nested maps rather than assoc?

18:18 amalloy: (assoc x :birthday (inc (get x :birthday))) ;; so gross

18:18 metellus: I was about to ask the same thing when I realized that eggsby wanted to modify the existing value

18:19 amalloy: (update-in x [:birthday] inc) ;; so clear

18:19 nkoza: ToxicFrog: i was searching how to update a map with a transformation of the existing value, assoc is for putting a new one or replacing the previous

18:19 ToxicFrog: nkoza: aah, ok

18:20 amalloy: and it just gets more extreme when you're computing x somewhere else: you have to let-bind it to make the assoc version work

18:20 ToxicFrog: Yeah, I missed that bit

18:23 hyPiRion: Hm, is there a specific reason to have update-in, but not update? It seems weird considering assoc exists, even though assoc-in would be enough.

18:23 amalloy: for the same reason we have dissoc but not dissoc-in

18:23 it's not entirely obvious what update does

18:24 mabes: I have a ns as a symbol, how can I resolve the ns so that I can then use ns-resolve with it?

18:24 ,*ns*

18:24 clojurebot: #<Namespace sandbox>

18:24 mabes: I'd like to say something like:

18:24 amalloy: (update m [:x :y] inc) ;; what does this do, hyPiRion?

18:24 mabes: ,(resolve 'sandbox)

18:24 clojurebot: nil

18:24 hiredman: http://clojure.org/namespaces

18:25 hyPiRion: amalloy: I myself consider it the same as (update-in m [[:x :y]] inc)

18:26 Which is like ##(update-in {[:x :y] 1} [[:x :y]] inc)

18:26 lazybot: ⇒ {[:x :y] 2}

18:26 mabes: ,(find-ns 'sandbox)

18:26 clojurebot: #<Namespace sandbox>

18:26 mabes: thanks hiredman :)

18:26 hyPiRion: Exactly the same relation assoc and assoc-in has.

18:26 amalloy: hyPiRion: not exactly the same

18:26 assoc and dissoc can accept multiple keys

18:27 hyPiRion: ,(assoc [0 0] [0 1] inc)

18:27 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>

18:27 amalloy: what you said is how it would probably work if it existed. but wouldn't it be equally useful to have it act like (-> m (update-in [:x] inc) (update-in [:y] inc))?

18:27 hyPiRion: Oh, gotcha.

18:28 amalloy: &(assoc nil :a 1 :b 2)

18:28 lazybot: ⇒ {:b 2, :a 1}

18:28 amalloy: anyway, that's unclear, which i think is why it doesn't exist

18:30 hyPiRion: so not immediately obvious what the function does.

18:33 So what's the reason for not accepting multiple key-vectors for assoc-in then?

18:39 djanatyn: one more quick question ^_^; if I have a list of maps, and I want to find the maximum value for one of the keys, how would I go about doing that idiomatically?

18:40 I can't just (max (map #(:key %) list)) because then I lose the other values in the map

18:42 amalloy: &(doc max-key)

18:42 lazybot: ⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."

18:42 djanatyn: thank you amalloy!

18:43 man, clojure sure does have a lot of convenient functions

18:45 madsy: djanatyn: Yeah. Discovering all of them can be a chore :)

18:45 Even clojure.core has tons

18:45 cpinera: Hi all. I'm attempting to create an uberjar with Leiningen, and both clojure-1.3.0 and clojure-1.4.0 jars are being included. I'm assuming one or several dependencies are causing it. Is there a way for me to have leiningen not to include the jar for clojure-1.3.0?

18:45 hyPiRion: What's the best way of finding these nuggets? Just dive into the source code?

18:46 aperiodic: http://clojure.org/cheatsheet

18:47 madsy: cpinera: There should be a project.clj setting for excluding jars. Check the example files on the Leiningen github page

18:48 cpinera: madsy: I'm using :uberjar-exclusions [#"clojure-1.3.0.jar"] but the jar is still being included...

18:48 technomancy: cpinera: what version of leiningen?

18:48 cpinera: technomancy: I was on version 2 preview 7 and then I upgraded to the latest in the trunk

18:49 madsy: cpinera: Hm, not sure then. Maybe ask on #leiningen ?

18:49 cpinera: madsy: You are correct. Thanks!

18:49 technomancy: cpinera: is it a fork of clojure with a separate group-id?

18:49 hyPiRion: aperiodic: That doesn't cover much.

18:50 technomancy: hyPiRion: you pretty much have to hang out on IRC =)

18:50 aperiodic: hyPiRion: what else are you looking for? i've found it to be pretty comprehensive

18:50 technomancy: there's no substitute

18:50 hyPiRion: For example, you'll never find ##(unchecked-byte 255) there.

18:50 lazybot: ⇒ -1

18:50 cpinera: technomancy: not as far as I can see. I got it directly from https://github.com/technomancy/leiningen, branch: master

18:50 technomancy: cpinera: i mean in your project

18:50 cpinera: does `lein deps :tree` list two versions of clojure?

18:51 cpinera: technomancy: ah yes, you are correct. I'm doing Android development, and I'm using [android/clojure "1.4.0"] as a dependency

18:51 technomancy: cpinera: ok, in that case you have to use :exclusions

18:52 hyPiRion: But okay, I'll just hang in here to find those diamonds.

18:52 cpinera: technomancy: Understood. How would it look like? e.g. [clj-time "0.4.3" :exclusions [org.clojure]] ?

18:53 technomancy: cpinera: normally you would add it inside :dependencies, but for something like clojure there are too many libs pulling it in, so you wouldn't want to add an entry for each one. so you can use a top-level :exclusions [org.clojure/clojure]

18:53 amalloy: hyPiRion: you'll never learn them all anyway. i think my knowledge of clojure.core is pretty encyclopedic, and yet just today i found out about ##(doc release-pending-sends)

18:53 lazybot: ⇒ "([]); Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent actions immediately. This has no impact on actions sent during a tr... https://www.refheap.com/paste/4401

18:54 hyPiRion: amalloy: That's a pessimistic look on it :(

18:54 cpinera: technomancy: Perfect! Thank you very much indeed, I really appreciate your help.

18:54 technomancy: no problem

18:54 amalloy: only if you feel pessimistic about it

18:55 i also recently found out about ##(doc sequence), which is like the opposite of seq. i'd been using lazy-seq for that purpose till last week

18:55 lazybot: ⇒ "([coll]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields ()"

19:01 djanatyn: >_<

19:01 this is so much harder than it should be

19:02 so, I have a list of maps. the maps are in the format of {:distance foo :route bar}

19:02 I'm trying to find the map in that list that is the biggest. so I need to use 'max-key and apply.

19:03 hyPiRion: Is the biggest by distance or route, or both?

19:03 djanatyn: so, the function I'm using for max-key to compare is #(:distance %).

19:03 gfredericks: :distance works too

19:04 hyPiRion: #(:distance %) is not a nice key to compare with.

19:04 or nevermind.

19:04 djanatyn: oh. okay, distance works

19:05 but when I try (apply #(max-key :distance %) list-i-mentioned-earlier), I get an error! because the function I'm using with apply only accepts one argument >_>

19:05 amalloy: (apply max-key :distance ...)

19:05 djanatyn: you seem to just be wrapping everything in lambdas just in case :P

19:06 kenneth: hey, is there an option to `lein uberjar` to specify which filename to create the uberjar at

19:06 djanatyn: but I thought that function would apply

19:06 ...

19:06 oh

19:06 *headdesk*

19:06 I *do* want to pass :distance to max-key :)

19:06 thank you.

19:06 gfredericks: ~headdesk

19:06 clojurebot: Excuse me?

19:07 gfredericks: clojurebot: headdesk is botsmack

19:07 clojurebot: c'est bon!

19:07 metellus: ~headdesk

19:07 clojurebot: headdesk is botsmack

19:07 gfredericks: ~headdesk

19:07 metellus: ~botsmack

19:07 clojurebot: headdesk is botsmack

19:07 Owww!

19:07 gfredericks: ~headdesk

19:07 clojurebot: headdesk is botsmack

19:07 gfredericks: ~headdesk

19:07 clojurebot: headdesk is botsmack

19:07 gfredericks: what happened to inference?

19:07 hyPiRion: ~botsnack

19:07 clojurebot: Thanks, but I prefer chocolate

19:07 metellus: ~chocolate

19:07 clojurebot: Cool story bro.

19:07 amalloy: gfredericks: it's working, you just got unlucky

19:08 gfredericks: amalloy: getting unlucky 4 times in a row is inconceivable

19:08 I have inconceived of it

19:08 djanatyn: ...woooooooo

19:08 okay

19:08 amalloy: ~headdesk

19:08 clojurebot: clojurebot evades successfully!

19:09 djanatyn: after a few days I now have a working implementation that will bruteforce any number of cities in the travelling salesman problem :D :D :D

19:09 in clojure!

19:10 gfredericks: djanatyn: so what're you going to sell?

19:11 djanatyn: uhh

19:11 clojure consulting?

19:22 I have a feeling (->) and (->>) are really important and useful functions

19:24 emezeske: djanatyn: s/functions/macros :)

19:24 gfredericks: they're just sugar

19:24 important and useful for readability perhaps

19:26 l1x: hey guys noob question, how can i create a hash in clojure?

19:27 TimMc: l1x: Are you talking about cryptographic primitives or associative data structures?

19:27 l1x: second

19:28 TimMc: l1x: http://clojure.org/data_structures#Data%20Structures-Maps%20%28IPersistentMap%29

19:28 l1x: this returns a hash (jmx/mbean "java.lang:type=Memory") i would like to store it and refernce the nested part

19:29 TimMc: Oh, a Java bean? You may want to `bean` on it.

19:32 l1x: in ruby i would reference it the following way parent[:nested_hash] (where parent ={:hash =>value , :nested_hash => {:super_deep_key => value}}

19:32 i would like to do something similar

19:34 emezeske: ,(get-in {:a {:b 42}} [:a :b])

19:34 clojurebot: 42

19:35 l1x: emezeske: thx

19:35 emezeske: l1x: You can of course just do it the long way too: &&(:b (:a {:a {:b 42}}))

19:35 err

19:35 ,(:b (:a {:a {:b 42}}))

19:35 clojurebot: 42

19:36 l1x: k

19:36 thx

19:40 jlewis: hi

19:41 zer: (let [m (transient {})]

19:41 (dotimes [n 12]

19:41 (assoc! m (keyword (str n)) n))

19:41 (persistent! m))

19:41 jlewis: can you determine whether a PersistentHashMap has an entry with a null key in it?

19:41 zer: (let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))

19:42 &(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))

19:42 lazybot: ⇒ {:0 0, :1 1, :2 2, :3 3, :4 4, :5 5, :6 6, :7 7}

19:42 emezeske: jlewis: I think contains? does what you want maybe

19:42 ,(contains? {:a 1} :b)

19:42 clojurebot: false

19:42 emezeske: ,(contains? {:a 1 :b nil} :b)

19:42 clojurebot: true

19:43 zer: &(clojure-version)

19:43 lazybot: ⇒ "1.4.0"

19:43 zer: ,(clojure-version)

19:43 clojurebot: "1.4.0-master-SNAPSHOT"

19:43 zer: ,(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))

19:43 clojurebot: {:0 0, :1 1, :2 2, :3 3, :4 4, ...}

19:44 jlewis: emezeske: i'm specifically asking about null *keys*, not null values

19:44 zer: ,(clojure.pprint/pprint (let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m)))

19:44 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.pprint>

19:44 amalloy: zer: :((((((((((((((((((((( transients aren't mutable objects

19:44 jlewis: the implementation has a special case for this - it has a boolean hasNull that it keeps around

19:44 zer: hm, this is how i treat them

19:44 emezeske: jlewis: Oh, I misread you

19:44 jlewis: i'd like to determine whether the map has a null key or not, but hasNull unfortunately is package private... :) this is from java, by the way

19:45 package protected*

19:45 amalloy: zer: you are treating them wrong, then, which is why you don't get the behavior you want

19:45 emezeske: jlewis: (contains? {nil 42} nil) does not work for your purpose?

19:45 zer: should i work with the return value of assoc! instead?

19:45 amalloy: yes

19:45 they're allowed to mutate, but not required to

19:46 zer: still a bit confusing, that my hash-map gets filled with 8 values instead of 1

19:46 err 12

19:46 jlewis: emezeske: that always returns false

19:46 emezeske: ,(contains? {nil 42} nil)

19:46 jlewis: ,(contains? {nil 1} nil)

19:46 clojurebot: true

19:46 true

19:46 jlewis: err

19:46 wtf

19:46 amalloy: zer: well, the first 8 times it decides to mutate, and the ninth time it decides to return a new object

19:46 jlewis: ,(contains? {3 1} nil)

19:46 clojurebot: false

19:47 jlewis: ?!?! i'm confused. i observed contrary behavior to this before

19:47 zer: ah ok, ty

19:47 i wonder why you would want to return a new object instead of mutating

19:47 jlewis: emezeske: thanks, my test was screwed up. :)

19:48 zer: treating transients as mutable would be quite handy

19:48 amalloy: &(class (transient {}))

19:48 lazybot: ⇒ clojure.lang.PersistentArrayMap$TransientArrayMap

19:48 emezeske: jlewis: No prob :)

19:48 amalloy: &(class (transient {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20))

19:48 lazybot: java.lang.RuntimeException: Unmatched delimiter: )

19:48 amalloy: &(class (transient {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}))

19:48 lazybot: ⇒ clojure.lang.PersistentHashMap$TransientHashMap

19:49 zer: aah right

19:49 amalloy: zer: and no, treating them as mutable wouldn't be handy; you'd be back in the soup of mutable-state

19:50 zer: well, i like it, when constructing things, just applying sequentiel mutations and not caring about the return value

19:50 amalloy: just use ->

19:50 georgek: hi, can anyone tell me what might be a typical problem that causes the error "clojure.lang.Var$Unbound cannot be cast to clojure.lang.Symbol"

19:51 amalloy: &(-> (transient {}) (assoc! :x 1) (assoc! :y 2) persistent!)

19:51 lazybot: ⇒ {:x 1, :y 2}

19:51 zer: yes, this is what i will do from now on ty again

19:52 hiredman: georgek: calling resolve incorrectly

19:54 Gnosis-: what's the equivalent of subvec for a seq?

19:55 emezeske: Gnosis-: I think I usually end up using take and drop for that

19:55 Gnosis-: hmm, okay

19:57 georgek: thanks hiredman

19:57 Gnosis-: also, it looks like BigInts don't support a lot of bit-* operations

20:00 georgek: I'm working with a library with two files which I require in my ns; file A has a call to a function X. There's a function in file B that I think depends on the call to function X. If I require both files into my ns, is the call to function X in file A 'automatic'

20:00 in other words, so file B can then rely on it?

20:01 this is the lib, https://github.com/ngrunwald/clj-rome/tree/master/src/clj_rome

20:01 I think the translate fn in fetcher.clj relies on register-converters in reader.clj

20:09 Gnosis-: how do I test if something is an array?

20:12 georgek: Gnosis, do you mean this, http://stackoverflow.com/questions/9090396/testing-whether-an-object-is-a-java-primitive-array-in-clojure

20:12 Gnosis-: yeah

20:13 also, why the hell are bytes signed in Java?

20:15 georgek: the Class/forName thing worked for what I needed, thanks!

20:20 zer: shame, i cant do

20:20 (-> (transient {}) #(if pred (assoc! % :a 'a) %) persistent!)

20:20 is there any way that does not use let for each conditional or an atom?

20:27 gfredericks: ,(-> (transient {}) (#(if pred (assoc! % :a 'a) %)) persistent!)

20:27 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pred in this context, compiling:(NO_SOURCE_PATH:0)>

20:27 gfredericks: ,(-> (transient {}) (#(if true (assoc! % :a 'a) %)) persistent!)

20:27 clojurebot: {:a a}

20:27 gfredericks: zer: you just gotta respect how -> works is all

20:28 zer: sweet

20:40 gfredericks: so if I want to be able to use #bytes [1 2 3], do I just go define that myself or is there a standard library or something for these things?

20:41 amalloy: gfredericks: do it yourself. but you need to use a namespaced tag; others are reserved for clojure.core

20:42 gfredericks: how does this work with lein libraries? I put the file in /src?

20:42 amalloy: yeah

20:42 at one of the classpath's roots

20:43 gfredericks: coothx.

20:44 incidentally how does clojure or anything handle situations with identically named files all at the root of the classpath?

20:48 pepijndevos: you probably get the one thats on the path first?

20:48 gfredericks: I guess there must be an API for getting multiple files with one name

20:49 "When Clojure starts, it searches for files named data_readers.clj at the root of the classpath."

20:50 hiredman: gfredericks: classloaders have a getResources method

20:51 gfredericks: hiredman: entiendo

20:51 also the 1.4 changelog doesn't mention how you go about writing reader tags

20:51 does this preclude pr-str?

20:52 hiredman: you muck with print-method or whatever

20:52 gfredericks: ah

21:23 * nDuff grumbles at korma describing itself as "composeable" while being full of macros

21:36 Scriptor: overtone seems to crash whenever I try running it from the slime repl

21:36 otherwise works fine from the command-line

21:37 casion: Scriptor: I've not been able to get overtone working with slime myself

21:40 Scriptor: casion: does java crash every time you try (use 'overtone.live) ?

21:40 casion: Scriptor: yep

21:40 Scriptor: have you tried with the external server?

21:40 casion: there was another mysterious freeze at times that I never could figure out

21:40 no I havent, I gave up on it

21:41 tetrad_: HiroProtagonist: www.siliconmicrodisplay.com/st1080.html

21:41 casion: I use supercollider directly, so getting overtone working is not a high priority for me

21:52 gfredericks: (inc tagged-reader-literals)

21:52 lazybot: ⇒ 1

22:06 aniero: (take 3 (repeatedly (constantly "heh")))

22:09 xeqi: ,(repeate 3 "heh")

22:09 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: repeate in this context, compiling:(NO_SOURCE_PATH:0)>

22:09 xeqi: ,(repeat 3 "heh")

22:09 clojurebot: ("heh" "heh" "heh")

22:13 aniero: :)

22:15 is it better to do (zipmap ks (repeatedly (constantly val))) or (zipmap ks (repeat (count ks) val)) ? style choice?

22:15 casion: ,"hehhehheh"

22:15 clojurebot: "hehhehheh"

22:15 casion: you guys should write more concise code ;)

22:17 * wmealing_1 looks at clojurebot

22:17 xeqi: &(zipmap [:a :b :c] (repeat "heh"))

22:17 lazybot: ⇒ {:c "heh", :b "heh", :a "heh"}

22:17 aniero: ohh, length is optional in repeat, thanks!

23:03 Gnosis-: how do I get a helpful stacktrace at the REPL?

23:03 Raynes: (.printStackTrace *e)

23:06 Gnosis-: it looks like a big mishmash of .invoke(...) to me :(

23:16 jlewis: when is it possible that a PersistentHashMap would return an entry with key and value = null, and yet not have hasNull set?

23:16 i'm trying to track down a bug in my program, and it's proving difficult - I can't find out how that null entry gets in the map

23:22 muhoo: well, i'm 50% of the way to convincing a customer to let me deliver the user interface for an android tablet app in cljs. this will be interesting.

23:35 lpvb: /close

23:38 amalloy: jlewis: i don't know why you would ever find out that it has hasNull set

23:38 aniero: aha, (take-while identity ...) instead of (take-while (complement nil?) ...)

23:39 jlewis: amalloy: i'm using PersistentHashMap from java. I'm trying to debug this issue, and I'm noticing the unexpected behavior that there's a null->null pair in the entry set of the map, yet hasNull is not set

23:40 i don't assoc a null anywhere... i'm kind of at my wit's end :)

23:40 amalloy: and you're looking at its hasNull in a debugger then?

23:40 jlewis: yes

23:42 amalloy: i don't think that behavior is possible, and i don't think anyone can debug it without seeing what code you're building up the map with

23:43 jlewis: i was afraid someone would say that... i don't have anything near to a minimal test case

23:46 amalloy: oh, i suppose it is very much worth mentioning that i am using https://github.com/krukow/clj-ds, not clojure itself. perhaps it has a bug.

23:46 lynaghk: muhoo: we're doing a cljs iPhone app right now. Might be fun to compare notes sometime.

23:47 amalloy: gosh. probably it has a bug, then

23:47 jlewis: that is a serious bummer!

23:57 muhoo: lynaghk: cool, yes it would

Logging service provided by n01se.net