#clojure logs

2011-12-22

00:01hiredmanthe best answer to that is java is not c++
00:01accelso if an object has been GCed
00:02accelhow can it still manage runnign threads?
00:02hiredmanyou do have finalizers, which are called when objects are gc'ed, but you don't have control of when or where or on what thread, so the use of finalizers is generally frowned
00:02hiredmanaccel: how would it be managing them?
00:03accelperhaps I am wrong but it seems that to schedule a bunch of threads; you need to keep state around; and if that sate has been GC-ed, you can't manage those threaes anymore
00:04hiredmanyou should try implmenting the executor interface, it requires very little state, all of which can go away leaving the threads running fine
00:04hiredmanbut the running threads will all have a reference to at least the task queue of the executor
00:05hiredmanthreads are gc roots
00:05hiredmanhttp://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html
00:05accelso the scheduler won't be GCed as long as some thraed is running
00:05hiredmanhttp://www.yourkit.com/docs/75/help/performance_problems/memory_leaks/gc_roots.jsp
00:06accelgot it; thanks
00:06hiredmanaccel: that is not what I said
00:07hiredmanif the threads reference the queue, and the executor references the queue, there is no reference from the queue to the executor
00:07accelis it no implied by what you said?
00:29dnolenhmm is there a fn that returns both the filtered and the removed items of a predicate?
00:30Raynes(juxt filter remove)
00:35dnolenRaynes: yeah, that's was I was going to do, but wondering if I was missing something.
00:35Raynesdnolen: There used to be something in contrib, but that was back before birds could fly and fish could swim,
00:35alandipertgroup-by?
00:37jodaro&((juxt filter remove) even? [1 2 3 4 5])
00:37lazybot⇒ [(2 4) (1 3 5)]
00:37jodaronice
00:47amalloy~juxt
00:47clojurebotjuxt is a little hard to grok but it's the best thing ever
00:53Raynesamalloy: I'm surprised that it doesn't say something about being nuts.
00:58dnolenalandipert: group-by puts things into a map, which is not really what I want, I want to preserve the order some.
00:59amalloydnolen: it preserves as much order as (juxt filter remove) would
01:00amalloy&(let [{truthy true, falsey false} (group-by even? (range 20))] [truthy falsey])
01:00lazybot⇒ [[0 2 4 6 8 10 12 14 16 18] [1 3 5 7 9 11 13 15 17 19]]
01:00dnolenamalloy: I'm adding a bit of my own logic to preserve order.
01:02espringe (-> 25 #(+ % 1) int)
01:02espringejava.lang.ClassCastException (NO_SOURCE_FILE:19)
01:03espringeWhat's wrong with that?
01:03hiredman,(macroexpand '(-> 25 #(+ % 1) int))
01:03clojurebot(int (clojure.core/-> 25 (fn* [p1__27#] (+ p1__27# 1))))
01:03hiredman,(macroexpand '(clojure.core/-> 25 (fn* [p1__27#] (+ p1__27# 1))))
01:03clojurebot(fn* 25 [p1__27#] (+ p1__27# 1))
01:04espringeStill not quite seeing what's going on
01:05hiredman,(macroexpand '(-> 1 (2 3 4)))
01:05clojurebot(2 1 3 4)
01:05hiredman,(macroexpand '(-> 1 (fn [])))
01:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>
01:05hiredmanweird
01:05hiredman,(macroexpand '(-> 1 (fn* [])))
01:05clojurebot(fn* 1 [])
01:06RaynesIt is trying to insert 25 as the first element in the form that #() expands to. It isn't inserting it as the first argument to your function.
01:07espringeAh, I see. Thanks
01:07espringeIs there a quick fix for that? Or i have to give a name to my function?
01:08hiredmanwell, what is -> doing?
01:08espringeI want the result of that to be 26
01:09espringeIt should get 25, feed it into the function that increments it. Then make it an int
01:09hiredmanok, but what is -> doing "Ah, I see."
01:09espringeYeah, just for learning
01:09espringenothing practical
01:09hiredmansure, so what is -> doing?
01:09hiredmanyou said you saw, so what did you see?
01:09Raynes&(-> 3 (#(+ 3 %)))
01:09lazybot⇒ 6
01:10espringehiredman: I assume that #() is expanding into a list of some sort. And -> is throwing 25 into that list
01:10espringeIs that wrong?
01:10hiredman,(macroexpand '(-> 1 2))
01:10clojurebot(2 1)
01:10hiredman,(macroexpand '(-> 1 (2)))
01:10clojurebot(2 1)
01:10hiredmanespringe: sure, where in the list?
01:10espringeAt the end?
01:11espringe,(macroexpand '(-> 1 (2 3 4)))
01:11clojurebot(2 1 3 4)
01:11espringeapparently not
01:11Raynes&(doc ->)
01:11lazybot⇒ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
01:12espringeAhh! I see why it's doing what it's doing
01:12espringeSo I need something like -> except it inserts at the very end of the list -- instead of the 2nd element
01:12accelcan I read from an agent using @?
01:13hiredmanaccel: have you tried it?
01:13accelyeah
01:14acceland I get an error saying: "Nu such var: foo.bar/blah"
01:14hiredmandid it work?
01:14accelNo, it failed.
01:14espringe(->> 25 #(+ % 1) int)
01:14espringeSo shouldn't that work?
01:14hiredmanespringe: did you run macroexpand on it to see what it does?
01:14espringe,(macroexpand '(->> 1 (2 3 4 5)))
01:14clojurebot(2 3 4 5 1)
01:14hiredmanaccel: with an error unrelated to agents
01:15Raynesespringe: No. It inserts 25 as the last element of the form created by the #().
01:15hiredmanespringe: on your actual expression, feel free to use your own repl to play with it
01:16espringeThanks. I think I got it:
01:16espringe,(->> 25 (#(+ % 1)) int)
01:16clojurebot26
01:16espringeThanks for your help everyone
01:17Raynesespringe: If that is your actual code, you can actually just do ##(-> 25 (+ 1) inc)
01:17lazybot⇒ 27
01:17hiredman,(macroexpand '(-> 1 (2)))
01:17clojurebot(2 1)
01:17hiredman,(macroexpand '(->> 1 (2)))
01:17clojurebot(2 1)
01:19espringeRaynes: Now you've just confused me again :(. What's (+ 1) and why does it evaluate to 1
01:19espringeIsn't + a binary function?
01:20espringe((+ 1) 1) doesn't work either
01:20brehautespringe: its sum
01:20espringeSo it's not a partially applied function
01:20RaynesI'm not sure you understand what -> does at all.
01:20brehaut,(+)
01:20clojurebot0
01:20espringe,(+ 1)
01:20brehaut,(+ 1 2 3)
01:20clojurebot1
01:20clojurebot6
01:20espringeWhy does that give 1
01:20RaynesI'm trying to think of the best way to explain this.
01:20brehautespringe: what is the sum of the list containing the number 1 and nothing else?
01:20Raynes(-> 1 (+ 2) inc) = (inc (+ 1 2))
01:20espringeOh, never mind. I see.
01:21espringeIt works on any amount of arguments
01:21RaynesBut that still isn't what is happening in my example.
01:21brehautespringe: now to really bake your noodle ##(< 1 2 3)
01:21RaynesIt is working on two numbers.
01:21lazybot⇒ true
01:21espringeYeah, I know that
01:21espringeWhen i first read the code, I thought (+ 1) was going to be shorthand for #(+ 1 %) as I assumed + was a partially applied binary function
01:22espringebut i was just being dumb :D
01:22accelfoo/cat.clj requires foo/dog.clj; foo/dog.clj depends on foo.cat/some_agent ; how can I make this work w/o creating circular dependencies?
01:22RaynesEven if + didn't work at all on one argument, it still would work in my example. The arguments aren't evaluated until the form is complete. Thus is the wonder of macros.
01:23RaynesNot doing it is an excellent way.
01:23hiredmanthat is the definition of a circular dependency, don't do it
01:24acceli can't forward declare the var or something?
01:25hiredmanaccel: http://www.essortment.com/5-stages-grief-16816.html please skip to acceptance and structure your code in a way that doesn't require this
01:25RaynesHahaha
01:26RaynesThat was the greatest hiredmanism to date.
02:11accelhow can I run clojure/java in real time mode? I have a cursor that I want to blink 5 times a second; and looking at it visually; I can see the gc hiccups
03:29accelis there a way to define a multimethod as memoizable?
04:42acceldoes clojure have an idiomatic way of saying: write this acyclic list out to file?
04:53clgvaccel: you mean something like pr/prn?
04:53clgvthat writes the list to *out* which ist stdout by default: ##(prn (range 10))
04:53lazybot⇒ (0 1 2 3 4 5 6 7 8 9) nil
04:54clgvvia (binding [*out* (writer "myfile.data")] (prn mydata)) you can use that to write to a file
04:55accelclgv: Cool. What is the inverse of prn?
04:55clgvaccel: e.g. load-string if you already read that string
04:56clgvor load-file for a whole file. but then you only get the last value returned
04:57accelhmm, is there a way to do a read w/o eval?
04:57acceli guess I can attach an extra "quote" aroudn the prn
04:57clgvoh right load does eval, but read/read-string does not
04:58accelis there no read-file ?
04:58clgvthats 'read
04:58Chousukeread happens one form at a time
04:59accelone more dumb question; how do I go from a filename to a stream for reading?
05:00clgvaccel: use clojure.java.io/reader and put that into a LinePushBackReader
05:04accelclgv: got it; thanks for all your patience
05:04clgvnp
05:06kralnamaste
05:35Blktgood morning everyone
05:39tscheiblHachdj Dorsmno
05:40tscheibl... gesundheit
05:44G0SUBnamaste, kral
05:47voldemordorthe language is pleasure, but does any company actually develop any application with clojure?
05:47voldemordorsee i'd like to go to development, but dont want to deal with java...
05:47ejacksonvoldemordor: many, check out the clojure success stories on the home page.
05:47nachtalpvoldemordor: a couple of examples can be found here: http://dev.clojure.org/display/community/Clojure+Success+Stories
05:48voldemordorthx i will look into it
06:08erujolc#couchdb
06:12alekxhi! what's the recommended setup for a newbie? what's the best way to set repl?
06:16tsdhalekx: Probably, the easiest is installing Leiningen http://github.com/technomancy/leiningen, lein new first-steps && cd first-steps && lein repl
08:37ambrosebsis there a reason why the #myns.MyRecord{...} syntax only works for fully qualified classes? Just the implementation?
08:41pyrhi guys, when running a ring app in an existing servlet container
08:41pyr(say, jetty7)
08:41pyris there a standard way of telling the ring war servlet
08:41pyrto not care about the uri prefix
08:42pyri.e: if i handle routes such as /foo, /bar/:id and deploy the uberwar to /myapp, i get failures since i get hits to /myapp/foo
08:43pyri can't seem to find a reference for web.xml which is where this sort of config seems happen
08:59kreyHi there, I do not really understand https://github.com/clojure/tools.logging
09:00tsdhambrosebs: Just a blind guess, but maybe you need to `import' myns.MyRecord as if it was a Java class to refer to it without qualification...
09:01kreyWhere to call log-capture! ?
09:02ambrosebstsdh: the reason it doesn't work it the implementation. it uses (RT/classForName ...) which doesn't take into consideration the current scope
09:02ambrosebsI wasn't sure if this was a design choice
09:02ambrosebsi see no mention in the design docs
09:06tsdhHm, that's consistent with Class/forName, which also relies on qualified names.
09:12TimMcWhat's the syntax in question?
09:23broquaintI'm failing to understand the output (possibly because I'm failing at debugging too) of this test - https://gist.github.com/1510460
09:23broquaintMy confusion lies in why the second COND isn't [:a :b] [[:a :b]].
09:25broquaintThat relates to this 4clojure problem BTW - http://www.4clojure.com/problem/93
09:37samaaronbroquaint: it might help if you made your question more specific
09:37pandeirois there another way to get the path of a clj file besides *file*? in one of my noir handlers, *file* returns NO_SOURCE_PATH
09:39broquaintSure, samaaron, my expectation is that after recursing on the first nested structured [[[:a :b]]] the next condition that would be evaluated would be [[:a :b]] but the output indicates that it skips straight to [[:c :d]].
09:46broquaintI should really reduce that to a minimal test case and come back with something more coherent ;)
09:56kreyGetting Message: n.spy.memcached.MemcachedConnection - Could not redistribute to another node, retrying primary node for set-item-test. << why?
09:58Raynessamaaron: What are you getting me for Christmas?
09:58samaaronRaynes: you can have a cup stacking set and a Skrillex EP
09:58samaaronOh My Gosh!
09:58RaynesFantastic.
10:01samaarondo you want it gift wrapped?
10:01Raynessamaaron: I wouldn't take it any other way.
10:02samaaronhave you heard much Skrillex?
10:02RaynesCloser to none at all, ever.
10:02samaaronwhat kind of "youth of today" are you?
10:03RaynesThe bad kind.
10:03Raynessritchie: Ohai.
10:03samaaronsurely the bad kind listens to skrillex??
10:03lazybotsamaaron: What are you, crazy? Of course not!
10:03sritchiewhat up, good sir
10:04Raynessritchie: You can either send me a pull request or I can just give you write access to my lein-noir fork. The latter would probably be better if you have more work to do on your stuff, since you wont have to constantly bother with pull requests.
10:04RaynesYour choice.
10:04RaynesRed pill or blue pill.
10:05RaynesAlso, someone buy me the hat on this list: http://www.amazon.com/gp/registry/wishlist/ref=ya_52
10:05sritchieany decision in pill form is a decision I feel very comfortable making
10:06sritchieI'll take write access, but I'll work in a branch
10:06RaynesHeh. Why, so you don't make me angry for screwing up your own template?
10:06Raynes:P
10:06TimMcRaynes: The URL you have dialed is not available. Please hang up and try again.
10:06RaynesTimMc: I still haven't quite figured out Amazon wishlists.
10:07TimMcThat wasn't the public URL.
10:07RaynesTimMc: http://amzn.com/w/3AB1JVMTPUFSQ
10:07RaynesThat might be it.
10:08sritchieI might freak your watchers out with my character-by-character commits, each documented obsessively with tortured rationale
10:08RaynesI have watchers?
10:09RaynesYeah, didn't think so.
10:09sritchiein that case, let's tear it up
10:10sritchiethanks for the access, I'll move that stuff over now
10:11TimMcRaynes: Who is Connie?
10:11RaynesTimMc: Eh?
10:11TimMc"This list is for:" on the left.
10:11RaynesSays Anthony for me.
10:12TimMc"This list is for: Anthony"?
10:12RaynesConnie would be my mother, whose name was originally on this account. Hasn't been for at least a year or so. It still shows her name in the title for me, but nowhere else. I assume amazon doesn't understand name changes.
10:12TimMchaha
10:15pandeirowhy does *file* have NO_SOURCE_PATH in my noir module? anyone? how can i work around this?
10:19TimMcCup stacking!
10:19TimMcOh man, I remember that.
10:20cemericksamaaron: skrillex is what made me aware of cup stacking to begin with
10:20cemerickwhat an absurd corollation
10:20samaaronit's insane
10:21samaaronOH MY GOSH!
10:21samaaronwub wub wub wub
10:21cemerickhah
10:21Raynescemerick: Get out of my internets.
10:21samaaroni've been listening to skrillex quite a bit of late
10:21samaaronsome good sounds
10:22cemerickRaynes: Hey, I could be talking about nyan…things. Whatever that is.
10:22samaaronRaynes: what's your cup-stacking pb?
10:22RaynesFYI, I've got no idea what you're talking about.
10:22samaaronagain, what kind of "youth of today" are you??
10:22lazybotsamaaron: Uh, no. Why would you even ask?
10:22cemerickDon't google it.
10:22samaaronyou're not conforming to stereo-types
10:23cemericksamaaron: I lost a bit of my sanity when I discovered that such a thing existed. Give Raynes a chance to live a well-adjusted life.
10:23samaaronhahahaha
10:25TimMcOne of my cousins had a stacking mat and everything.
10:25cemerickgaaaah
10:25TimMcI was kind of horrified.
10:26samaaronI used to have a yo-yo as a kid
10:26samaaronalthough, I still have one now
10:26TimMcThat's perfectly respectable.
10:26cemerickI don't see how that's at all comparable.
10:27TimMcpandeiro: Cup-stacking is why you're getting NO_SOURCE_PATH, I am sure of it.
10:27cemerickTimMc: Thanks for making me blow juice out my nose.
10:28TimMcWelp, back to the bracket mines.
10:29RaynesMother of God, is this for real?
10:29cemerickHe googled it.
10:29TimMcahaha, he *warned* you about googling it
10:29samaaronhahaha
10:29samaaronOh My Gosh!
10:30samaaronhttp://www.youtube.com/watch?v=8pbFR3jXWi8
10:30TimMchttp://www.mspaintadventures.com/sweetbroandhellajeff/archive/001.jpg
10:31samaaronthen listen to: http://www.youtube.com/watch?v=WSeNSzJ2-Jw&amp;feature=related
10:31jodaroheh
10:31samaaronmake sure you make it through to 40s
10:32jodarostill watching the tp commercial
10:32jodaroabout pieces
10:34Raynessamaaron: Oh my Gosh.
10:34clojurebotCool story bro.
10:34samaaronhaha
10:34samaaronwub wub wub
10:34samaarondid you make it to 40s?
10:34RaynesYes.
10:34TimMcclever bot
10:35RaynesI see the correlation.
10:35RaynesI've never been that happy about anything in my life.
10:35samaaronwub wub
10:35cemerickRaynes: No one else has either, EVER.
10:35samaaron:-)
10:36samaaronEVARRRR
10:37Raynescemerick: I don't know. samaaron seemed pretty happy up there during his talk.
10:37RaynesMaybe not quite this happy.
10:37RaynesI don't know, I slept through most of it.
10:38cemerickOK, so samaaron and the cup-stacking-girl can be that happy. :-P
10:38samaaron:-)
10:38samaaronwub wub
10:38RaynesStaying awake was a bigger challenge than talking at the conj. Every time I dozed off I felt a little more guilty. People probably thought I wasn't interested in *anything*.
10:39samaaronRaynes: and you didn't even have any jet-lag to deal with
10:39RaynesYeah. Just late nights and my untrained body.
10:39Raynescemerick: I fell asleep for at least the last 5 minutes or so of your talk.
10:39RaynesI nearly fell out of my chair when the applause started.
10:40RaynesI was like "YAY!WHATHAPPENED!"
10:40samaaronOh My Gosh!
10:40samaaronwub wub wub
10:40cemerickI *knew* it. Damn you, Raynes, DAMN YOU.
10:41cemerick;-)
10:41Raynes:)
10:43TimMcwub
10:43TimMcI think that's actually the first time I've heard dubstep.
10:45gfredericksClojurescript is more sensitive about namespaces and files, isn't it? E.g., I couldn't write a macro that defs a function in two different namespaces?
10:45TimMcgfredericks: I think you could, as long as that namespace had beenr equired already.
10:46gfrederickswould I use the (ns) macro, or some set!s?
10:46TimMcWouldn't you just fully-qualify the names?
10:46gfredericksyou can def a fully-qualified name?
10:46TimMcHmm, maybe not...
10:47TimMcYou definitely can't do ns twice for the same namespace.
10:47TimMcGClosure will error on that to "teach you a lesson". No kidding.
10:47gfredericksthat's in its error message?
10:49TimMcNot exactly.
10:49samaaronTimMc: I've never seen Closure referenced as GClosure - I like that a lot
10:50TimMcgfredericks: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl.clj#L73
10:50pandeiroso, uh, why doesn't *file* return the relevant info for my noir handler again?
10:51gfredericksTimMc: hmph
10:51gfrederickswell I think I'll just be generating a separate cljs file then
10:51gfrederickspoor man's macro
11:02pandeiroTimMc: i saw that you were talking about clojure again so i thought i'd give it another shot... :-/
11:03TimMcYeah, sorry for the topic excursion.
11:04pandeirowhen you (:require) a certain module, does clojure not read that file and set the *file* var?
11:04TimMcI'm not familiar with the *file* var, or noir. :-(
11:04pandeiroi realize i am way out of my league here amongst people who live sleep eat breath language implementation for years... but can anyone help a noob?
11:05gfrederickspandeiro: does it have something to do with :require only doing anything the first time?
11:05samaaronOh nice, so now I've got two university talks lined up next year where I can inject Overtone and Clojure into everyone's minds
11:05samaaron*** YOU WILL LIKE OVERTONE & CLOJURE ***
11:05kreyWhat's overtone?
11:05pandeirogfredericks: i have no idea, i can't even find where :require is implemented in the clojure source, and probably wouldnt understand the code if i could
11:05ejacksonthat which is about to injected into your mind !
11:05gfredericksclojurebot: YOU |WILL| LIKE OVERTONE & CLOJURE
11:05clojurebotIk begrijp
11:06samaaronkrey: it's like cup-stacking and skrillex rolled into one package
11:06pandeiroi just figured it was probably a common use case, ie for writing a config file, i want to know where i am in absolute path terms
11:06gfrederickspandeiro: it results in a call to the clojure.core/require function I think
11:06ejacksonsamaaron: well, it's usually the case that a roll of cups has been stacked
11:06samaaronyeah, but with awesome wub wub as part of the process
11:07kreyI don't know cup-stacking and skillrex
11:07samaaronkrey: oh damn that's unfortunate
11:07cemerickpandeiro: Are you loading any code via a REPL?
11:07TimMckrey: Good, keep it that way.
11:07TimMcpandeiro: If you need to load a config file, use clojure.java.io/resource
11:07samaaronkrey: http://vimeo.com/22798433
11:08cemerickpandeiro: sorry, I misread your question
11:08TimMcpandeiro: I just tried using *file* in a minimal project and it didn't work.
11:09pandeirocemerick: actually i am trying to do up a quick and dirty noir + clutch thing, and i want to allow the user to set the couch instance, and write that to a file
11:10pandeiroinstead of hard-coding where that config file is, i wanted to be able to dynamically resolve the path from inside my couch-noir.db.init module, since init.clj and config.clj will live in the same subdir
11:10kreyHow to compare strings during tests with clojure?
11:10TimMcpandeiro: Yeah, definitely use io/resource or something -- it'll be on the classpath.
11:11krey (info (test/get-item "set-item-test")) => xyz
11:11pandeiroTimMc: yeah i was going straight to (java.io.File. "")
11:11TimMc&(= "hello" "hello")
11:11lazybot⇒ true
11:11pandeirobut that gives me the project's root dir
11:11krey(is (= (test/get-item "set-item-test") "xyz")) << actual: (not (= xyz "xyz"))
11:12TimMckrey: looks like a symbol, not a string
11:12TimMc&'[xyz "xyz"]
11:12lazybot⇒ [xyz "xyz"]
11:12kreyahh worked with str
11:14kreyAwwwww... replace method did not use escaping for the data structures :)
11:14kreyHow good tests are
11:15jsabeaudryIs it possible to return an http response that is too big to fit in memory with ring?
11:15kreyHow to encapsulate: (binding [*print-dup* true] (prn-str value))
11:15kreyNeed it multiple times,... seems to be not DRY
11:17nachtalpjsabeaudry: as a stream? https://github.com/mmcgrana/ring/blob/master/SPEC#L85
11:18nachtalpjsabeaudry: sorry, i meant https://github.com/mmcgrana/ring/blob/master/SPEC#L104
11:18pandeiroTimMc: clojure.java.io/resource doesn't seem to help... i guess i am stuck hard-coding the location if there is no way for a module to know what file it is in... damn
11:18jsabeaudrynachtalp: Yes precisely! Many thanks! :D
11:19kreyhttps://github.com/heroku/devcenter-memcache-java/blob/master/README.md << awww the warnings are even in the example with java
11:19krey"Could not redistribute to another node, retrying primary node for"
11:19kreyEverything works as excepted... Why a warning here?
11:20nachtalpjsabeaudry: sure :)
11:22Raynessamaaron: Teach me to play the Overtone.
11:22bweaverHello, I'm new to Clojure and want to parse an XML document, transform it, then print the new document out. I found xml/parse and zip/xml-zip, but I'm stuck on printing the modified document. There's an xml/emit method, but it's not documented. What's the best practice in this case?
11:22samaaronRaynes: do you have it installed yet?
11:22RaynesNo.
11:22samaaronok, that's your first task
11:23RaynesHeh
11:23samaaronhttps://github.com/overtone/overtone/wiki/Installing-overtone
11:23TimMcbweaver: Try emit, see what happens.
11:23Raynessamaaron: This cake stuff can go.
11:24RaynesIt's evil.
11:24samaaronRaynes: only when lein 2 is out :-)
11:24samaaroni still use cake happily
11:24Raynes$guards
11:24lazybotSEIZE HIM!
11:24bweaverTimMc: It seems to work, I'm just curious if there's something I should be using since it's not part of the documented API?
11:25TimMcbweaver: It's part of the API -- just not documented. :-(
11:25bweaverTimMc: Ah, good then. Thanks!
11:25TimMcHuh, I wonder if it prints the preamble.
11:25pandeirowow, so it is because I was referencing *file* inside a function... if I bind a var to it outside, then i get it... but it's just a path snippet that parallels the namespace, not an absolute path... what good is that?
11:26TimMcpandeiro: I don't think it's intended for use like that.
11:26TimMcIt's a compiler-level thing.
11:26Raynessamaaron: You've got music on my Clojure!
11:26samaaronyou made a noise?
11:26pandeiroTimMc: i guess clojure just doesn't have something like __FILE__ in PHP or (I think) ruby
11:27Raynessamaaron: No, maven hasn't finished downloading the internet yet.
11:27samaaronhahaha
11:27RaynesBut I'm going to make a noise. I'm going to make so much noise.
11:27samaaroni like to keep a cache of the internet to help with that situation
11:27TimMcpandeiro: Use the classpath to your advantage.
11:30Raynessamaaron: Overtone just crashed my JVM.
11:30samaaronare you using linux?
11:30pandeiroTimMc: please expound
11:30samaaronawk
11:30Raynessamaaron: OS X.
11:30RaynesI tried to start an internal server.
11:30Raynes"*** ERROR: open directory failed '/Users/anthony/Library/Application Support/SuperCollider/synthdefs'"
11:31RaynesI was under the impression that there weren't any external dependencies for that.
11:31cemerickpandeiro: so you're trying to load a file at "foo/bar/config.clj"?
11:31pandeirocemerick: yeah write to it
11:32Raynessamaaron: Looks like the actual problem was 'input and output sample rates do not match. 48000 != 44100'.
11:33RaynesI'm glad that it told me this though, because I would have otherwise assumed those numbers to be equal. They look so darn similar.
11:33cemerickpandeiro: Well, (spit "foo/bar/config.clj" content) will do that, but I suspect that's not what you're aiming for. maybe gist what you're working on so we can have some context.
11:34samaaronsorry, awk should have been afk
11:34samaaronbut i'm back now
11:34samaaronthe error you saw wasn't anythign major
11:34RaynesI'm good for some asynchronous conversation.
11:34samaaronand yep, it's the sample rate issue
11:35samaaronif you can figure out a way of usign AppleScript or some nonsense to automatically set the sample rate to 44100 then that would be awesome
11:35samaaronotherwise you need to head into "Audio MIDI Setup" and do it manually
11:35pandeirocemerick: sure, http://sprunge.us/PAXL
11:38TimMcpandeiro: Surely slurp is called for, not spit.
11:38TimMcWait, writing to it?
11:38cemerickpandeiro: I'm still not sure about the use case. You want the user to be able to set the database config once somewhere, and then reuse it everywhere else?
11:39pandeirocemerick: yeah and i figured why not do it right in the noir db module?
11:39pandeiroas opposed to a flat config file somewhere i would slurp, i load it as clojure
11:40pandeiroi am a total noob so tell me if that is a terrible idea
11:40pandeiroor impossible, as the case may be
11:40cemerickpandeiro: I've never used noir, so I can't say one way or the other if that's typical.
11:40Raynessamaaron: What is a sample rate?
11:40cemerickThe thing is, you're trying to generate a clojure source file at runtime, which would presumably be read the *next* time the app runs?
11:41pandeirobasically: user loads webapp, webapp checks db connection, if none exists reroutes to /setup/, and post to /setup/ tries to establish connection and write config file for future use (in case server is restarted)
11:41samaaronok, so you need to meet nyquist and chums
11:41pandeirodoes that make sense?
11:41TimMcRaynes: How many samples per second make up the digital capture of the analog signal.
11:41RaynesI'd google it, but if you say it I'll get to hear it in my head in your lovely accent.
11:41RaynesTimMc: Damn you.
11:41samaaronbasically, sound can be stored as reading the current voltage generated by a microphone
11:41cemerickpandeiro: OK, so this is being used as a one-time setup procedure?
11:41pandeirocemerick: yeah
11:41cemerickOK; you're doing it the hard way :-)
11:42samaaronthe thing is, you need to store that voltage in discrete parts
11:42pandeirocemerick: i should just put a flat config file somewhere in the project root or something?
11:42TimMcRaynes: http://www.mathworks.com/help/toolbox/daq/daqsample.gif
11:42samaaroneach of those parts is typically called a sample
11:42pandeiroi had just read this steve yegge blogpost about how lisp makes for great data storage format...
11:42clojurebothttp://www.assembla.com/wiki/show/clojure/Datatypes
11:42lazybotAssembla is deprecated. Use http://dev.clojure.org
11:42samaaronso the sample rate is the number of values of the microphone you store per second
11:42pandeirolol over my head apparently
11:42cemerickpandeiro: well, first, if you're just saving and loading data, just save and load data, don't mess around with namespaces.
11:42TimMcRaynes: I'm just jealous and vindictive because I didn't get to see his talk/
11:42cemerick,(pr-str {:some "data"})
11:42clojurebot"{:some \"data\"}"
11:43cemerick,(read-string "{:some \"data\"}")
11:43clojurebot{:some "data"}
11:43Raynessamaaron: I made sound!
11:43samaaronRaynes: yey!
11:43pandeirogotcha
11:43pandeiroreally no plus in trying to keep it in the namespace hierarchy
11:43cemerickSecond, if this is going to be used in a deployed app, then likely is no project directory.
11:43TimMcRaynes: http://4.bp.blogspot.com/_D_Z-D2tzi14/TOM8bCK7rRI/AAAAAAAAEFo/rjD1XRjQKns/s400/dogs38alt.png
11:44pandeirocemerick: yeah i'm a beginner, i don't know how the big boys do it
11:44TimMc^ not a sample rate thing
11:44cemerickpandeiro: namespaces are for code; this is just some data. :-)
11:44pandeirook few hours down the drain but i've learned my lesson
11:44cemerick'course, you *can* put non-code data in namespaces, but they're unnecessary, and probably won't fit into how the classpath ends up being configured at runtime.
11:45cemerickIMO, I'd just dump a "saved" database config to ~/.your-config-directory-name/config.clj.
11:46cemerick(spit (io/file (System/getProperty "user.home") ".your-config-directory-name" "config.clj") (pr-str database-config))
11:46cemerickThen (read-string (slurp config-clj-path)) to read.
11:47cemerickpandeiro: and make sure you're starting off with clutch 0.3.0 :-)
11:47pandeirocemerick: ok thanks... but i dont totally understand why it wouldnt be cleaner to put it in the project root dir if i am using lein or something?
11:47pandeiro(yep, clutch 0.3.0 :)
11:48cemerickpandeiro: You can certainly save it to the current directory — but when a user's app is deployed, there _is no_ project directory anymore.
11:48cemerickOr, you can't assume that there's one, e.g. might be a .war file.
11:49pandeiroi see
11:49pandeirocemerick: thanks a lot
11:49pandeiroTimMc: you too
11:49cemerickpandeiro: If there's a better location than what I suggested, then use that. Maybe noir has a convention for storing settings somewhere?
11:49cemerickAsk ibdknox when he's around. :-)
11:49pandeirocemerick: i will ask, for sure...
11:50pandeirocemerick: on a scale of 1 to 10, how hard is it to get the clojure view server up and running with clutch 0.3.0?
11:51cemerickpandeiro: Dead-balls simple IMO. See configure-view-server and view-server-exec-string docs @ https://github.com/ashafa/clutch
11:51pandeiroawesome, i will give it a shot
11:51cemerickI can imagine scenarios where it might not work, but it's done well in every environment I've tried.
11:52cemerickI think if I were using the view server for serious stuff in production, I'd probably use curl to automate the configuration so that it's stable and out of the app's hands (rather than re-setting it on every startup or something), but maybe that's just me being enterprisey.
11:53cemerickOn balance, I'm far more interested in the clojurescript view server. Hopefully that can be merged in soon.
11:54kreyhmpf, damn spymemcached
12:07pandeirocemerick: got it set up and working, easy... though i notice the classpath (due to noir, mostly) is about 40 lines long... should that be a concern, performance wise?
12:08cemerickpandeiro: nah, no worries
12:08pandeiroi'm curious too what the advantage of a clojurescript view server would be exactly? still requires jvm right?
12:09cemerickCapturing the whole thing is the only way to ensure that people's view function dependencies (if any) are available.
12:09cemerickpandeiro: Nope, no JVM needed with cljs views.
12:09cemerickThus the interest. :-)
12:09pandeirowow, i dont see how that can be
12:09pandeirobut that would be very cool indeed
12:09cemerickclojurescript compiles to javascript
12:10pandeirobut the program that compiles it runs on the jvm, no?
12:10cemerickTry it for yourself if you like: https://github.com/cemerick/clutch-clojurescript
12:10cemerickRight, yes, but you don't need a JVM/Clojure runtime for the view server.
12:10cemericki.e. you can run cljs-generated views on Cloudant, etc.
12:11pandeiroah i see
12:12pandeirothat is terrific
12:12cemerickYup.
12:12cemerickNote that clutch-clojurescript necessarily uses a bundled (now old) version of clojurescript. Feel free to tinker, but I wouldn't use it for anything serious until it's integrated into clutch.
12:14samaaroncemerick: do you know what's happening with clojurescript bundling?
12:14pandeirowhen you say necessarily, you mean it couldn't just seek out $CLOJURESCRIPT_HOME and try to use the compiler there?
12:14cemericksamaaron: Nope.
12:14pandeiroi ask naively, not having looked at the impl at all
12:14samaaronlast time I checked you had to run a shell script to download stuff to specific directories to get it to work
12:15cemerickdnolen might have a clue there.
12:15cmeiersamaaron: We have a Overtone band booked for our March meeting of the Cincinnati Functional Programmer's meetup :)
12:15samaaronwhich seems to be a temporary measure
12:15pandeirosamaaron: yeah the bootstrap script is still there
12:15samaaroncmeier: what??
12:15lazybotsamaaron: Uh, no. Why would you even ask?
12:15cemerickpandeiro: it could, but I think that'd be stupid, and a huge PITA upon deployment.
12:15pandeirolol ok
12:16cemerickpandeiro: I mean, you could easily throw an updated version of all the jars on the classpath, and stuff should work, but…
12:16samaaroncmeier: does this band have a name and a leader?
12:17cmeierGuys from EdgeCase Columbus office - inspired by Clojure Conj. (they are still working on a name)
12:17cmeierI will be happy to pass on suggestions :)
12:17samaaroncmeier: can you get them to email me some details?
12:17samaaroni'd love to know more about what they're doing
12:17cmeiersure
12:17samaaronthanks :-)
12:18samaaronas long as they don't use the name (λ-tones) I'm happy ;-)
12:19samaaronright, i'm going to cycle home
12:19samaaronchat later
12:20pandeirocemerick: last thing, i promise: did you guys ever consider some kind of helper function to facilitate authentication with the couchdb instance? it's a small PITA having to splice credentials into the URL... am i missing something?
12:20pandeiro(i've read through the clutch source but i couldn't find anything)
12:21cemerickpandeiro: just haven't gotten around to documentation yet :-)
12:21cemerick(-> "http://some-couch-url&quot; com.ashafa.clutch.utils/url (assoc :username "foo" :password "bar"))
12:22pandeironice
12:22cemerickThere are other fields of interest on the utils.URL record type.
12:23pandeiroyeah i saw that but i still dont grok what defrecord is and exactly how it's used... it's the connect function that returns an instance of it, yeah?
12:23cemerickpandeiro: connect?
12:24pandeirothe private fn used by couchdb-request
12:24jsabeaudryI have a ring handler that has a body "(repeat 0)" which I would like to use to test throughput but I get abysmally low speeds, is one tcp packet sent for each element of the ISeq?
12:24cemerickpandeiro: no, that URL is java.net.URL. :-P
12:25cemerickcom.ashafa.clutch.utils.URL is the only record type that clutch users should care about
12:25cemerick(which really only exists because java.net.URL sucks pretty hard)
12:26pandeiroi see, i need to try to understand what a record is first, but i did notice that piece of code when i was trying to figure out how to easily insert auth credentials
12:27cemerickfundamentally, you shouldn't need to know anything about http-client
12:27cemerickmost of it is going to be eliminated, FWIW :-P
12:28pandeiroi found the impl interesting since i just wrote a browser-side version of the same
12:28pandeiro(much simplified)
12:28pandeirowhen you say eliminated, you mean separated out into a different package?
12:28pandeirodifferent repo i mean
12:29cemerickWell, significantly refactored. Clutch currently uses the JDK's HTTP client, which has a number of failings. I'm hoping to use something more sane soon-ish.
12:42Raynesdakrone: Ping.
12:42dakroneRaynes: pong
12:43Raynesdakrone: I'm getting a strange error with the wunderground JSON API that I never got before. "ZipException unknown compression method java.util.zip.InflaterInputStream.read (InflaterInputStream.java:147)"
12:43RaynesI assume something changed on the server side, but I'm not sure what could cause something like this.
12:44dakronedo you have a url I can try to reproduce?
12:44RaynesCan you grab ororo? I'll let you use my API key.
12:44Rayneshttp://github.com/Raynes/ororo
12:45dakronesure
12:51dbleyl_hi. simple question. how do you overload a function that can take either a string, or a sequence of strings?
12:52dbleyl_do you test for sequential? or is there a cleaner way?
12:53dbleyl_destructure?
12:53nachtalpdbleyl_: (defn myfun [& args] ) ?
12:53cgraydbleyl_: you could do (defn foo [& strs] ...)
12:56TimMcdbleyl_: You mean, a single arg that is either a string or a sequence?
12:57dbleyl_yes
12:57TimMcI'd say (fn [x] (if (string? x) ... ...))
12:57TimMcand in the else clause, call seq on x
13:09dbleyl_TimMc: thanks. I'm going with defn x [[s & more]]
13:11TimMcI don't think that's what you want...
13:11dbleyl_the repl just proved that you are correct.
13:11dbleyl_treats string as a seq of chars.
13:11TimMcYou only ever have one argument, and destructuring won't help you dispatch on anything.
13:15jodarodbleyl_: i'm doing almost exactly that right now with multimethods
13:15jodaroso you might look there
13:22Vinzentdon't you think it'd nice to be able to write something like (defn foo ([^String s] ...) ([^IPersistentCollection coll] ...))?
13:23TimMcdbleyl_: multimethods would be useful if you want consumers of your code to be able to extend its functionality. Otherwise, just use an if.
13:26Vinzentor even [^pos? x] and [^neg? x] - much more declarative than spagetti of ifs! but it looks like I'm thinking about pattern matching
13:34cgraydoes the jvm impose its own limit on the number of open files that's allowed?
13:36hiredmanwhy do you ask?
13:37cgraybecause i'm having a problem where files aren't getting properly written... i have about 500 open, so i'm thinking that might be it
13:37hiredmancgray: are you properly closing the files?
13:37cgrayhiredman: i'm trying to keep them open so that there's no cost associated with seeking to append to them
13:38hiredmanare you flushing?
13:38cgrayyep
13:39hiredmanand have you tried it with closing the file?
13:39cgrayyeah, and that worked
13:39cgraybut it slowed down once the files got big
13:40hiredmanare you sure you are flushing?
13:40cgrayi'll put it in a gist
13:40hiredmanbecause closing automatically flushes
13:41cgrayhttps://gist.github.com/1511359
13:42hiredmancgray: most likely the gzip outputstream is the issue
13:43cgraythat seems strange to me because it worked when i was closing the file
13:44cgrayi'll try without it though
13:44hiredmanI imagine gzipos uses a certain blocksize, and waits for that blocksize number of bytes for writing to the underlying stream
13:44hiredmanand closing makes it stop waiting
13:45cgraythat makes sense, but what's happening is that files are getting big and then going back to 10 bytes...
13:45cgraylet me try without gzip though
13:45hiredmanyou have a race in your open-category-writer
13:46cgrayreally? i thought swap! was atomic
13:46hiredmanit is, but you don't check to see if a writer for that category exists
13:46hiredmanthe only thing atomic is the function you hand to swap
13:46cgrayi only use it if the category doesn't exist though
13:47TimMccgray: Your gist is deleted?
13:48cgrayTimMc: yeah, sorry... i kind of f-ed it up...
13:48hiredmanI am assuming this is a multithreaded program, you check for the existence outside of the function passed to swap, that means between the check and the call to swap some other thread could have swapped a writer in
13:48cgrayhiredman: it's not intended to be multithreaded, but it's a good point
13:49hiredmanif it's not multithread then why are you using an atom?
13:49cgraygood practice for global variables? what should i use instead?
13:49cgray(i don't have a great reason for that tbh)
13:50hiredmanwhy is it global?
13:50cgraybecause i'm mapping over the last function in the gist and it needs to change
13:50hiredmanwhy not reduce?
13:51cgraygood question...
13:51hiredman(reduce f writer-map ...)
13:52cgrayi think you were right about the problem being gzipwriter though
13:55kenthHi, is there a function that pulls up the code for a function loaded in REPL? or the return type?
13:56jodarosource
13:56kenthcool, thanks
14:04mcrittendenwhat's the best way to insert a | (bar) inbetween every character in a string, returning a new string. e.g. a function takes "test" as a param and returns "t|e|s|t" ...can interpose be used for this?
14:04mcrittendenin between*
14:04cemerick,(apply str (interpose \| "test"))
14:04clojurebot"t|e|s|t"
14:05mcrittendencemerick: ok so interpose returns a seq which is then converted back to a string via apply str?
14:05cemerickyup
14:05mcrittendenawesome, thanks a bunch
14:06amalloy&(clojure.string/join "|" "test")
14:06lazybot⇒ "t|e|s|t"
14:07amalloy(apply str (interpose foo bar)) makes me so sad. use join
14:07mcrittendenamalloy: cool, sounds good. thanks.
14:07mcrittendenbtw what's the diff between lazybot and clojurebot?
14:08cemerickamalloy: what can I say, I'm old school :-P
14:08amalloylazybot is lazier
14:09Raynesmcrittenden: They're entirely different bots. lazybot is written by amalloy and I and clojurebot by hiredman.
14:09amalloyseriously, the difference is: they're completely different source trees written by different people to do different things. clojure evaluation is the most important thing either does, but they both have a bunch of add-ons
14:10mcrittendenare either or both open source?
14:10mcrittendeni'd be curious to take a look
14:10amalloy~source
14:10clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
14:10amalloy$whatis source
14:10lazybotsource is http://github.com/flatland/lazybot
14:11Raynesamalloy: Did you see the latest?
14:11Raynes$guards
14:11lazybotSEIZE HIM!
14:11RaynesI can't believe nobody added this crucial feature.
14:12jodaroheh
14:12amalloyinteresting. is that a generic feature like clojurebot's ~foo, or a specific guards command?
14:12mcrittendenthanks amalloy!
14:12Raynesamalloy: Specific guards command.
14:12amalloy$help guards
14:12lazybotamalloy: SEIZE HIM!
14:13jodarolazybot has cool stuff like
14:13jodaro$wotd
14:13lazybotjodaro: pfeffernusse: (noun) A gingerbread biscuit served traditionally around Christmas time.
14:13RaynesStill waiting on jodaro to write the factoids plugin. Unfortunately, I'm not sure he knows he is supposed to do it.
14:13jodarofactoids?
14:13Raynes$know Who was the 7th president of the united states of america?
14:13lazybotRaynes: Andrew Jackson (1767-1845), the 7th President of the United States
14:14jodarothats pretty factoidish
14:14Raynesjodaro: It's magic and I was kidding.
14:14RaynesI'll do it eventually.
14:14jodaro$know what color is an orange?
14:14lazybotjodaro: orange (of the colour between red and yellow)
14:14RaynesIt's just the syntax that I'm having trouble coming up with.
14:15jodaropfeffernusse
14:29jsabeaudryIs there an easy way to coerce an ISeq to an InputStream?
14:35foodooDo functions declared by protocols always dispatch by their first argument?
14:36TimMcjsabeaudry: Your question doesn't make sense.
14:36amalloyyes
14:36TimMcjsabeaudry: Seqs produce objects, inputstreams produce bytes.
14:37foodooand should java.lang.object be used as a call-all variant of a protocol implementation?
14:38foodoocall-all -> catch all (sorry)
14:39jsabeaudryTimMc: these sound very similar to me. Basically I'm looking for way to make an input stream as easily as I can make an ISeq ( (repeat 10 0) for example)
14:40mcrittendenI'm trying to use clojure to read from stdin and having trouble. Here's a simplified example which I want to take input and just re-print it. Can someone take a quick look? https://gist.github.com/1511559
14:40mcrittendenactually, just figured it out. never mind!
14:42brehautfoodoo: yes, but its not a catch all; it just catches all objects
14:43brehautfoodoo: nil isnt an object
14:43TimMcjsabeaudry: If you're trying to convert sequence data into bytes, you have to serialize it somehow.
14:45TimMcjsabeaudry: I don't know offhand of any lazy inputstream producers, but it shouldn't be hard to write.
14:45jsabeaudryTimMc: What if it is already a byte (repeat 10 (byte 0))?
14:46mcrittendennew question, how can I tell clojure to stop listening to stdin when the user hits enter? https://gist.github.com/1511559
14:47jsabeaudryTimMc: alrighty, I'll look into writing these myself, thank you for your help :)
14:48gfredericksjust got a patch into underscore that fixes the cljs incompatibility
14:49TimMcjsabeaudry: You may want to look at gloss. It's a byte-oriented library.
14:49foodoomcrittenden: It's probably rather a Java issue as Clojure uses the java.io classes
14:49sritchiemcrittenden: usee (defn prompt-name [] (println "What's your name?") (read-line))
14:49amalloyfwiw, there's https://github.com/flatland/io/tree/develop/src/java/io/core which lets you reify an interface to create a new kind of InputStream instead of having to extend a class
14:51foodoomcrittenden: I forgot about (read-line) I only looked at clojure.java.io
14:51mcrittendensritchie wow, I wish I found read-line earlier. thanks
14:51sritchieno problem
14:52brehautamalloy: thats great
14:52amalloyand https://github.com/flatland/io/blob/develop/src/clj/io/core.clj#L8 is a sample implementation of turning a ByteBuffer into an InputStream
14:53jsabeaudryTimMc: Oh wow, thanks that gloss library is going to be handy!
14:54amalloybut yeah, gloss is pretty excellent for byte stuff. we wound up using gloss instead of this io lib we wrote
14:54TimMcI haven't had an excuse to use it yet. :-(
14:58foodoohypothetical question: Would it make sense to implement (seq coll) as a protocol so that anyone could create their own sequence types for Clojure?
15:00brehautfoodoo anyone _can_ implement their own seq types in clojure
15:00foodooBecause if I look at (reduce) it requires the collection to implement InternalReduce. But most types will already fail at the (let [s (seq coll)]) statement
15:00foodoobrehaut: How is the idiomatic way to do that?
15:01brehaut ,(map inc (reify clojure.lang.Seqable (seq [this] (list 1 2 3))))
15:01clojurebot(2 3 4)
15:01brehautfoodoo: implement clojure.lang.Seqable for your type
15:02foodoookay. That's a Java interface
15:02brehautyes.
15:03brehautfoodoo: whats the problem with that?
15:03foodooIt's okay.
15:04foodooMaybe it's just that this doesn't seem to be covered in the official docs
15:04brehautfoodoo: theres three[1] ways to make a type in clojure: defrecord, deftype, gen-classes. records already implement seqable, and you can trivially implement seqable for the other two. [1] ok so there is really more
15:06foodooah, thanks :) Still I wish this would have been better documented
15:06accelgood mrning ladies and gentlemen; it's 12:07pm here as we start coding clojure again
15:06amalloygoodness, when did #clojure get a sportscaster?
15:07brehautamalloy: 12:07pm dec 22, 2011
15:07amalloyso let it be written
15:07brehautis it the 22nd?
15:07mcrittendenyes
15:07accelshould I live cast my clojure coding session? I think I could improve quite a lot afer you guys see all the idiotic things I do.
15:11Bronsahere it's 21:11
15:24gfredericksif clojure is a sport, who is winning?
15:25hiredmanme
15:26pbuckleygfredericks: anyone writing code with it is winning? But like a football game their head hurts after playing.
15:28brehautgfredericks: im pretty sure it was a game of two halves, but clojure was the winner on the day
15:29brehautin hindsight that joke might not translate to non-rugby playing countries
15:29gfredericksI was just wondering if that was why I didn't understand it.
15:29pbuckleyI thought I just wasn't smart enough to get the joke
15:30accelis there a canonical way to reprenset infinity in clojure?
15:30brehautpbuckley: if im telling the joke, that should never be a problem
15:30gfredericksaccel: if there is I'd like to know about it. a couple times I wrote a bunch of arithmetic code that used :infinity
15:31hiredmanI write clojure code while wearing a bathrobe with "mr. bigshot" embroidered on it, I think I win
15:31amalloy&Double/POSITIVE_INFINITY
15:31lazybot⇒ Infinity
15:31accelgfredericks: what amalloy said :-)
15:31gfrederickshiredman: now that you mention that I think I remember it being the exact conditions for winning.
15:32amalloy&'∞
15:32lazybot⇒ ∞
15:32brehautaccel: alternatively (last (cycle :a))
15:32gfredericks,(+ 5 Double/POSITIVE_INFINITY)
15:32clojurebotInfinity
15:33kurtharrigerHow do I create a byte data type for 0xFE in clojure?
15:34kurtharriger(byte 0xFE) reports value out of range
15:34brehaut,(short 0xFE)
15:34clojurebot254
15:34brehauttheres no unsigned primative data in java
15:35kurtharrigerbut that returns a java.lang.Short I need java.lang.Byte
15:35brehautkurtharriger: time to start crying
15:35TimMckurtharriger: I can never remember how to do this.
15:35pbuckley&(- Double/POSITIVE_INFINITY Double/POSITIVE_INFINITY)
15:35lazybot⇒ NaN
15:35hiredmanhttp://www.javamex.com/java_equivalents/unsigned_arithmetic.shtml
15:36brehaut,Byte/MAX_VALUE ;; kurtharriger
15:36clojurebot127
15:36TimMcunchecked-byte?
15:36TimMc&(unchecked-byte 0xFE)
15:36lazybot⇒ -2
15:36TimMcHad to grep the chatlogs.
15:37kurtharrigerah ha
15:37kurtharrigerthanks
15:37TimMc&(doc unchecked-byte)
15:37lazybot⇒ "([x]); Coerce to byte. Subject to rounding or truncation."
15:37pbuckleyTimMc: how do you save the chatlogs? just C-x C-w?
15:38TimMcpbuckley: autolog_path = "~/chatlog/$tag/$0.log";
15:38TimMcin .irssi/config :-P
15:42pbuckleyTimMc: thanks, I just setup logging for erc :-)
15:45amalloyTimMc: i even remembered reading about unchecked-int, when i was looking into how to use the 4-byte constant 0xFFFF0000, but i was like..."naw, that can't be it. i must be misremembering and there's a way to enter it as a literal"
15:57amalloybrehaut: i finally remembered to use (map f x (rest x)) instead of (for [[a b] (partition 2 x)] (f a b)). you're a hero!
15:57brehauthah am i?
15:57amalloywell, cause it's better code and you usually write it that way
15:58ibdknoxall the cool kids do ;)
15:58brehautlol
15:58brehauthaskell has taught me some things apparently :)
16:01TimMcamalloy: Is that a correct transformation?
16:01amalloyTimMc: yes, i believe it's correct for all f and x
16:01TimMcI think you need a 1 in that partition to make it overlap.
16:01amalloyoh sorry
16:01amalloyyes, clearly need a 1
16:02TimMcpartition 2 1 x
16:02amalloyright
16:04TimMc&(take 10 (partition 0 (range)))
16:04lazybot⇒ (() () () () () () () () () ())
16:05TimMc&(take 5 (partition 0 1 (range)))
16:05lazybot⇒ (() () () () ())
16:06TimMc&(take 5 (partition 1 1 (range)))
16:06lazybot⇒ ((0) (1) (2) (3) (4))
16:06TimMc&(take 5 (map seq (range)))
16:06lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
16:06TimMc&(take 5 (map list (range)))
16:06lazybot⇒ ((0) (1) (2) (3) (4))
16:06TimMcOops, sorry -- I thought I was in /msg lazybot
16:07TimMcIt's a good thing I didn't decide to discuss intimate topics with the bot.
16:09Vinzentlol
16:10Vinzentcan you help me setup cljs+emacs?
16:11VinzentI've opened index.html from the repl sample which comes with clojurescript, started inferiour-lisp. I see the repl, but it hangs when I'm hitting enter
16:12Vinzent(I've followed instructions on cljs wiki)
16:13zakwilsonIs there currently a good reason to use Java 7 with Clojure?
16:13hiredmanthere are a lot of new features in 7
16:14hiredmanhttp://openjdk.java.net/projects/jdk7/features/
16:14hiredmanhuh, sctp support, I had forgotten that protocol even existed
16:20brehautibdknox: re:state-m in korma; did you come to any decision?
16:20ibdknoxI don't think it's the right thing to do
16:21ibdknoxbrehaut: it's very cool, but the trade-off in conceptual complexity doesn't seem worth it to me
16:21ibdknoxespecially given it's not common in Clojure
16:22TimMcMonads? In my Clojure?
16:23mcrittendenassuming a nested 3x3 vector, anyone have a smart way to convert a number 1-9 to the appropriate position in the vector? for example, 9 would become [2, 2] and 1 would become [0, 0] and 4 would become [1, 0]
16:23TimMcmod and div
16:23mcrittendenTimMc: cool, just didn't know if there was a shortcut. thanks!
16:24TimMcI don't think there's a divmod operator in Clojure.
16:25TimMc$findfn 20 6 [3 2]
16:25lazybot[]
16:26sritchie(juxt quot mod)
16:26TimMcOuch.
16:26sritchie,((juxt quot mod) 20 6)
16:26clojurebot[3 2]
16:26TimMc((juxt quot mod) (dec 9) 3)
16:26TimMc&((juxt quot mod) (dec 9) 3)
16:26lazybot⇒ [2 2]
16:26brehaut(comp (partial (juxt mod quot) 9) dec)
16:26ibdknox~juxt
16:26clojurebotjuxt is usually the right answer
16:27brehautrats. sniped twice.
16:28brehautand i got the order wrong. sigh
16:28amalloyi usually use (juxt quot rem). i think for positive integers it doesn't matter, and i can never remember the difference between rem and mod, but for negative ones it should matter
16:28ibdknox,(doc rem)
16:28clojurebot"([num div]); remainder of dividing numerator by denominator."
16:28ibdknox,(doc mod)
16:28clojurebot"([num div]); Modulus of num and div. Truncates toward negative infinity."
16:30foodoo~clojure
16:30clojurebotclojure is a language to use if you want to up your game
16:30brehaut~math
16:30clojurebotmath is hard.
16:30sritchie~science
16:30clojurebotscience is http://sunpig.com/martin/images/2008/10/iwilldosciencetoit.jpg
16:30foodoo~xkcd
16:30clojurebotGabh mo leithscéal?
16:30TimMc&(let [num 20, div -6, [a b] ((juxt quot rem) num div)] (= (+ (* a div) b) num))
16:30lazybot⇒ true
16:30TimMc&(let [num 20, div -6, [a b] ((juxt quot mod) num div)] (= (+ (* a div) b) num))
16:30lazybot⇒ false
16:32mcrittenden((juxt quot mod) (dec 9) 3) <- i love that so much. thanks all
16:32TimMcmcrittenden: Use rem
16:33mcrittendenin this case it will never be negative but I hear you, I'll use rem
16:33TimMcThe semantics are clearer.
16:34brehautmcrittenden: ordinals vs cardinals for your index might help too
16:35mcrittendenbrehaut: that just went over my head. care to explain?
16:35brehautstart counting at 0 rather than 1
16:35mcrittendenah so I can avoid the (dec x)?
16:35mcrittendengotcha
16:36TimMcbrehaut: I've never heard those words used that way.
16:36brehautTimMc: i thnk its a computerscience bastardisation of math
16:36TimMcHaha, OK.
16:36brehautTimMc: some languages have arrays that have 1 as the first index
16:36brehaut(BASIC for instance)
16:36TimMcYep.
16:37brehautso weird :P
16:38TimMcbrehaut: Are you sure that "ordinal" doesn't refer to 1-based in this context?
16:38brehautTimMc: nope ;)
16:38TimMccardinals definitely start at 0 in math
16:39TimMcWikipedia: "The finite ordinals (and the finite cardinals) are the natural numbers: 0, 1, 2, â...,"
16:39brehauttimmc: http://c2.com/cgi/wiki?OrdinalsAndCardinals
16:40brehautTimMc: note the 'minor nitpick' ;)
16:40zakwilsonibdknox: what do you think about the idea of replacing lazy-with in Korma with some sort of smart join?
16:40TimMcbrehaut: Yeah, that's a nice touch.
16:48ibdknoxzakwilson: what would be the between what join is now?
16:48ibdknoxand what you're proposing
16:48ibdknoxzakwilson: also, korma.incubator would be a great place to try such a thing :D
16:48zakwilsonibdknox: I just read about incubator *as you were typing that*.
16:49ibdknoxzakwilson: I'm not opposed to what I think you're going to suggest :) It's just slow and pretty annoying to implement (unless you drastically limit the cases you're willing to deal with)
16:50ibdknoxzakwilson: I assume you're saying a has-many that comes back in one query and then you dissect the results and put them into objects
16:50zakwilsonibdknox: yes, something like that.
16:51ibdknoxzakwilson: if it's limited to one level deep, then it's fairly easy to do :)
16:51zakwilsonEssentially, I want the apparent behavior of with, but one query instead of the potential for zillions.
16:51ibdknoxand would be a good addition I think
16:52mcrittendensritchie: your idea worked really well. thanks again. made good progress, learned a lot
16:53zakwilsonI've been thinking about this for a while - since before I even know about Korma. I had it in mind for ClojureQL - something that knows about relationships and generates a query to traverse them as requested.
16:53sritchieawesome
16:53semperosusing clojure.java.jdbc with h2, trying to select a column which returns a clob value
16:53ibdknoxzakwilson: indeed, I've done such things before
16:53semperosusing the function to "declobify" the text into a string shown here: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#SELECT
16:53ibdknoxzakwilson: it's a tough thing to build while maintaining flexibility and speed
16:54ibdknoxzakwilson: I'm all for trying to do it though
16:54semperosif I just try to go through the result set and println the declobbed string, it works fine; if I try the same operation, but use a for comprehension to return a seq of such strings, I get an error
16:54semperoshere's a gist showing what I'm doing: https://gist.github.com/1512012
16:54zakwilsonI had in mind something that looks like with and requires you to manually specify what you want to traverse - e.g. (with [:foo :bar :baz]) would join to foo, which joins to bar which joins to baz.
16:54semperosseems like I'm missing something basic; any thoughts?
16:55zakwilsonI also had in mind something that would traverse all known relationships to a certain depth: (traverse 3)
16:55hiredmansemperos: did you read the exception?
16:55ibdknoxsemperos: results need to be realized immegiately
16:55ibdknoximmediately
16:55hiredmansemperos: those things don't just messages for fun
16:55semperosI did read the exception
16:55semperosI don't understand how my two fn's differ in terms of when I'm realizing the results
16:55hiredman~for
16:55clojurebotfor is not a loop
16:55semperosright
16:56ibdknoxfor creates a lazy seq
16:56semperosah, that's right
16:56semperosthanks guys
16:56zakwilsonI haven't done anything like that before and honestly, I'm bad at databases, as my not-in group post illustrates. (I finally figured that one out, BTW and will post about it as soon as I fix the code)
16:56ibdknoxnp
16:56semperosthought it was something simple I was overlooking
16:57amalloyTimMc: btw, i had forgotten earlier, but the one that goes with mod is div. so div/mod or quot/rem are probably both reasonable; i was just objecting to quot/mod
17:00TimMcamalloy: Ah, there is a div? Good. I was speaking in general terms.
17:01brehaut,(apropos 'div)
17:01clojurebot(unchecked-divide-int)
17:01TimMc&((juxt div mod quot rem /) 20 6)
17:01lazybotjava.lang.RuntimeException: Unable to resolve symbol: div in this context
17:01amalloyapparently not
17:01TimMcharmph
17:02brehautdef mod (comp int /)
17:02brehauts/mod/div/
17:02amalloyi think unchecked-divide-int is basically div though
17:02TimMc&((juxt unchecked-divide-int mod quot rem /) 20 6)
17:02lazybot⇒ [3 2 3 2 10/3]
17:02TimMc&((juxt unchecked-divide-int mod quot rem /) 20 -6)
17:02lazybot⇒ [-3 -4 -3 2 -10/3]
17:03TimMc&(doc unchecked-divide-int)
17:03lazybot⇒ "([x y]); Returns the division of x by y, both int. Note - uses a primitive operator subject to truncation."
17:04TimMcOK, so that's the same as Java's / with integer types.
17:15antares_technomancy_: hi. I see that lein deps with 1.6.2 does not exit when one of the dependencies is not found. This causes stall builds on travis-ci.org and I can reproduce it locally. Is it a known leiningen issue?
17:17schleyfoxhi, is there any way to force identity equality (java ==) in clojure on the built in persistent data types?
17:17hiredman,(doc identical?)
17:17clojurebot"([x y]); Tests if 2 arguments are the same object"
17:17schleyfoxfantastic, thanks
18:33sridthe highest rated answer on a stackoverflow question reads: "You use hashmaps to represent members of the population. I'd rather recommend you create a little class to represent them" http://codereview.stackexchange.com/a/372/6446
18:33sridgoes against clojure's philosophy of using built-in datastructures to represent objects
18:38amalloysrid: that's a...ruby question? ruby dudes like classes; you should probably use classes in ruby
18:41sridyea, that's what I thought. it is non-straightforward to write functions / simple-datastructure code in ruby.
18:45alexbaranoskyno first class functions in ruby! (don't let them try to fool you : ) )
18:49amalloyalexbaranosky: i don't know a ton of ruby, but isn't Proc basically as first-class as clojure's functions? at a lower level both of them are actually instances of a class, but you treat them as functions
18:50alexbaranoskyamalloy: you have to go out of your way to make a proc though; meaning you can't just take a function and pass it around, like you could in JS or Python
18:51amalloyalexbaranosky: your argument is that functions are first-class, but most "functions" are actually methods, which aren't?
18:51alexbaranoskyamalloy, but maybe you could just write your code in terms or Procs, and leave methods out of the picture entirely, and then get away with it :)
18:52amalloyalexbaranosky: http://experthuman.com/programming-with-nothing was a fun blog post on that topic
18:52alexbaranoskyamalloy, well I guess I see JS and Python's approach as nicer - basically that their methods are functions with a this associated
18:52alexbaranoskyamalloy, I'll take a look in a minute
18:56alexbaranoskyamalloy, I've read enough of that article to realize it is awesome
18:57amalloygrep "lambda calculus" # pretty good indicator of awesome
19:01alexbaranoskyamalloy, I've been using `for` a lot more since ClojureConj thanks to your prodding
19:02amalloyexcellent. finding it suitable/useful?
19:02alexbaranoskydefinitely
19:03amalloynot coincidentally, i added 2 problems to 4clojure last night to introduce 'for
19:05alexbaranoskyhave I mentioned lately that Clojure is awesome ? :)
19:06alexbaranoskyfor a little fun I got the idea to write some "Java" in Clojure... Write a little project with all of the class-oriented features of Clojure just to flex more of those Clojure-muscles
19:16acceldoes {} always create hashmap?
19:17seancorfield,(type {})
19:17seancorfieldwhere's the bot?
19:17seancorfield&(type ())
19:17lazybot⇒ clojure.lang.PersistentList$EmptyList
19:17seancorfield&(type {})
19:17lazybot⇒ clojure.lang.PersistentArrayMap
19:18seancorfieldthe array map becomes a hash map once it has more than 10 entries i believe
19:18seancorfield&(type (into {} (range 30)))
19:18lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
19:18seancorfielddarn!
19:18seancorfield&(type (apply into {} (range 30)))
19:18lazybotclojure.lang.ArityException: Wrong number of args (21) passed to: core$into
19:18seancorfieldgroan...
19:19accel&(type {:a a, :b b, :c c, :d d, ... crap I'm tired
19:19lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
19:19seancorfieldheh
19:19accel30 is a big number.
19:19ibdknox&(into {} (partition 2 (range 30))
19:19lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
19:19ibdknox&(into {} (partition 2 (range 30)))
19:19lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry
19:19ibdknoxlol
19:19amalloyomg guys
19:19alexbaranoskyy'alls syntax is hurting my eyes ;)
19:19alexbaranosky:P
19:19amalloy&(into {} (map vec (partition 2 (range 30))))
19:19lazybot⇒ {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15, 16 17, 18 19, 20 21, 22 23, 24 25, 26 27, 28 29}
19:19seancorfieldsorry, i'm on vacation and my brain is away...
19:20amalloy&(type (into {} (map vec (partition 2 (range 30))))) ; if you like
19:20lazybot⇒ clojure.lang.PersistentHashMap
19:20seancorfieldthank you
19:20accelwoot
19:21accelhow many clojure-ists does it take to figure out the type of {} :-D
19:21amalloyactually, sorta simpler to do ##((juxt type identity) (apply hash-map (range 30)))
19:21lazybot⇒ [clojure.lang.PersistentHashMap {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15, 16 17, 18 19, 20 21, 22 23, 24 25, 26 27, 28 29}]
19:21seancorfieldis it 10 items or 15 that is the tipping point for array map becoming a hash map?
19:21amalloy10, for now
19:21seancorfieldyeah, i remember having to look in the source for a change i made in java.jdbc (removing structs)
19:22amalloyalso my hash-map example is ridiculous. of course it's a hash-map, i asked for a hash-map
19:22ibdknox:p
19:22seancorfieldhahaha
19:22seancorfield&(type (into {} []))
19:22lazybot⇒ clojure.lang.PersistentArrayMap
19:23seancorfieldgotta love juxt tho'... i'm using that a lot these days
19:23amalloy~juxt
19:23seancorfieldwhen i have a sequence of maps and only want a subset of the keys, juxt is perfect! :)
19:23amalloyclojurebot: :(
19:24amalloyseancorfield: juxt isn't really ideal for that. what if your keys aren't all keywords?
19:24ibdknox&(doc select-keys)
19:24lazybot⇒ "([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
19:25amalloyright, select-keys or (map the-map [k1 k2 ...])
19:25amalloydepending on if he wants out a map or a tuple
19:25ibdknoxyeah
20:05brehautim pretty sure you oculd write an accurate siesmic activity monitor by drinking the twitter firehose
20:06TimMcbrehaut: Or scraping usgs.gov. :-P
20:06brehautTimMc: in new zealand its geonet.org.nz :P
20:06brehautbut its at least 15 minutes behind twitter
20:07accel#<questino redacted, reading "Proggramming Clojure" instead>
20:10TimMc< amalloy> seancorfield: juxt isn't really ideal
20:10TimMc:-O
20:10TimMc$guards
20:10lazybotSEIZE HIM!
20:12accelhow do I allow a function to be able to call itself?
20:14hiredmanrecur is the best way
20:14accelrecur looks like it[s paired with loop
20:14skeeterbughttp://java.ociweb.com/mark/clojure/article.html#Recursion
20:14accelI'm not sure how to use recur/loop to write a recursive (non-iterative) version of fibonacci
20:15accelskeeterbug: nice; thanks
20:15amalloyTimMc: any good relationship, like mine with juxt, is predicated on honesty. someone has to be there to tell him when he's going out in an ugly shirt
20:15accelin a very weird way; multimethods also get me out of this bind
20:17jlibah.
20:18TimMcamalloy: haha
20:18jliamalloy: what's ugly?
20:18brehautaccel: you need to refactor fib into a tail recursive form before recur is useful
20:19TimMcaccel: Functions can call themselves without doing anything special. What's the trouble.
20:25jliTimMc: "without anything special"? not quite - if you want it to be tail recursive, you need to use recur
20:25TimMcjli: accel is asking for general recursion, not iteration
20:26jlioh
20:26TimMc...which is odd, but whatever.
20:26TimMcaccel: I shudder to think how you are using multimethods for this.
20:27brehautTimMc: i wonder if he means he actualy wants mutual recursion
20:27accelnono; just a function calling itslf
20:27accelim an idiot
20:27brehaut,((fn fib ([n] (if (< 2 n) (fib (- n 2) 1 1) 1)) ([n a b] (if (<= n 0) b (recur (dec n) b (+ a b))))) 10)
20:27accelwhen I ask a question, it it can either be internted as (1) sheer stupidity or (2) a brilliant way to tackle a known difficult problem; asusme (1)
20:28brehautclojurebot hates my fib
20:29amalloybrehaut: clojurebot is dead atm
20:29brehautthat would be why then
20:29brehautin that case http://spl.smugmug.com/Humor/Lambdacats/13227630_j2MHcg#965006899_x8v3L
20:30brehautTimMc: re earthquakes; twitter told me it was a mag 5.8 in chch nearly 20 minutes before gns had the official reading
20:32qbgbrehaut: I like this one: http://spl.smugmug.com/Humor/Lambdacats/13227630_j2MHcg#1288212148_5KLHJ3V
20:32brehauthaha
20:33LoganLKWhat clojure book or guide would you recommend for someone who knows Java but has never done any functional programming/lisp before?
20:33amalloypersonally i recommend Joy of Clojure to all comers. some people claim it's not a good first book but i dunno what is wrong with them
20:34amalloy4clojure.com is free and fun, but a bit narrowly-focused - it teaches mechanics more than the big picture
20:34ekoontzI like Clojure in Action by Amit Rathore a lot
20:35ekoontzhas a lot of practical stuff like integration with SQL and HBase
20:35qbgYou can also complement those books with SICP or the SICP videos
20:35brehauttheres very little waffle in Joy of Clojure; if you are new to FP or lisp you probably dont want to belt through it in only a few sittings. if you space it out a bit it should be fine
20:36LoganLKmany thanks
20:36hiredmanI recommending reading the documentation on clojure.org
20:37hiredmanyou can start from the top of the left side bar and work your way down
20:37qbgTake this with you: http://clojuredocs.org/
20:38amalloyoh yeah, SICP is excellent too
20:38TimMcbrehaut: You will of course recall the XKCD re: speed of Twitter vs. speed of seismic waves.
20:38brehauthiredman: occasionally going back to the top and going down again is helpful too
20:38brehautTimMc: yes.
20:38TimMcbrehaut: I periodically re-read clojure.org/lisps in particular
20:41TimMc&((fn fib [n] (if (< n 2) 1 (+ (fib (- n 1)) (fib (- n 2))))) 6) ; accel: see, fib calls itself directly
20:41lazybot⇒ 13
20:41qbgLoganLK: http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
20:44brehautTimMc: the slow version is so much cleaner than a linearized version
20:44TimMcNot if you have recur.
20:45TimMcThe explicit accumulator version is slightly ugly.
20:45brehautTimMc: yeah, that version is linearized
20:46brehaut&((fn fib ([n] (if (<= 2 n) (fib (- n 2) 1 1) 1)) ([n a b] (if (<= n 0) (+ a b) (recur (dec n) b (+ a b))))) 6)
20:46lazybot⇒ 13
20:49amalloythey're all uglier than the iterate version, though
20:54qbg&((fn [n] (let [f (fn [n f] (if (<= 2 n) 1 (+ (f (- n 1)) (f (- n 2))))) f (memoize f)] (f n f)) 6)
20:54lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
20:54qbg&((fn [n] (let [f (fn [n f] (if (<= 2 n) 1 (+ (f (- n 1)) (f (- n 2))))) f (memoize f)] (f n f))) 6)
20:54lazybot⇒ 1
20:55qbg&((fn [n] (let [f (fn [n f] (if (<= n 2) 1 (+ (f (- n 1)) (f (- n 2))))) f (memoize f)] (f n f))) 6)
20:55lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: sandbox19315$eval21954$fn--21955$f
20:55qbg&((fn [n] (let [f (fn [n f] (if (<= n 2) 1 (+ (f (- n 1) f) (f (- n 2) f)))) f (memoize f)] (f n f))) 6)
20:55lazybot⇒ 8
20:56qbg&((fn [n] (let [f (fn [n f] (if (< n 2) 1 (+ (f (- n 1) f) (f (- n 2) f)))) f (memoize f)] (f n f))) 6)
20:56lazybot⇒ 13
20:57brehautamalloy: hah yes definately
20:59qbg&((fn [n] (first (nth (iterate (fn [[x y]] [y (+ x y)]) [0 1]) n))) 6)
20:59lazybot⇒ 8
20:59qbg&((fn [n] (first (nth (iterate (fn [[x y]] [y (+ x y)]) [1 1]) n))) 6)
20:59lazybot⇒ 13
20:59qbgYep, iterate is good
21:00brehaut&((fn [n] (first (nth (iterate (juxt second (partial apply +)) [1 1]) n))) 6)
21:00lazybot⇒ 13
21:00brehautmuch better ;)
21:01TimMcbrehaut: Are you a wizard? o.o
21:01amalloyhaha brehaut, i hadn't seen it written out with juxt
21:02brehautTimMc: oh. my bad ##((comp first (partial nth (iterate (juxt second (partial apply +)) [1 1]))) 6)
21:02lazybot⇒ 13
21:02amalloyin fairness though, you should be starting with [0 1]
21:02hiredman,(tkae 10 (let [p (promise)] (deliver p (lazy-seq (concat [1 1] (map + @p (rest @p))))) @p))
21:02hiredmandamn
21:02clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: tkae in this context, compiling:(NO_SOURCE_PATH:0)>
21:02hiredman,(take 10 (let [p (promise)] (deliver p (lazy-seq (concat [1 1] (map + @p (rest @p))))) @p))
21:02clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NullPointerException>
21:02brehauti took qbg's code and mangled it; i take no responsibility for the logic
21:02qbghiredman just took my idea
21:02qbg:)
21:03amalloynice. i was getting set to mock you for actually naming a variable, brehaut
21:03brehautamalloy: lol
21:03brehauthiredman: thats great
21:03hiredmanif the damn thing worked
21:03brehauta mere detail
21:04amalloyhiredman: chunked seqs causing the problem?
21:04brehautTimMc: i had an point-free epiphany when i learnt haskell. its been hard to shake it ever since
21:04qbg&(take 10 (let [p (promise) s (lazy-cat [0 1] @p)] (deliver p (map + s (rest s))) @p))
21:04lazybot⇒ (1 2 3 5 8 13 21 34 55 89)
21:05qbg&(take 10 (let [p (promise) s (lazy-cat [1 0] @p)] (deliver p (map + s (rest s))) @p))
21:05lazybot⇒ (1 1 2 3 5 8 13 21 34 55)
21:05hiredman,(take 10 (let [p (promise)] @(deliver p (lazy-cat [1 1] (map + @p (rest @p))))))
21:05clojurebot(1 1 2 3 5 ...)
21:05sandy1986Hi, wrap-reload doesn't work. I'm using net.cgrand.moustache and lein ring server-headless 8080 to run the app
21:06TimMc&(doc lazy-cat)
21:06lazybot⇒ "Macro ([& colls]); Expands to code which yields a lazy sequence of the concatenation of the supplied colls. Each coll expr is not evaluated until it is needed. (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))"
21:07qbg&(take 10 (let [p (promise) s (lazy-cat [0 1] @p)] (deliver p (map + s (rest s))) s))
21:07lazybot⇒ (0 1 1 2 3 5 8 13 21 34)
21:08qbgHehe... Only one deref
21:08brehauthiredman: does that imply that you can use promises to implement any 'tie the knot' type stuff for mutually recursive data?
21:08amalloybrehaut: that only works because of the delayed execution provided by lazy sequences
21:09qbgWell, a promise basically is mutation under the covers
21:09hiredmanwell, you can use any kind of mutable state to do it, promises are just nice cause it is one shot
21:09hiredmanI have a letfn as a macro that uses promises are delays or something under the covers
21:09hiredmanor
21:09qbgIf clojure was fully lazy and had letrec, we wouldn't need it in this case
21:10hiredmanhttps://gist.github.com/1179073
21:11amalloyhiredman: probably promises. doing it with delays doesn't seem easy
21:11brehautibdknox: are you paying attention?
21:11amalloydamn it i hate you. delays, huh?
21:11hiredmanI guess, I don't really recall how it works
21:12hiredmanI would have thought promises
21:13accelhow do I convert a string to a throwable?
21:13brehaut(Exception. "string")
21:13brehaut,(Exception. "string")
21:13clojurebot#<Exception java.lang.Exception: string>
21:13brehauton the other hand. dont, and go look at slingshot
21:13amalloyinteresting. it looks like you're having the body of each function start with (let [f (force f-delay), g (force g-delay)] ...). makes sense, i suppose
21:13accelbrehaut: noted; thanks
21:13accelbrehaut: why?
21:14qbg&(Throwable. "string")
21:14lazybot⇒ #<Throwable java.lang.Throwable: string>
21:14brehautaccel: because why tunnel data through strings when you can use a arbitrary structured data
21:14qbglolz
21:14brehautthrowable is a class?
21:14brehautnot an interface?
21:14qbgyes
21:14brehautgoddamn java
21:14hiredmanright, I sort of remember this, because clojure isn't lazy you just can Y combinator up the functions, you need delays
21:14accelbrehaut: gah; how am I supposed to remain a crappy clojure programmer if you keep on telling me the right way to do things?
21:14amalloyslingshot is great, but it's hardly the only choice. using underlying host exceptions makes interop easier
21:15hiredmanyou can't just Y combinator up
21:15qbgbrehaut: You also can't have generic subclasses of throwable
21:15qbgLuckily it doesn't matter to Clojure users...
21:15brehautqbg: i seem recall all this. but everytime it comes up i am annoyed
21:16hiredman1.4 is gonna have ExceptionInfo
21:16qbgThat made the ACM programming competition hard
21:16amalloyoh really
21:16hiredmanhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ExceptionInfo.java
21:17brehautexcellent!
21:17hiredmanand slingshot already sort of supports using it instead of using slingshot's own exception class
21:17amalloywelp, that's good. now slingshot doesn't need a Stone anymore; it can just be a layer of nice macros on top of this ExceptionInfo thing, right?
21:18hiredmanhttps://github.com/scgilardi/slingshot/blob/master/src/slingshot/support.clj#L19
21:18hiredmanright
21:19accelwoot; it owrks again
21:19accelyay for learning how to use exceptions
21:19brehautthats some crafty code
21:19accelI feel like I should pay you guys tuition.
21:19accelWhat do you prefer, chicken or beef flavored ramen?
21:20accelOkay; no tuition then.
21:20hiredmanbrehaut: it went through a number of iterations to get to that
21:20brehautgeez christchurch; calm the fuck down
21:22brehauthiredman: it re-emphasises my need to go looking at other peoples code in detail.
21:22accelbecause it's incomprehensible or beacuse it's brilliant?
21:22qbgSo Throwable is Serializable... Not sure why you would want to do that
21:22brehautaccel: if i wanted incomprehensible i'd be a c++ developer
21:23hiredmanqbg: rpc exceptions
21:23accelbrehaut: Im pretty sure you can get most of the way there with defmacro
21:23qbghiredman: makes sense
21:23brehautaccel: defmacro is simple
21:24brehautaccel: the syntax quote reader stuff makes macros seem a bit more magical than they really are
21:24amalloybrehaut: fwiw, i prefer (every? #(ns-resolve 'clojure.core %) '[ex-info ex-data])
21:25accelbrehaut: I have no problem with defmacro; it's the things that defmacro can create that scares me.
21:25brehautaccel: i dont really have anything to say to that
21:26brehautamalloy: nice
21:26hiredmanthe real tricky bit is using resolve again down below
21:26qbgaccel: Like compiler-in-a-macro macros?
21:27hiredman(which is required to avoid statically linking to a particular implementation at compile time)
21:30brehautaccel: more seriously, even though i can use the basics in clojure well, there is a heap of real smart stuff out there that is worth learning from, so why waste the opertunity
21:31accelbrehaut: for you absolutely; for me, I still need to master basis
21:31brehautaccel: reading comprehension comes before writing comprehension
21:32brehautif you only read what yuo are writing, its going to take a lot longer to learn
21:33brehautaccel: start with 'source' in your repl; whenever you use a new function, see how its implemented.
21:34TimMcOf course, sometimes you'll just see calls to RT, or nasty tricks, or implementation-specific stuff.
21:34TimMcThe stuff near the top of core.clj is more likely to have those.
21:36accelwhy is clojure's map so much uglier than sicp's map?
21:37brehautdoes sicp have a variadic map?
21:37hiredmanclojure's map also handles chunked seqs
21:37brehautand is it lazy?
21:37hiredman(except when it isn't)
21:38hiredmanreally chunking is what makes it ugly
21:38ibdknoxbrehaut: hm?
21:38accelis there a good book of clojure pearls?
21:38accelI wouldn't mind reading such a text.
21:39brehautibdknox: did you see the discussion about using promises and delays to write macros that allow mutually recursive data?
21:39ibdknoxI didn't, but that's what I did...
21:39ibdknoxlol
21:39brehautthats what i thought :)
21:40hiredman,(for [m (repeat 5 {:a {:b {:c 1} :d 2} :e 3}) [k v] m :when (= k :a) [k v] v :when (= k :b)] v)
21:40clojurebot({:c 1} {:c 1} {:c 1} {:c 1} {:c 1})
21:41hiredman,(for [m (repeat 5 {:a {:b {:c 1} :d 2} :e 3}) [k v] m :when (= k :a) [k v] v :when (#{:b :d} k)] v)
21:41clojurebot({:c 1} 2 {:c 1} 2 {:c 1} ...)
21:42brehaut4clojure?
21:43hiredmanme? no, for is just cool
21:43brehautah :)
21:50hiredmanactually letfn- has 5 calls to for
21:53brehauthiredman: is letfn- just a reimplementation of letfn? or does it do some other stuff?
21:53hiredmanI believe it is just letfn
21:57accel(def a 20) `(,a) <-- why does this not say (20) ?
21:57accelinquiring minds want to KNOW
21:57accelUNDERSTAND ALL THE THINGS
21:57hiredmanbecause this is not scheme
21:57brehautbecause a: a is an int, not a function
21:57brehautb: , is white space
21:57clojurebotAlles klar
21:57ibdknoxlol
21:57accelcrap
21:57accelhow do I unquote in clojure?
21:57brehaut,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:a
21:57clojurebot:a
21:57accelbrehaut: point taken
21:57hiredmanaccel: read the docs, you'll find out
21:58accelREMOVE ALL THE ,'s
21:58accelhiredman: this question actuallyc ame from watching the clojure data structures part 1 screencast
21:58brehaut(thats incidentally why clojurebots eval character is superior to lazybots. sorry ranyes)
21:58accelha
21:58accel~
21:58clojurebotGabh mo leithscéal?
21:58hiredmanbrehaut: well, I got to pick first
21:59brehauttrue
21:59brehautits still objectively better :P
21:59TimMcamalloy: Why did sexpbot get changed to lazybot?
22:00amalloyTimMc: sexpbot looks too much like sexbot
22:00ibdknoxI always read it as sex-puh-bot
22:00amalloyand is hard to pronounce, too. lazybot is a more awesomer name all around, really
22:01brehautamalloy: now to get core to introduce a new visible whitespace character into clojure
22:01amalloymeh
22:01amalloyi agree , is nice, but & is fine too, and sticks out a bit more
22:07TimMcamalloy: Hard to pronounce, which is a major problem in an IRC channel. :-P
22:08hiredman,(* 12345678 12345678)
22:08accel19 minutes into Clojure Data Structures part 1; and I realize I have learned more from it than an entire season of terra nova
22:08clojurebot152415765279684
22:08TimMc,Long/MAX_VALUE
22:08clojurebot9223372036854775807
22:33sandy1986;) bye bye.
22:37accelwhoa
22:37accelclojure's built in numeric types are quite nice
22:37accelwhy has no one written mathematica within clojure yet?
22:37accelclojureritica is just a matheamtica binding
22:37accelbut not actual mathematica
22:46moogatronic_If I have a function that uses destructuring: (defn test [& {:keys [a b c] :or [a 1 b 2 c 3]}] (+ a b c)) is there a way to call the function and pass a map as the params?
22:47moogatronic_like: (test :b 0 {:a 1 :c 7}) ... ie, can i pre-destructure the params somehow?
22:48brehauti recall this coming up before, and ithink the solutions are fairly hideous
22:48brehaut(flatten the map into a seq of keys and vals)
22:49brehaut,(apply (fn [& {:keys [a b]}] [:a a :b b]) (mapcat identity {:a 1 :b 2 :c 3}))
22:49clojurebot[:a 1 :b 2]
22:50brehautmoogatronic_: i think the problem is that java has no varargs; they are a myth built ontop of an array of objects.
22:52moogatronic_brehaut: ah, I will investigate this. THat looks usable. The destructuring is nice for the function def, but sometimes I build up a map of the params that I want to pass along.
22:52brehaut,(destructure ['[& {:keys [a b]}] [:a 1 :b 2]])
22:52clojurebot[vec__61 [:a 1 :b 2] map__62 (clojure.core/nthnext vec__61 0) map__62 ...]
22:53brehautmoogatronic_: if you can, make the function take a map; you could provide a utility that takes varargs and calls that