#clojure logs

2012-08-15

00:34tolstoyIs there a way to shut down Emacs (when slime is attached to swank) without killing the JVM and/or causing an exception in Swank?
00:35tolstoy,sayonara and ,quit cause swank to shut down the JVM, so that's not it….
00:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sayonara in this context, compiling:(NO_SOURCE_PATH:0)>
00:35tolstoyOops. Sorry clojurebot.
00:41amalloytolstoy: the only way i know is to start a swank server independent of emacs (ie, lein-swank+slime-connect, rather than clojure-jack-in)
00:41amalloythen you can just kill the *swank* buffer to disconnect
00:42tolstoyamalloy: That's what I've done. "lein trampoline run" and in the start up sequence I start up swank (just for fun).
00:42shawnlewisany opinions on clojure (sql) database migration and query libraries?
00:43tolstoyWhen 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.
00:44amalloytolstoy: you're doing something weird, then. i do the same thing and it works fine
00:44tolstoyOkay. Good to know.
00:44shawnlewislooks like lobos and korma were good options, but no longer work together due to https://github.com/budu/lobos/issues/43
00:45amalloythe startup code looks like (do (stuff) (swank/start-server :host host :port port) (stuff))
00:46tolstoyYeah, that's what I have, except no :host param.
00:47tolstoy(defn- start-swank() (log/info "starting swank") (swank/start-server :port 4005))
00:48tolstoyexception in control loop java.lang.InterruptedException java.lang.Exception: Error reading swank message
00:49tolstoyOops, that's a [] not (). Anyway, probably just some mismatch somewhere along the line.
00:51tolstoyHm. Maybe I need slime-clj.
00:51amalloyNOOO
00:51amalloyso old and evil
00:51tolstoyAh, ok. Phew!
00:54xeqitolstoy: I would get a stack trace when I closed emacs as well, can't remember if M-x slime-disconnect would cause it
00:55amalloyyou're talking about closing all of emacs, not just disconnecting? i dunno then; i never close emacs
00:56tolstoyxeqi: Yeah, slime-disconnect gives me the same stack trace in the JVM/swank process.
00:56tolstoyThe st happens regardless. But "slime-disconnect" was what I was looking for.
00:57amalloyhttps://gist.github.com/3356076 to fix the bug that allows emacs to stop running
00:58xeqishawnlewis: theres also https://github.com/weavejester/ragtime for migrations
00:58tutysra_can i tell whether a project should use lein2 or can be used with lein1 by looking at the project.clj file
00:58xeqithough in clojars technomancy just made his own script for us https://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj
00:59xeqitutysra_: some have a :min-lein-version, :source-path vs :source-paths is a way, :profiles are lein2 only
01:00xeqithere are other keys, but those seem to be the main ones
01:01amalloytutysra_: 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
01:01shawnlewisxeqi: cool
01:01uvtcamalloy: interesting. Thanks.
01:02xeqiamalloy: ohh, thats a good one
01:02uvtcOh, also, I think a ":profiles" keyword would indicate lein2.
01:03uvtcwhoops --- xeqi said that already.
01:05tutysra_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?
01:05amalloy*shrug*
01:06amalloymost of the time lein2 works. if it doesn't, try lein1
01:06uvtctutysra_: this might be helpful to you: https://github.com/technomancy/leiningen/wiki/Upgrading
01:11tutysra_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
01:13uvtctutysra_: nice ☺
01:17samrathow can I do this: https://www.refheap.com/paste/4359 without using :when twice?
01:19uvtcMaybe :when (or (> v 1) (< v 20)) ?
01:20xeqiI was thinking `and`, but I never use :when
01:20uvtcOh, whoops. :)
01:21samratuvtc: thanks, putting `and` worked
01:21uvtcxeqi: what do you use instead?
01:21uvtcsamrat: y/w :)
01:22xeqifilter
01:23xeqinot for any good reason
01:23xeqijust the habits I brought with me
01:24uvtcAh. Seems like a `for` with `:when` might be better for perf; instead of first creating a big seq then filtering it afterwards.
01:25uvtcBut I guess for most mortal-sized lists it doesn't matter too much. :)
01:25xeqiyeah, lack of stream fusion would hurt there
01:27uvtcI don't know what "stream fusion" is. Perhaps a new style of music? :)
01:31xeqithink smart compiler that turns multiple map/filter/reduce calls into a single walk down the seq
11:41rplevyjcromartie: https://github.com/technomancy/swank-clojure/ , M-x clojure-jack-in
11:42jcromartiethanks
11:46dnolenSWEET, http://www.50ply.com/cljs-bench/
11:46dnolenhttp://www.50ply.com/blog/2012/08/14/cljs-bench-facelift/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+50plyBlog+%2850Ply+Blog%29
11:47mmitchelltechnomancy: 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:49mmitchelldoes 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:53jcromartiewow, Emacs 24, latest clojure-mode and paredit
11:53jcromartieand "{" still doesn't work!
11:55clgvhumm repl-y in lein2 is a backstep compared to lein1.x + rlwrap...
11:57nDuffjcromartie: I'm using emacs 24 with the emacs live package, and {} works fine for me.
11:58jcromartieemacs live package?
11:58nDuffjcromartie: https://github.com/overtone/emacs-live/
11:58nDuff...watch the video linked from the README; it's pretty awesome.
11:59mmitchellanyone here using s3wagon private for their dependencies?
11:59jcromartiehah, does it actually add that glow to Emacs?
11:59jcromartiefor some reason I thin that's an embellishment
12:00nDuffjcromartie: It's from a video of a presentation
12:00nDuffjcromartie: ...so not an intentional post-processing as much as a camera-in-a-dark-room effect.
12:00jcromartieno
12:00jcromartie"@Pat Sadly it's post-recording FX."
12:00jcromartie:)
12:00nDuffHuh.
12:01rplevyclgv: I've been wondering if repl-y plans to clean up its act. All I ever see are spews of terminal escape codes
12:01rplevybut it's fine
12:01borkduderplevy what version of lein2/reply are you using (just wondering)
12:02rplevyborkdude: let me check...
12:02rplevypreview 7
12:03clgvrplevy: yeah thats pretty annoying. I use Pos1 or End often...
12:04borkduderplevy maybe you should file it as a bug on github
12:05rplevygood idea, I will make it a point to do that. I just assumed it was known.
12:16clgvI hope repl-y improves vastly until lein2 goes stable...
12:16S11001001nDuff: the lines in the screenshots are perfectly straight
12:17clgvI guess there is no rlwrap-fallback built-in anymore?
12:17S11001001implying the camera was very, very far away
12:18nDuffS11001001: Conferences tend to have good video recording setups in terms of ideal positioning..
12:18S11001001not that perfect
12:20S11001001the CCD pixels would have to perfectly line up with those displaying the different color of the statusbar
12:22technomancyclgv: you can trampoline to running clojure.main/main with rlwrap
12:22technomancyclgv: 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:23clgvtechnomancy: fuctional keys seem not to work, e.g. Pos1, End
12:23rplevyI just opened an issue on repl-y for the escape code noise in emacs shell buffer
12:23technomancythe only problems I've heard are from having .inputrc interfere and not honoring TERM=dumb
12:23technomancyrplevy: that's the TERM=dumb issue, I think it's fixed if you run from master
12:24technomancyI don't know of a good solution around .inputrc other than just deleting it unfortunately
12:24clgvoh ok. so it might improve next preview/stable of leiningen?
12:24rplevyok great, repl-y master or lein master?
12:24technomancyclgv: if it's TERM=dumb, yes. I don't know about the inputrc issues or end key.
12:25technomancyrplevy: lein master. if you have a checkout try removing .lein-classpath just to be sure
12:25rplevygreat, thanks
12:25technomancybut honestly there's not much point to running it in an emacs buffer unless nrepl.el isn't working for you
12:25clgvrplevy: your name is too similar to "repl-y". I always read you like this ;)
12:27rplevyclgv: haha
12:29rplevyclgv: 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:29rplevy.
12:31clgvwrite a customizable + extendable swing repl ;)
12:32rplevyI 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:33trptcolinclgv: we just found out about the home/end thing - see https://github.com/jline/jline2/issues/54
12:33rplevyrepl-y is a lot nicer than the lein 1.x repl
12:34technomancyas the author of 1.x repl, I feel qualified to assert that it sucks
12:34trptcolinon ubuntu, anyway, it seems there's something outside of any INPUTRC that sets up keybindings in bash/zsh
12:37trptcolin… which we don't [yet?] have access to in jline
12:38technomancyyou 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:39otfromright. I'm off to the Clojure dojo. Catch you all tomorrow.
12:39technomancytrptcolin: ^
12:39trptcolinin beta10. i don't have any commits on top of beta10 yet
12:39technomancyok, cool
12:40trptcolinthis home/end thing is jline, but [at least so far] appears to be fixable via adding bindings to ~/.inputrc
12:40clgvtechnomancy: remaining question: when will preview8 be released?
12:40technomancytrptcolin: is there a wiki page or something that covers inputrc?
12:40hyPiRionclgv: When it's done, I suspect.
12:40technomancyI seem to see a fair number of questions about it
12:40trptcolinthat's a good idea
12:40technomancyclgv: by the end of the week
12:41clgvtechnomancy: oh that's sooner than I expected for "when it's done" ;)
12:43trptcolinclgv: 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:44technomancyif anyone has other considerations for things to go into preview8, please speak up
12:46clgvtrptcolin: no it did not. I directly uncommented those two lines in /etc/inputrc
12:48clgvtrptcolin: oh right. it *has* to be in the local .inputrc -- there it works!
12:50cemericktechnomancy: this is happening today?
12:50cemerickpreview8, I mean?
12:50technomancycemerick: possibly. at least before the weekend.
12:51cemerickOK. Hopefully I can get a beta9 of nREPL out tomorrowish
12:51cemerickThough maybe that's cutting it too close.
12:51technomancywhat kind of changes does it have?
12:51technomancyin terms of potential for instability
12:52cemerickNo changes, just additions; though I should probably read the changelog before guaranteeing that.
12:52cemericktechnomancy: nevermind, just run with what's been in there.
12:53technomancyoh yeah?
12:53eggsbyM-. in nrepl is magic
12:53eggsbynrepl.el *
12:53cemerickYeah. beta9 will happen this week, and then I can get to grinding down all the rough edges for a final release.
12:54cemerickBut whatever goes out should percolate in master for at least a little while before being flung at innocents.
12:54technomancyheh; sure.
12:54technomancyleiningen actually doesn't even pull in nrepl directly, just via reply
13:07spurrowhi... 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:08spurrowis it just multi methods?
13:08ivanvariable-arity functions
13:08ivaner, maybe multiple arity
13:09ivaner, pattern matching?
13:09spurrowso i might do something like: fib(0) = 1; fib(1) = 1; fib(n) = fib(n-1) + fib(n-2);
13:09spurrow(not clojure, sorry!)
13:10ivanlooks like pattern matching
13:10ivanhttps://github.com/clojure/core.match/
13:10technomancyyeah, that's pattern matching
13:10technomancyyou could sorta do it with multimethods, but they're lower-level
13:11spurrowoh great, core.match is exactly what i'm looking for
13:12S11001001compiling code that uses core.match brings some of the scalac experience to clojure.core/load :)
13:12spurrowS11001001: what do you mean by that?
13:12spurrowis scala famed for its pattern matching?
13:12S11001001scalac is famed for taking ages to compile things
13:12spurrowlol
13:14dnolenS11001001: heh, you must have lots of crazy patterns. haven't put much thought yet on possible optimizations ...
13:15dnolenspurrow: it's an idea that popular outside of mainstream languages - you should read up on pattern matching, CLOS generic methods, predicate dispatch
13:16S11001001dnolen: 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:18dnolenS11001001: i don't see any relevant to core.match there.
13:18dnolens/any/anything
13:18S11001001fnmatch is a thin wrapper for match
13:20dnolenS11001001: 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:20S11001001I figured as much
13:25spurrowin clj files, why is code not nested within (ns) ?
13:29nbeloglazovspurrow: I think it's like syntactic sugar: to avoid indent before each top level command like defn or def.
13:30spurrowbummer...why negotiate with terrorists?
13:34dnolenS11001001: 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:40l1xo hai!
13:40l1xi am trying to get java.jmx working with my project but no luck yet
13:40uvtchi, l1x.
13:40l1xi am following this doc
13:41l1xhttps://github.com/clojure/java.jmx/
13:42S11001001dnolen: yes
13:42l1xhttps://github.com/l1x/cljmx/blob/master/src/cljmx/core.clj#L10
13:42l1xthis errors out that \* is not supported
13:43l1xhttps://gist.github.com/3361874
13:43l1xif somebody have a minute for a clojure noob, i would appreciate
13:43dnolenS11001001: how long does it take for you? and how are you compiling? interactively or at the command line w/ lein?
13:45S11001001alternately with C-c C-l and C-c C-k depending on mood
13:45uvtcl1x: if that thing on line 10 is a string, you need to put double-quotes around it "\"*:*\""
13:46uvtcs/is/is supposed to be/
13:46l1xthx i try that
13:49l1xuvtc: actually (jmx/mbean-names "*:*") works
13:49l1xnow i need to find a way to print out what it returns
13:51uvtcl1x: maybe `(doseq [i (jmx/mbean-names "*:*")] (println i))`?
13:52treehugl1x: that line 10 looks like it was copied out of the clojure doc string which would have required the quotes
13:52l1xyou are awesome dude!
13:52l1xthx!
13:52uvtcl1x: sure, y/w :)
13:59dnolenS11001001: so does it take 1s to compile? 10s? 1 minute?
14:02S11001001dnolen: 6s
14:04dnolenS11001001: slow enough to be annoying. I'll look into possible optimizations when I pick up core.match again.
14:04l1xtreehug: yep
14:04l1xtreehug: using "*:*" works
14:07S11001001not 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:20l1xhow can i iterate through a hashmap?
14:20l1x(doseq [[k v] (jmx/mbean-names "*:*")] (prn k v))
14:20l1xthis does not work :(
14:20l1xException in thread "main" java.lang.UnsupportedOperationException: nth not supported on this type: ObjectName
14:21hiredmanl1x: I don't thing mbeen-names returns a hashmap
14:22l1xsorry i meant hashset
14:22hiredmando you understand what a hashset is?
14:22hiredmanand do you understand what the [k v] destructuring in the doseq above is doing?
14:24l1xyep, my bad
14:27l1xhiredman: is there something like in ruby the puts variable.class which tells me what is what
14:29dnolencraziness, core.logic querying for Eclipse project from a Smalltalk SOUL dev
14:34`fogusI have no idea what that sentence means
14:35dnolen`fogus: http://soft.vub.ac.be/SOUL/
14:36dnolen`fogus: SOUL embeds Prolog into Smalltalk, they did some incredible pattern directed metaprogramming work w/ it.
14:36`fogusooooo! Now it's starting to make sense
14:36`fogus(for some value of sense)
14:36`fogusThis just gave me an idea for my EL talk
14:50nDuff...so, I'm looking at korma, and it's not clear to me what the expected workflow is for injecting runtime configuration values.
14:51achenghello. 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:52l1xif prn print this [:HeapMemoryUsage {:committed 85000192, :init 0, :max 129957888, :used 17351208}], how can i access the individual elements in the hash?
14:52nDuff...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:53dnolenibdknox: my last bit about SOUL might interest you as well ...
14:55haspakerWhy won't Clojure read numbers beginning with zero?
14:55hyPiRion,012
14:56clojurebot10
14:56hyPiRionoctal.
14:56Chouser1acheng: that's a great question
14:56haspakerAh
14:56Chouser1apparently it depends
14:56haspakerThanks
14:56uvtc,0000
14:56clojurebot0
14:56`fogus,08
14:56clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 08>
14:56`fogusThat's where octal gets ya!
14:57hyPiRionIt's kind of scary when you work with floats though.
14:57hyPiRion,065.4321
14:57clojurebot65.4321
14:58hyPiRion...well, in Java at least.
14:58@chouser,((fn [{a :a, b :b, :or {b (inc a)}}] [a b]) {:a 5})
14:58clojurebot[5 6]
14:59@chouser((fn [{a :a, :keys [b], :or {b (inc a)}}] [a b]) {:a 5})
14:59@chouser,((fn [{a :a, :keys [b], :or {b (inc a)}}] [a b]) {:a 5})
14:59clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
15:01achengchouser: i wonder why that would be the case when you use :keys
15:02achengchouser: 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:04clojurebot[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:04technomancynDuff: indeed; that's a major design flaw in korma
15:05@chouserhmph. cut off.
15:05@chouser,(prn (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))
15:05clojurebot[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:05clojurebot"[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@chouserheh
15:05achengchouser: running low on quarters?
15:06achengchouser: (didn't mean for that to sound snarky in any way)
15:06@chouserheh, I'm not sure what you mean
15:06@chouseranyway, 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@chouser,(take-nth 2 (destructure '[{a :a :keys [b] :or {b (inc a)}} {:a 5}]))
15:07clojurebot(map__29 map__29 b a)
15:07hyPiRionSeems like order is important here.
15:07@chouser,(take-nth 2 (destructure '[{a :a b :b :or {b (inc a)}} {:a 5}]))
15:07clojurebot(map__56 map__56 a b)
15:08@chouseryeah, so the "or" part is done at the moment the target (b in this case) is bound
15:08hyPiRion,((fn [{a :a, b :b :or {b 2, a (inc b)}}] [a b]) {})
15:08clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>
15:08hyPiRionBut when reversed, it's okay.
15:08hyPiRion,((fn [{b :b, a :a :or {b 2, a (inc b)}}] [a b]) {})
15:08clojurebot[3 2]
15:09@chouser,(take-nth 2 (destructure '[{:keys [a b c d e]} {}]))
15:09clojurebot(map__145 map__145 e d c ...)
15:09@chouser:keys are bound in reverse order (!)
15:10achengchouser: is that for a good reason?
15:10@chouserI doubt it was intentional
15:10hyPiRionI suspect it's conj on a list in action.
15:11achengchouser: 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@chouserseems 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:11achengyeah
15:12nbeloglazov&(doc destructure)
15:12lazybot⇒ "([bindings]); "
15:12achengthanks both! followup question: how does one become awesome?
15:12@chouserYou're already awesome, you just have to find people who agree.
15:13@chouserWait, scratch that. I don't think that's a good philosophy.
15:13trptcolinlol
15:13nbeloglazovI like it :)
15:13hiredmanchouser: too late
15:13hiredmanyou said it, someone slap it on a tshirt
15:13@chouseracheng: Commenting on Yegge posts makes one awesome.
15:14@chouserno, this is getting worse.
15:14hiredmanchouser: why don't you stick to "reading is good", seems pretty safe
15:14@chouser:-)
15:15hyPiRionWe can do it the Hickey way:
15:16hyPiRionAwesome - Causing awe or terror; inspiring wonder or excitement.
15:16mattmossFaster? Stronger? More functional?
15:16hyPiRion(Look it up in a dictionary)
15:17uvtchammock-driven awesomeness
15:17achenghe also said not everything is awesome. so there's a limited number of spots
15:18hiredmanhttps://www.youtube.com/watch?v=UPq1_9DsLKk
15:20@chouserhiredman: now that is awesome.
15:21hiredmanand it describes software developement pretty well
15:21mattmosshiredma: I actually had six billion dollar man in mind, but that works too.
15:22uvtcmattmoss: six *million?
15:22achenguvtc: inflation
15:24qmxcemerick: fwiw, bought your book :)
15:24pandeirocemerick: you mentioned an http lib to me last week, specializing in API routing, can you remind me what it's called please?
15:25cemerickpandeiro: bishop, perhaps? That's cmiles74's.
15:25cemerickqmx: Hey, thanks :-D
15:25cemerickI hope you like it.
15:26pandeirocemerick: i think that's it; cheers
15:26clojurebotcemerick: Yeah, MacKay's book is great too.
15:38georgekhi, 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:39emezeskegeorgek: http://stackoverflow.com/questions/1828641/how-to-parse-a-uri-like-this-in-java
15:39emezeskegeorgek: I don't think it's a bug in java.net.uri -- you just need to encode the special character
15:40georgekah cool, thanks emezeske
15:40hiredmangeorgek: http://www.ietf.org/rfc/rfc2396.txt says pipes are "unwise" in uris and must be escaped
15:40hiredmanoh, bleh, I guess stackoverflow works too
15:41hyPiRionUse "%7C" instead of "|".
15:41hiredmanuse a a urlencoder
15:42hiredmanI like how the rfc defines a character class called "unwise"
15:42hiredmanthose guys are a hoot and a half
15:43emezeskehiredman: Heh, stackoverflow was just the first hit on google :)
15:43hiredman!!!!
15:43hiredmannew loper-os.org post
15:44hiredmanfuh, not about lips though
15:44hiredmanlisp
15:47zerokarmalefthiredman: but still proclaiming himself a prophet, more or less?
15:48hiredmanzerokarmaleft: with an extensive self quotation
16:05TimMcWell, he's spot-on here.
16:12zeromodulusI 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:13zeromodulusthe code is there, under src/hello-world/core.clj
16:13georgekdoes 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:14georgekI mean as you can with lein2
16:17solussddoes assoc create a new record when used with records? I thought it returned a hash-map…. is that a recent change?
16:17zeromoduluswelp, I give up, I'll try again when things are more mature and documented. see ya.
16:17gfrederickssolussd: I believe it will only switch to a hash-map if you dissoc one of the declared keys
16:18solussdso under the hood it's newing up a new record
16:18gfrederickssolussd: and afaik it's been the same behavior since the beginning
16:18solussdcool
16:18cemerickI guess 4 minutes is the half-life of a question on irc. Verified experientially. :-P
16:19S11001001solussd: try dissocing a vital key
16:20solussdyup, that turns it into a hash-map
16:20solussdcool, that's exactly how I expect/want it to work
16:21S11001001oh gfredericks said that already
16:21S11001001gfredericks: indeed it's always been like this
16:27djanatynquick question. I have a list of cities, and a function that takes two cities and finds the distance between them.
16:27djanatynhow I can I find the totaly distance in an idiomatic way?
16:27gfredericksbetween all pairs?
16:28S11001001shortest route that visits all cities :)
16:28gfredericks:P
16:28@ChouserHeh, I was about to suggest that.
16:28djanatynWell, no, not yet. I just want to find out the length of a route given a list of cities
16:29djanatynthat's next!
16:29gfredericksdjanatyn: partition 2
16:29S11001001gfredericks: needs less skipping
16:29TimMcdjanatyn: Is this a closed loop?
16:29aperiodicpartition 2 1
16:29S11001001,(doc partition-by)
16:29metelluswhy not reduce?
16:29clojurebot"([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@Chouserand reduce
16:29gfredericks(apply + (for [[a b] (partition 2 1 cities)] (distance a b)))
16:29metelluswait, I know why not.
16:29S11001001gfredericks: ah, there it is
16:29gfredericksman that was like 8 people answering at once
16:29djanatynmmm. I wanted to use reduce but my function wasn't set up in a way that would work.
16:30@Chouserdjanatyn: it's good for your function to just take two cities. And wanting reduce was also right
16:30gfredericks(->> 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:31djanatynI knew to find the sum of the cities I could just #(reduce + %)
16:31djanatynerrm, the sum of the distances. I bet there's even a sum function already implemented in contrib or something too
16:31TimMcI believe (apply + ...) is better since it allows + to decide on a computation order.
16:31achengzeromodulus: you're gone but i wonder if you have the - vs _ issue.
16:32@ChouserTimMc: 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:33gfrederickswhen I run a ring/jetty server, what would cause it to return a gzip'd response?
16:33TimMcreduce makes me feel like more of a badass, but apply seems more correct.
16:34gfredericksdoes the response have to be above some threshold size?
16:34dnolen@Chouser: I've always suspected that something like reducers was the reason.
16:35gfredericksbut reduce has order as part of its API
16:35@Chouserdnolen: 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:35gfredericksso it couldn't really do anything else without breaking backwards compat
16:35dnolenChouser: which wouldn't compose right?
16:35@Chousergfredericks: good point, where + could know that order doesn't matter and use reducers.
16:37@Chouserhm, 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:37gfrederickswell that's prior to adding
16:38hiredmanChouser: I don't recall seeing rich recommend reduce in general and for + in particular
16:38hiredmanI seem to recall apply + being faster
16:38gfredericksso assymptotically it can still be more efficient but for something fast like + probably not
16:38@Chouserwhile 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:39hiredman,(time (reduce + (range 1e4)))
16:39clojurebot"Elapsed time: 1.349744 msecs"
16:39clojurebot49995000
16:39hiredman,(time (apply + (range 1e4)))
16:39clojurebot"Elapsed time: 5.568422 msecs"
16:39clojurebot49995000
16:39hiredmanhuh
16:39hiredman~clojurebot
16:39clojurebotclojurebot is a multimap
16:39hiredman~benchmarking
16:39clojurebotCool story bro.
16:39Bronsai remembered apply + being faster too
16:39hiredman~clojurebot
16:39clojurebotclojurebot is amazing
16:39hiredmanclojurebot: no you are not
16:39clojurebotExcuse me?
16:40Bronsa*remember
16:40@Chouserhiredman: you're going to make me grep the IRC logs, huh?
16:41metellus,(time (reduce + (range 1e4)))
16:41clojurebot"Elapsed time: 154.705691 msecs"
16:41clojurebot49995000
16:41metellusthere's more than just apply vs. reduce going on here
16:42hiredmanChouser: I think I found it
16:42hiredmanb
16:43@Chouserhttp://clojure-log.n01se.net/date/2009-01-12.html#13:48
16:43hiredmanapply lets the function choose how to handle var args, reduce (with the protocol stuff) lets the collection drive how reduction is done
16:45hyPiRionOh, the old common lisp loop.
16:46TimMcFunction vs. collection: FIGHT!
16:46TimMcWhat we need here is a protocol.
16:48gfredericksamalloy: ping
17:06djanatynwow, I didn't know there was a clojure meetup group in pittsburgh :O
17:07TimMcIs it active?
17:07djanatynYes, they're having a meetup on September 11th. I plan on attending.
17:07djanatynThe only other usergroup I've been to was the ruby usergroup, and to be honest, I'm not really into Ruby.
17:09haspakerIs there an equivalent of "reduce" that returns all values instead of just the very last one?
17:10brehautreductions
17:10brehaut,(reductions conj [] [1 2 3])
17:10clojurebot([] [1] [1 2] [1 2 3])
17:10haspakerBrilliant
17:12leandrohow do i get the current function's name?
17:13nDuffleandro: The current function often won't _have_ a name at all. What's the context?
17:13leandrolog, i'd line to log this information.
17:13leandroline=like
17:14nDuff*nod*; ahh.
17:14nDuffThe normal JVM-centric methods work, though they're pretty slow.
17:14nDuffIIRC, log4j has that support built in
17:14nDuffso there's something you can use in your format strings which will indicate where your code is
17:15nDuffhaving it be user-configured that way is probably best -- that way they can choose whether to eat the performance penalty
17:15leandroit helped soo much. ty.
17:17leandronDuff: i'll continue to use a hardcoded string. =)
17:40solussdwhy does this fail? &(let [b 5] (for [item '[b]] (eval item)))
17:40solussd,(let [b 5] (for [item '[b]] (eval item)))
17:40clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
17:40solussdwell, it fails with a b doesn't exist in my repl
17:40solussdif I (def b 5), it works
17:41emezeskesolussd: Why do you have the quote on '[b] ?
17:41dnolensolussd: eval doesn't work with locals.
17:41solussdemezeske: bc I want the name of the symbol in the body of the for
17:41solussddnolen: thanks
17:41bosieis there a documentation that is better than the official one?
17:42acagle_ /flush
17:42solussddnolen: is there a way to get the local value?
17:42dnolenbosie: Clojure official docs are nice IMO - but there are some truly excellent books now as well if you're just starting.
17:42dnolensolussd: not w/ eval.
17:43bosiednolen: just starting. java/ruby background
17:43solussdclojuredocs.org is nice, sometimes.
17:43dnolenbosie: O'Reilly Clojure Programming is pretty darn good
17:43bosiednolen: i find them undigestable, like examples would be helpful ;)
17:43bosiesolussd: nice
17:44bosiednolen: bought it
17:44Raynes$examples eval
17:44lazybotYou must pass a name like clojure.core/foo or, as two arguments, clojure.core foo.
17:44dnolenbosie: covers language, idioms & tooling. clojuredocs.org is nice for examples. accessible from lein2 repl as well.
17:44Raynes$examples clojure.core/eval
17:44lazybothttps://www.refheap.com/paste/4400
17:44RaynesThese are extracted from clojuredocs.
17:44bosiehow would i go about figuring out what line 1 does: http://biomunky.wordpress.com/2010/03/17/clojure-read-a-file/
17:44RaynesWell you could ask here like you just did.
17:44Raynes:p
17:45bosieRaynes: hah, sure but i couldn't figure out from the docs how to read it
17:45RaynesLine one of the first example?
17:45bosieRaynes: yes
17:45RaynesThe namespace stuff is particular hard to understand.
17:45bosieRaynes: the whole '[] business
17:45RaynesThe docs for them are designed to be thorough and not necessarily easy.
17:46RaynesIn 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:47bosiethe equivalent of import clojure.java.io.reader
17:47bosiei take it?
17:47solussddnolen, I can accomplish what I want with macrolet!!!! :D
17:47dnolenbosie: 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:47dnolensolussd: nice
17:47RaynesWell, no, because you just said has no meaning in Clojure.
17:47Raynes:p
17:47bosieRaynes: sure
17:47solussdi've wanted an excuse to use it.
17:48bosieRaynes: so what is '[] ?
17:48bosiea function in itself?
17:48dnolenbosie: so yes, that dynamically loads the file according. '[...] will contain the usual syntax for importing.
17:48RaynesIt's a quoted vector.
17:48bosiehm
17:49RaynesIt 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:49bosieoh
17:50bosiehm
17:50bosieso in what "state" is [] in?
17:50nDuff"state"?
17:50clojurebotmutable state is bad
17:50dnolenbosie: it's just a piece of data.
17:51bosienDuff: in the sense that it kindad is a vector but apparently not evaluated, so it just gets 'held' somehow without being executed?
17:51bosielike a lazy sequence?
17:51dnolen,(let [a b] [[a b] '[a b]])
17:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>
17:51metellus,(let [a 1, b 2] [[a b] '[a b]])
17:51clojurebot[[1 2] [a b]]
17:51dnolenoops, thx metellus
17:52dnolenbosie: ^
17:52Raynesbosie: It isn't anything spectacular. It just isn't evaluated.
17:52bosiek
17:52Raynesbosie: In Clojure, things are read and then they are evaluated. A quote prevents that evaluation part of things.
17:52bosieRaynes: so its simply held as a string until needed?
17:53nDuffbosie: The vector is evaluated as a vector.
17:53nDuffbosie: ...the symbols within it aren't resolved.
17:53nDuffbosie: ...but there's no kind of lazy / just-in-time behavior involved.
17:53bosiek
17:53RaynesFWIW, Clojure behavior is often a lot more simpler than you think.
17:54bosieRaynes: so it isn't like haskell? ;)
17:54RaynesHaskell is super easy.
17:54Raynes:D
17:54bosieRaynes: i didn't find it easy at all :(
17:54bosiemakes me wonder if i am not cut out for FP
17:54nDuffbosie: ...you just get clojure.lang.Symbol objects rather than, well, whatever foo or bar would point to if they were defined.
17:54Raynesbosie: I was kidding.
17:54RaynesHaskell can be overwhelming sometimes.
17:55RaynesThings 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:56bosieRaynes: k
17:56bosieRaynes: i honestly hope so ;)
17:57metellus,(let [a 1] [(class a) (class 'a)])
17:57clojurebot[java.lang.Long clojure.lang.Symbol]
17:57haspakerIs there a function that returns the first item of a lazy sequence that satisfy a certain condition?
17:58joegallo(first (filter ... ...))
17:58haspakerOf course
17:58haspakerFeel a bit stupid now :>
17:59Rayneshaspaker: 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:59joegallosometimes (some .......) is the right thing, though, too. But the semantics are different.
18:00haspakerYeah
18:00joegallo(first (filter x y)) returns the first value from y for which x returns truthy
18:00joegallo(some x y) returns the first truthy return value of x, which *always* tricks me.
18:00haspakerI mostly felt stupid because I have used (first (filter …)) on other occasions but did not realize I could do it here as well
18:01joegallono worries. we shall strike this conversation from the chat logs, it'll be like it never happened.
18:01joegallo;)
18:01haspakerBrilliant :P
18:03dnolenbosie: lots of new stuff to learn. fortunately people here are nice and helpful :)
18:03bosiednolen: yup that seems
18:03bosiednolen: to be the case. seems to be the case in quite a few FP languages ;)
18:06bosiethanks Raynes / dnolen
18:11eggsbywhy can't you use == on keywords?
18:11eggsby,(== :foo :foo)
18:12clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>
18:12hiredman,(doc ==)
18:12clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums all have the equivalent value (type-independent), otherwise false"
18:12hiredman== is for numbers only
18:12eggsbyah, and =
18:12eggsbyI see
18:13eggsbythanks hiredman
18:15joegallo,(doc identical?)
18:15clojurebot"([x y]); Tests if 2 arguments are the same object"
18:15joegallo(== :foo :foo)
18:15joegallo,(== :foo :foo)
18:15clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>
18:15joegallo,(identical? :foo :foo)
18:15clojurebottrue
18:15eggsbyhm
18:15joegallophew, just checkin'
18:15nkozathere is a more succint way to do this, without using update-in?: (update-in {:a 1} [:a] #(inc %))
18:16eggsbynkoza: the #(%) is unnecessary
18:16eggsby,(update-in {:a 1} :a inc)
18:16clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Keyword>
18:16eggsbyoops
18:16eggsby,(update-in {:a 1} [:a] inc)
18:16clojurebot{:a 2}
18:16nkozausing update-in is the common idiom to update a key in a map?
18:17hyPiRion,(merge-with + {:a 1} {:a 1})
18:17clojurebot{:a 2}
18:17nDuffnkoza: Very.
18:17nkoza(without nested maps)
18:17metellus,(assoc {:a 1} :a 2)
18:17clojurebot{:a 2}
18:17nkozaI thought update-in was only for nested maps
18:17eggsbynkoza: it works with nested maps, you just define your 'path' to the data
18:17eggsby,(update-in {:a {:b 1} [:a :b] inc)
18:17clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
18:17eggsbyoops
18:17eggsby:3
18:17eggsbyyou get the idea
18:17amalloynkoza: yes, use update-in whether you have nested maps or not
18:17nkozaok, thanks
18:18ToxicFrogamalloy: why is it preferred to use update-in for non-nested maps rather than assoc?
18:18amalloy(assoc x :birthday (inc (get x :birthday))) ;; so gross
18:18metellusI was about to ask the same thing when I realized that eggsby wanted to modify the existing value
18:19amalloy(update-in x [:birthday] inc) ;; so clear
18:19nkozaToxicFrog: 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:19ToxicFrognkoza: aah, ok
18:20amalloyand 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:20ToxicFrogYeah, I missed that bit
18:23hyPiRionHm, 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:23amalloyfor the same reason we have dissoc but not dissoc-in
18:23amalloyit's not entirely obvious what update does
18:24mabesI have a ns as a symbol, how can I resolve the ns so that I can then use ns-resolve with it?
18:24mabes,*ns*
18:24clojurebot#<Namespace sandbox>
18:24mabesI'd like to say something like:
18:24amalloy(update m [:x :y] inc) ;; what does this do, hyPiRion?
18:24mabes,(resolve 'sandbox)
18:24clojurebotnil
18:24hiredmanhttp://clojure.org/namespaces
18:25hyPiRionamalloy: I myself consider it the same as (update-in m [[:x :y]] inc)
18:26hyPiRionWhich is like ##(update-in {[:x :y] 1} [[:x :y]] inc)
18:26lazybot⇒ {[:x :y] 2}
18:26mabes,(find-ns 'sandbox)
18:26clojurebot#<Namespace sandbox>
18:26mabesthanks hiredman :)
18:26hyPiRionExactly the same relation assoc and assoc-in has.
18:26amalloyhyPiRion: not exactly the same
18:26amalloyassoc and dissoc can accept multiple keys
18:27hyPiRion,(assoc [0 0] [0 1] inc)
18:27clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
18:27amalloywhat 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:27hyPiRionOh, gotcha.
18:28amalloy&(assoc nil :a 1 :b 2)
18:28lazybot⇒ {:b 2, :a 1}
18:28amalloyanyway, that's unclear, which i think is why it doesn't exist
18:30hyPiRionso not immediately obvious what the function does.
18:33hyPiRionSo what's the reason for not accepting multiple key-vectors for assoc-in then?
18:39djanatynone 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:40djanatynI can't just (max (map #(:key %) list)) because then I lose the other values in the map
18:42amalloy&(doc max-key)
18:42lazybot⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
18:42djanatynthank you amalloy!
18:43djanatynman, clojure sure does have a lot of convenient functions
18:45madsydjanatyn: Yeah. Discovering all of them can be a chore :)
18:45madsyEven clojure.core has tons
18:45cpineraHi 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:45hyPiRionWhat's the best way of finding these nuggets? Just dive into the source code?
18:46aperiodichttp://clojure.org/cheatsheet
18:47madsycpinera: There should be a project.clj setting for excluding jars. Check the example files on the Leiningen github page
18:48cpineramadsy: I'm using :uberjar-exclusions [#"clojure-1.3.0.jar"] but the jar is still being included...
18:48technomancycpinera: what version of leiningen?
18:48cpineratechnomancy: I was on version 2 preview 7 and then I upgraded to the latest in the trunk
18:49madsycpinera: Hm, not sure then. Maybe ask on #leiningen ?
18:49cpineramadsy: You are correct. Thanks!
18:49technomancycpinera: is it a fork of clojure with a separate group-id?
18:49hyPiRionaperiodic: That doesn't cover much.
18:50technomancyhyPiRion: you pretty much have to hang out on IRC =)
18:50aperiodichyPiRion: what else are you looking for? i've found it to be pretty comprehensive
18:50technomancythere's no substitute
18:50hyPiRionFor example, you'll never find ##(unchecked-byte 255) there.
18:50lazybot⇒ -1
18:50cpineratechnomancy: not as far as I can see. I got it directly from https://github.com/technomancy/leiningen, branch: master
18:50technomancycpinera: i mean in your project
18:50technomancycpinera: does `lein deps :tree` list two versions of clojure?
18:51cpineratechnomancy: ah yes, you are correct. I'm doing Android development, and I'm using [android/clojure "1.4.0"] as a dependency
18:51technomancycpinera: ok, in that case you have to use :exclusions
18:52hyPiRionBut okay, I'll just hang in here to find those diamonds.
18:52cpineratechnomancy: Understood. How would it look like? e.g. [clj-time "0.4.3" :exclusions [org.clojure]] ?
18:53technomancycpinera: 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:53amalloyhyPiRion: 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:53lazybot⇒ "([]); 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:54hyPiRionamalloy: That's a pessimistic look on it :(
18:54cpineratechnomancy: Perfect! Thank you very much indeed, I really appreciate your help.
18:54technomancyno problem
18:54amalloyonly if you feel pessimistic about it
18:55amalloyi 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:55lazybot⇒ "([coll]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields ()"
19:01djanatyn>_<
19:01djanatynthis is so much harder than it should be
19:02djanatynso, I have a list of maps. the maps are in the format of {:distance foo :route bar}
19:02djanatynI'm trying to find the map in that list that is the biggest. so I need to use 'max-key and apply.
19:03hyPiRionIs the biggest by distance or route, or both?
19:03djanatynso, the function I'm using for max-key to compare is #(:distance %).
19:03gfredericks:distance works too
19:04hyPiRion#(:distance %) is not a nice key to compare with.
19:04hyPiRionor nevermind.
19:04djanatynoh. okay, distance works
19:05djanatynbut 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:05amalloy(apply max-key :distance ...)
19:05amalloydjanatyn: you seem to just be wrapping everything in lambdas just in case :P
19:06kennethhey, is there an option to `lein uberjar` to specify which filename to create the uberjar at
19:06djanatynbut I thought that function would apply
19:06djanatyn...
19:06djanatynoh
19:06djanatyn*headdesk*
19:06djanatynI *do* want to pass :distance to max-key :)
19:06djanatynthank you.
19:06gfredericks~headdesk
19:06clojurebotExcuse me?
19:07gfredericksclojurebot: headdesk is botsmack
19:07clojurebotc'est bon!
19:07metellus~headdesk
19:07clojurebotheaddesk is botsmack
19:07gfredericks~headdesk
19:07metellus~botsmack
19:07clojurebotheaddesk is botsmack
19:07clojurebotOwww!
19:07gfredericks~headdesk
19:07clojurebotheaddesk is botsmack
19:07gfredericks~headdesk
19:07clojurebotheaddesk is botsmack
19:07gfrederickswhat happened to inference?
19:07hyPiRion~botsnack
19:07clojurebotThanks, but I prefer chocolate
19:07metellus~chocolate
19:07clojurebotCool story bro.
19:07amalloygfredericks: it's working, you just got unlucky
19:08gfredericksamalloy: getting unlucky 4 times in a row is inconceivable
19:08gfredericksI have inconceived of it
19:08djanatyn...woooooooo
19:08djanatynokay
19:08amalloy~headdesk
19:08clojurebotclojurebot evades successfully!
19:09djanatynafter 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:09djanatynin clojure!
19:10gfredericksdjanatyn: so what're you going to sell?
19:11djanatynuhh
19:11djanatynclojure consulting?
19:22djanatynI have a feeling (->) and (->>) are really important and useful functions
19:24emezeskedjanatyn: s/functions/macros :)
19:24gfredericksthey're just sugar
19:24gfredericksimportant and useful for readability perhaps
19:26l1xhey guys noob question, how can i create a hash in clojure?
19:27TimMcl1x: Are you talking about cryptographic primitives or associative data structures?
19:27l1xsecond
19:28TimMcl1x: http://clojure.org/data_structures#Data%20Structures-Maps%20%28IPersistentMap%29
19:28l1xthis returns a hash (jmx/mbean "java.lang:type=Memory") i would like to store it and refernce the nested part
19:29TimMcOh, a Java bean? You may want to `bean` on it.
19:32l1xin ruby i would reference it the following way parent[:nested_hash] (where parent ={:hash =>value , :nested_hash => {:super_deep_key => value}}
19:32l1xi would like to do something similar
19:34emezeske,(get-in {:a {:b 42}} [:a :b])
19:34clojurebot42
19:35l1xemezeske: thx
19:35emezeskel1x: You can of course just do it the long way too: &&(:b (:a {:a {:b 42}}))
19:35emezeskeerr
19:35emezeske,(:b (:a {:a {:b 42}}))
19:35clojurebot42
19:36l1xk
19:36l1xthx
19:40jlewishi
19:41zer(let [m (transient {})]
19:41zer(dotimes [n 12]
19:41zer(assoc! m (keyword (str n)) n))
19:41zer(persistent! m))
19:41jlewiscan you determine whether a PersistentHashMap has an entry with a null key in it?
19:41zer(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))
19:42zer&(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))
19:42lazybot⇒ {:0 0, :1 1, :2 2, :3 3, :4 4, :5 5, :6 6, :7 7}
19:42emezeskejlewis: I think contains? does what you want maybe
19:42emezeske,(contains? {:a 1} :b)
19:42clojurebotfalse
19:42emezeske,(contains? {:a 1 :b nil} :b)
19:42clojurebottrue
19:43zer&(clojure-version)
19:43lazybot⇒ "1.4.0"
19:43zer,(clojure-version)
19:43clojurebot"1.4.0-master-SNAPSHOT"
19:43zer,(let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m))
19:43clojurebot{:0 0, :1 1, :2 2, :3 3, :4 4, ...}
19:44jlewisemezeske: i'm specifically asking about null *keys*, not null values
19:44zer,(clojure.pprint/pprint (let [m (transient {})] (dotimes [n 12] (assoc! m (keyword (str n)) n)) (persistent! m)))
19:44clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.pprint>
19:44amalloyzer: :((((((((((((((((((((( transients aren't mutable objects
19:44jlewisthe implementation has a special case for this - it has a boolean hasNull that it keeps around
19:44zerhm, this is how i treat them
19:44emezeskejlewis: Oh, I misread you
19:44jlewisi'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:45jlewispackage protected*
19:45amalloyzer: you are treating them wrong, then, which is why you don't get the behavior you want
19:45emezeskejlewis: (contains? {nil 42} nil) does not work for your purpose?
19:45zershould i work with the return value of assoc! instead?
19:45amalloyyes
19:45amalloythey're allowed to mutate, but not required to
19:46zerstill a bit confusing, that my hash-map gets filled with 8 values instead of 1
19:46zererr 12
19:46jlewisemezeske: that always returns false
19:46emezeske,(contains? {nil 42} nil)
19:46jlewis,(contains? {nil 1} nil)
19:46clojurebottrue
19:46clojurebottrue
19:46jlewiserr
19:46jlewiswtf
19:46amalloyzer: well, the first 8 times it decides to mutate, and the ninth time it decides to return a new object
19:46jlewis,(contains? {3 1} nil)
19:46clojurebotfalse
19:47jlewis?!?! i'm confused. i observed contrary behavior to this before
19:47zerah ok, ty
19:47zeri wonder why you would want to return a new object instead of mutating
19:47jlewisemezeske: thanks, my test was screwed up. :)
19:48zertreating transients as mutable would be quite handy
19:48amalloy&(class (transient {}))
19:48lazybot⇒ clojure.lang.PersistentArrayMap$TransientArrayMap
19:48emezeskejlewis: No prob :)
19:48amalloy&(class (transient {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20))
19:48lazybotjava.lang.RuntimeException: Unmatched delimiter: )
19:48amalloy&(class (transient {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}))
19:48lazybot⇒ clojure.lang.PersistentHashMap$TransientHashMap
19:49zeraah right
19:49amalloyzer: and no, treating them as mutable wouldn't be handy; you'd be back in the soup of mutable-state
19:50zerwell, i like it, when constructing things, just applying sequentiel mutations and not caring about the return value
19:50amalloyjust use ->
19:50georgekhi, 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:51amalloy&(-> (transient {}) (assoc! :x 1) (assoc! :y 2) persistent!)
19:51lazybot⇒ {:x 1, :y 2}
19:51zeryes, this is what i will do from now on ty again
19:52hiredmangeorgek: calling resolve incorrectly
19:54Gnosis-what's the equivalent of subvec for a seq?
19:55emezeskeGnosis-: I think I usually end up using take and drop for that
19:55Gnosis-hmm, okay
19:57georgekthanks hiredman
19:57Gnosis-also, it looks like BigInts don't support a lot of bit-* operations
20:00georgekI'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:00georgekin other words, so file B can then rely on it?
20:01georgekthis is the lib, https://github.com/ngrunwald/clj-rome/tree/master/src/clj_rome
20:01georgekI think the translate fn in fetcher.clj relies on register-converters in reader.clj
20:09Gnosis-how do I test if something is an array?
20:12georgekGnosis, do you mean this, http://stackoverflow.com/questions/9090396/testing-whether-an-object-is-a-java-primitive-array-in-clojure
20:12Gnosis-yeah
20:13Gnosis-also, why the hell are bytes signed in Java?
20:15Gnosis-georgek: the Class/forName thing worked for what I needed, thanks!
20:20zershame, i cant do
20:20zer(-> (transient {}) #(if pred (assoc! % :a 'a) %) persistent!)
20:20zeris there any way that does not use let for each conditional or an atom?
20:27gfredericks,(-> (transient {}) (#(if pred (assoc! % :a 'a) %)) persistent!)
20:27clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pred in this context, compiling:(NO_SOURCE_PATH:0)>
20:27gfredericks,(-> (transient {}) (#(if true (assoc! % :a 'a) %)) persistent!)
20:27clojurebot{:a a}
20:27gfrederickszer: you just gotta respect how -> works is all
20:28zersweet
20:40gfredericksso 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:41amalloygfredericks: do it yourself. but you need to use a namespaced tag; others are reserved for clojure.core
20:42gfrederickshow does this work with lein libraries? I put the file in /src?
20:42amalloyyeah
20:42amalloyat one of the classpath's roots
20:43gfrederickscoothx.
20:44gfredericksincidentally how does clojure or anything handle situations with identically named files all at the root of the classpath?
20:48pepijndevosyou probably get the one thats on the path first?
20:48gfredericksI guess there must be an API for getting multiple files with one name
20:49gfredericks"When Clojure starts, it searches for files named data_readers.clj at the root of the classpath."
20:50hiredmangfredericks: classloaders have a getResources method
20:51gfrederickshiredman: entiendo
20:51gfredericksalso the 1.4 changelog doesn't mention how you go about writing reader tags
20:51gfredericksdoes this preclude pr-str?
20:52hiredmanyou muck with print-method or whatever
20:52gfredericksah
21:36Scriptorovertone seems to crash whenever I try running it from the slime repl
21:36Scriptorotherwise works fine from the command-line
21:37casionScriptor: I've not been able to get overtone working with slime myself
21:40Scriptorcasion: does java crash every time you try (use 'overtone.live) ?
21:40casionScriptor: yep
21:40Scriptorhave you tried with the external server?
21:40casionthere was another mysterious freeze at times that I never could figure out
21:40casionno I havent, I gave up on it
21:41tetrad_HiroProtagonist: www.siliconmicrodisplay.com/st1080.html
21:41casionI use supercollider directly, so getting overtone working is not a high priority for me
21:52gfredericks(inc tagged-reader-literals)
21:52lazybot⇒ 1
22:06aniero(take 3 (repeatedly (constantly "heh")))
22:09xeqi,(repeate 3 "heh")
22:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: repeate in this context, compiling:(NO_SOURCE_PATH:0)>
22:09xeqi,(repeat 3 "heh")
22:09clojurebot("heh" "heh" "heh")
22:13aniero:)
22:15anierois it better to do (zipmap ks (repeatedly (constantly val))) or (zipmap ks (repeat (count ks) val)) ? style choice?
22:15casion,"hehhehheh"
22:15clojurebot"hehhehheh"
22:15casionyou guys should write more concise code ;)
22:17xeqi&(zipmap [:a :b :c] (repeat "heh"))
22:17lazybot⇒ {:c "heh", :b "heh", :a "heh"}
22:17anieroohh, length is optional in repeat, thanks!
23:03Gnosis-how do I get a helpful stacktrace at the REPL?
23:03Raynes(.printStackTrace *e)
23:06Gnosis-it looks like a big mishmash of .invoke(...) to me :(
23:16jlewiswhen is it possible that a PersistentHashMap would return an entry with key and value = null, and yet not have hasNull set?
23:16jlewisi'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:22muhoowell, 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:35lpvb /close
23:38amalloyjlewis: i don't know why you would ever find out that it has hasNull set
23:38anieroaha, (take-while identity ...) instead of (take-while (complement nil?) ...)
23:39jlewisamalloy: 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:40jlewisi don't assoc a null anywhere... i'm kind of at my wit's end :)
23:40amalloyand you're looking at its hasNull in a debugger then?
23:40jlewisyes
23:42amalloyi 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:43jlewisi was afraid someone would say that... i don't have anything near to a minimal test case
23:46jlewisamalloy: 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:46lynaghkmuhoo: we're doing a cljs iPhone app right now. Might be fun to compare notes sometime.
23:47amalloygosh. probably it has a bug, then
23:47jlewisthat is a serious bummer!
23:57muhoolynaghk: cool, yes it would