#clojure logs

2010-10-11

00:06TaigerRobocothmm
00:07TaigerRobocoti am trying
00:12freakazoidanyone use flymake + magit and have issues with emacs CPU usage just gradually increasing over time?
00:12freakazoidor otherwise have such a problem and have hints for debugging it
00:19automataI'm trying to use rosado's clj-processing on a lein project but getting some error messages
00:20automataany help?
00:25TaigerRobocotamalloy: else in clojure is " (if (= x y) x , :else y) " ?
00:26automatai'm getting this message: (ns live-processing.core
00:26automata(:use [rosado.processing]))
00:26automatajava.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (NO_SOURCE_FILE:1)
00:26maravillasthere's no :else
00:26maravillasjust (if (= x y) x y)
00:26amalloyTaigerRobocot: no, :else is pard of cond. (if CONDITION if-true if-false)
00:26amalloy,(if false 10 20)
00:26clojurebot20
00:26TaigerRobocottk
00:53TaigerRobocotis normal a function with recur return two value? example: instead returns 5 it returns 56 and I want ignore number 6 (next step of method recursive)
00:54amalloyTaigerRobocot: i don't understand what you're asking. can you pastebin or gist an example?
00:55TaigerRobocothttp://pastebin.com/jyrLH4Lk
00:55TaigerRobocotI call -> (fact 0 1 9)
00:56amalloyTaigerRobocot: you're using (def) when you really want (let). def creates a global variable, not a local
00:56TaigerRobocot let requires a vector for its binding
00:56amalloy,(let [x 10] x)
00:56clojurebot10
00:57amalloy,(let [auxN (+ 1 4)] auxN)
00:57clojurebot5
01:01TaigerRobocotcool, and that problem returning to values?
01:05amalloyoh i see. it's not returning two values; one of them you're printing and the other it's returning
01:06amalloyto make it clearer what's going on, you could turn the print into a println, but i think you probably just want to return the number instead of printing it: (if (= auxN numero) auxN)
01:09TaigerRobocotoh, alright.... can I break after print ? The printed number is more important
01:10TaigerRobocotanyway, is almost solved :)
01:11amalloytry something more like this: (cond (= auxN numero) auxN, (> auxN numero num), :else (+ num...))
01:11amalloyer, except i misparenthesized the > expression. you see what i mean, i hope
01:16freakazoidwhat's the reason for using vectors for that stuff, anyway? Syntax?
01:20TaigerRobocotfreakazoid: where?
01:21freakazoidlet, fn, etc
01:23TaigerRobocotamalloy: thank u for support, do u have a palpay account for donation?
01:23amalloyfreakazoid: i'm hardly a language authority, but they seem to be the most convenient way to group a bunch of items
01:24amalloyTaigerRobocot: lol no, support on #clojure is free and comes with no warranty :)
01:31amalloyfreakazoid: can you imagine writing (fn) with no [] for arg-specs? you need some way to separate the list of arguments from the function body
01:32freakazoidsomehow lisp and scheme seem to manage it.
01:32freakazoidbut it sounds like you're saying it's just syntactic.
01:34amalloylisp uses () instead though, right? you need *some* separator, and in clojure [] is available as a convenient grouping mechanism that doesn't "look" like it will treat its first member as a function
01:35freakazoidRight, so syntactic. I was just wondering if it served a further purpose.
01:36freakazoidIt certainly makes Clojure code easier to read than CL or Scheme code.
01:37freakazoidthere are some lisp dialects that have [] as just an alternate syntax for lists and use them in particular places by convention
01:37amalloyfreakazoid: it also simplifies rich's bootstrapping. check out (source defn) - he checks the arguments to see what order they're in; there's a check for vector? in there somewhere
01:37freakazoidoh groovy
01:37freakazoidso they do serve a further purpose, then
01:37freakazoid,(source defn)
01:37clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
01:38freakazoidblah
01:38amalloyfreakazoid: clojurebot doesn't have the source code, either
01:39amalloyclojurebot: source?
01:39clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
01:39amalloyclojurebot: clojure source?
01:39clojurebotclojure is far closer to perfection then python
01:40freakazoidThat's true, though clojurebot's spelling isn't.
01:40amalloyfreakazoid: http://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L263
01:42amalloyclojurebot: clojure?
01:42clojurebotclojure > scheme
01:42amalloyyou are so unhelpful
01:42freakazoidhmm, how do I get the jarfiles lein downloads into swank's classpath in emacs?
01:42amalloyclojurebot: github?
01:42clojurebothttp://github.com/richhickey/clojure/tree/master
01:42freakazoidclojurebot: cookies?
01:42clojurebotGabh mo leithscéal?
01:43amalloyclojurebot: github is http://github.com/clojure/clojure
01:43clojurebotIk begrijp
01:43amalloyclojurebot: github?
01:43clojurebotgithub is http://github.com/clojure/clojure
01:43amalloyclojurebot: botsnack
01:43clojurebotthanks; that was delicious. (nom nom nom)
01:43amalloyfreakazoid: you gotta treat him nice :)
01:44carkh~src defn
01:44clojurebotGabh mo leithscéal?
01:44carkhmhh
01:44carkhclojurebot: source defn ?
01:44clojurebotNo entiendo
01:46carkh~source defn
01:46carkhahaaa !
01:47carkh~botsnack
01:47clojurebotthanks; that was delicious. (nom nom nom)
01:48amalloycarkh: clojurebot needs to be updated: he still thinks richhickey has the source, not clojure
01:48amalloyi'll put together a patch for hiredman
01:49carkhrich isn't updating this repository at all ?
01:49raekthe clojure fork is the official one
01:49amalloyhe might be, but it's not the definitive source. and the last commit to this repo was in june
01:50carkhok
01:55amalloycarkh: okay, it's out of my hands now - should be fixed whenever hiredman pulls my repo and builds clojurebot again
01:55carkhnice thanks =)
02:05ossarehwith ring and wrap-cookies I should be able to (assoc (request :cookies) "cookiename" "cookievalue"), right?
02:10amalloyossareh: i haven't used ring, but looking at the source it looks like that's the wrong api
02:13ossarehthat might be because my example was incomplete? - my route is returning {:status 302 :headers {<redirect header>} :cookies (assoc (request :cookies) "x" "y")}. As I read http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/cookies.clj it looks for :cookies in the response and writes the values?
02:13amalloyor hrm, ossareh, i take it back. that looks fine api-wise, but because maps are immutable you're adding a value and then throwing it away
02:13amalloyoh. well that looks reasonable
02:14ossarehyeah, I'm trying to ensure I keep any cookies passed in, hence assoc'ing on the request cookies
02:14ossarehwondering if you can't set cookies on 302's.
02:15ossarehahhh
02:16ossarehI see
02:16ossarehthe cookie is having it's path set to my handler that is causing the redirect - so I don't see it in other requests.
02:21LauJensenGood morning all
02:23amalloythis seems like a silly question, but what is defn-? i see it defined as "a non-public defn", but what is that?
02:23carkhthe function defined with defn- cannot be accessed from another namespace
02:26LauJensencarkh: Well. You can still access non public fns using #'someotherns/private-function
02:27carkhbut that's cheating =)
02:27LauJensenNot if you're writing unit tests
02:28amalloymmmm, i love functional languages. if a function is too big, just cut/paste a subtree into a new function, and pass in whatever variables it needs; no need to worry about pass-by-value semantics
02:30LauJensenmmmm, order of execution is irelevant, mmmmm
02:31amalloyLauJensen: truly a delicious side-effect of not having side-effects
02:31LauJensenfunctional poetry
02:32notsonerdysunnycan I make cake automatically load a file when it is starting the swank server?
02:39amalloynotsonerdysunny: i don't know how, but you could modify src/cake/tasks/swank.clj to add it without too much trouble
02:40LauJensenhere's what I said in #cake.clj: swank opens your projects cp, which is also what bake gives you access to, try this (deftask swank-load #{swank} (bake (:use yourns) [] (load-file "somefile.clj"))) ?
02:44amalloyactually i take it back, notsonerdysunny. try $ cake swank && find src -name '*.clj' | xargs cake run
02:45amalloy(assuming you want to run everything. if you want to be more specific, pass whatever files you want to cake run
02:58LauJensenamalloy: I think notsonerdysunny is a new breed of troll, who pops up in technical channels, asks technical questions that make people think about how to answer, and then just ignores the result. Quite intelligent trolling
02:58amalloyLauJensen: no, he asked the same question yesterday, or ten hours ago or something
02:59LauJensenamalloy: So it works several days in a row with the same question? ingenious
02:59amalloyand if you were right, i'm not sure it would count as trolling. more like a socratic public service
02:59LauJensenhaha, good call
02:59amalloyLauJensen: har har. i don't think anyone answered last time
03:02notsonerdysunnysorry guys .. I am not trolling .. I was just trying what you guys suggested
03:03amalloynotsonerdysunny: don't worry about it, LauJensen's just a grumpy old man. stay off his lawn
03:04LauJensennotsonerdysunny: dont worry about it, the above was actually just a joke intended to have your name highlighted a few times, of course I know that you're not trolling :)
03:05amalloyLauJensen: -1 for knowing your audience :)
03:07LauJensen?
03:07amalloyLauJensen: he didn't know it was a joke. hence you aren't very good at telling jokes
03:08LauJensenamalloy: theoretically, couldn't it just be that you two are morons? No wait! Im kidding again! :) Okay I'll take a break from stand-up now
03:08amalloyhaha
03:09notsonerdysunny:)
03:14amalloyew, really? i can't write (comment TODO: whatever) because TODO: is an illegal token? i can understand needing comments to have balanced parens, but...
03:15carkhthe inside of your comment is going through the reader
03:15carkhyou might want to use ; comments
03:16LauJensenamalloy: or #_(comment TODO: whatever lol)
03:16amalloyLauJensen: that doesn't work. #_ is shorthand for comment
03:17amalloycarkh: yeah, i usually do, but for a long TODO list i decided to make it multiline
03:17LauJensen,#_(comment TODO: whatever lol)
03:17clojurebotInvalid token: TODO:
03:17amalloyclojurebot: thanks
03:17LauJensenodd, that works in my repl
03:17clojurebotI don't understand.
03:17amalloyLauJensen: what version of clojure?
03:18LauJensenwhich version? I was testing in 1.2, but I tested with #_(comment hi there), it was the TODO: which was triggering eval
03:18amalloyyeah
03:23amalloyLauJensen: i've noticed that using destructuring in function arglists causes (doc f) and eldoc to look ugly. i can add {arglists} metadata to my functions to present a cleaner look, but is there a way to have it automatically use my :as declarations in the arglist?
03:23amalloyeg (defn myfunc [{name :fname last :lname :as person}]) automatically get the simple arglist of [person]?
03:24LauJensenNot that I know of
03:25LauJensenBut I think for clarity, you wouldn't want that either, 6 months from now its nice to know whats being looked up in person
03:28amalloyhm, maybe. i suppose you could turn each destructured vector into a ([simple] [{thing1 :complex1 :as simple}]) pair
04:04notsonerdysunnyLauJensen: what you had suggested does not seem to work.. when I get a repl... I am able to load the file .. but when I did this in the "swank-load" task .. it is unable to see the file..
04:05LauJensenWhere is the file on disk ?
04:06notsonerdysunnyit is in lib/ .. it is one of the dependencies
04:07LauJensena .clj file?
04:10notsonerdysunny.clj is in a jar file ..
04:10notsonerdysunnyto be precise .. I am trying to use Clojuratica .. I want it to automatically establish the mathematica connection when it starts
04:11notsonerdysunnyClojuratica contains a bunch of .clj files "jar"red together
04:11LauJensennotsonerdysunny: Ok. I dont have a lot of time right now. But when you use the bake macro as I showed above, that lets you exec code at compiletime which has all the dependencies of your project loaded, so simply load it as you normally would. The #{swank} syntax means that this runs before swank launches.
04:12notsonerdysunnyoh thanks .. I did understand what you had given me .. but wasn't able to get it working
04:13notsonerdysunnythanks for you help though
04:13LauJensennp, you can ping me tonight if its still not working, but the guys in #cake.clj are very helpful so you should be able to get this going :)
04:17notsonerdysunnyLauJensen: actually I am sorry .. I had quoted the NameSpace
04:17notsonerdysunnythat is why it was not working
04:17notsonerdysunnynow it seems fine
04:17LauJensengreat :)
04:17opqdonutwhat's the status of definterface?
04:20notsonerdysunnyLauJensen: one more thing .. how is load-file searching for the files.. should the path be relative to some directory ..
04:20notsonerdysunny-> (doc load-file)
04:20LauJensennotsonerdysunny: I think its just relative to (System/getProperty "user.dir")
05:11quizmeis there a way to shorten this? http://pastie.org/1212551
05:14carkh(:use [ring.middleware params file-info reload file stacktrace])
05:14mrBlissquizme: http://gist.github.com/620252
05:14carkhi don't know much about ring, but there might be a namespace which imports them all
05:26raekfor prefix lists, lists should be used, iirc
05:27raekthat vectors works happens to be an effect of how it's implemented
05:27raek(:use (ring.middleware params file-info reload file stacktrace))
05:27mrBlissraek: You're right, but I think it looks better ;-)
05:28carkhi prefer vectors too =)
05:29carkhi even put vectors around single imports to make it regular
05:30LauJensenAnd it really makes no difference does it?
05:32raekI put my sense of aesthetics to the side and write it the documented way :-)
05:32mrBlissa stu said you should use lists because that's what the documentation prescribes
05:33raekjust beware of the empty-prefix-list syndrome...
05:34raekthat is, (:use (foo)) which doesn't do anything
05:34carkhit uses foo
05:34carkhi do that all the time =P
05:34raekvectors or lists?
05:35carkhvectors
05:37raekit works with vectors (meaning use without options), but not for lists (meaning empty prefix list)
05:41LauJensenyea, so vectors are safer
05:42raeka fair point
06:28philip``Hi, i'm trying to get cake running on my gentoo box, but it just raises an exception and hangs when i do "cake". The exception is "NoClassDefFoundError: Could not initialize class java.util.Currency". I've tried to find java.util.currency in emerge, but i can't seem to find it. Am i overlooking something?
06:29philip`` /join #cake
06:29philip``erh...
06:29Chousukeare you sure your java is properly installed?
06:30ChousukeCurrency is a standard component of the JRE
06:31Chousuke(And I doubt cake depends on it, so your problem might not be with cake)
06:31philip``Chousuke: I think i've installed icedtea, but i must admit, i was quite confused as to what packages to install.
06:31philip``Maybe i should try with sun/oracle jre?
06:31Chousukeicedtea should work I think
06:31philip``okay
06:31Chousukebut I don't know anything about Gentoo
06:32philip``Do you know of any simple way to test my java?
06:33Chousuketry writing a Hello World
06:36LauJensenphilip``: its #cake.clj
06:37LauJensenphilip``: java -version ?
06:38LauJensenphilip``: or java -cp clojure.jar clojure.main -e '(println "Hello, world!")'
06:38jarpiainalso, eselect java-vm list
06:40philip``LauJensen: version: http://gist.github.com/620331
06:40philip``And yeah, somethings definitly wrong. Hello world doesnt work, i get a nosuchmethod exception.
06:41philip``as in, it cant find System.out.println
06:41LauJensenphilip``: Clean your system, install Oracle/Sun JRE/JDK
06:41LauJensenAt least thats my recommendation, Ive spent enough hours debugging OpenJDK already :)
06:42philip``I'll try that. Thank you.
06:43don333given 2 files - main.clj and rtta/run.clj - where main :uses rtta.run, I can't slime-eval-buffer the main.clj in Emacs
06:43don333it gives me "Could not locate rtta/run__init.class or rtta/run.clj on classpath"
06:43tobiasraederhey :)
06:43LauJensenhey tobiasraeder, hows the project coming along?
06:44tobiasraeder@LauJensen good good, nearly done with the interop side so soon i should be mainly doing clojure that looks like clojure ;)
06:44don333what is the proper way to work in slime with namespaced files using other namespaced files?
06:48tobiasraederwhat interface do i need to implement to be able to use deftyped classes like a map?
07:01tobiasraederor to formulate it different, anyone worked with ILookup and ILookupThunk?
07:56philip``Okay, java is working now, and so is cake :). Now i'm having problems with emacs/swank-clojure... I'm running swank with 'cake swank', and i can connect from emacs just fine. Evaluating functions in the REPL is working too, but if i open up a file in another buffer and compile a function with C-c C-c, emacs hangs for a bit and gives me this error: "error in process filter: Wrong type argument: sequencep, 0.007100712"
07:56philip``. The compilation works fine, but it's really annoying with the little delay...
07:57philip``Also, exceptions make emacs hang, but the debugger window doesnt appear. I have to switch the that buffer manually :-/
08:00LauJensenC-h k C-c C-c ?
08:00LauJensenAnd did you connect using slime-connect ?
08:00LauJensenphilip``: ^
08:02notsonerdysunnyHello ..
08:03philip``LauJensen: C-c C-c runs slime-compile-defun. I am connected in the repl window, and the other buffer has majormode clojure-mode and slime minor mode. When i compile a defun from the clojure-mode buffer, it gets compiled and i can run it in my repl buffer, but not without giving me an error
08:03LauJensenphilip``: try slime-eval-defun instead
08:04LauJensennotsonerdysunny: hey
08:04notsonerdysunnythe slime interaction is kinda slow when compared to sbcl .. it becomes significant when an exception is thrown and you just press q to return to repl.. is this expected
08:04notsonerdysunnyHey LauJensen
08:05philip``LauJensen: Okay, thats snappy like i'd expect (for a simple function that sums two numbers...) Just need to bind that to C-c C-c instead i guess?
08:05LauJensenYes sir
08:05LauJensenphilip``: Also, you might want to try Arch Linux :)
08:07philip``LauJensen: Haha, yeah, some of my friends tell me that too. But i think i'm going to stay with Gentoo for a while. terminal-porn is nice :)
08:08kryftArch Linux. ♥
08:08LauJensen<3 Arch Linux E>
08:09philip``(updating chromium compiles for 3 hours straight. It's almost like an orgy!)
08:09LauJensenArch is Ubuntu without the bloat, Gentoo without the suck, Debian without the Flintstones, OSX without the femininity and totally unlike Windows
08:09fro0gphilip``: distcc :)
08:10LauJensenAlso, Arch can do about 90 critical program updates in around 90 seconds. Gentoo can do it in 90 years :(
08:10philip``Is it also ubuntu without the fucked up non-textfile-configurations?
08:11LauJensenphilip``: Yea, its not even Debian based, so its pretty far from Ubuntu
08:11LauJensenExcept for my monitor layout I dont think I have anything thats not in some way text based configuration
08:11philip``I spend almost a week getting xmonad running acceptably in ubuntu 9.10 because configuring x is fucked up...
08:12LauJensenreally? Should be super easy though http://media.slated.org/albums/userpics/10002/ubuntu.png
08:14fhdHi there. Has anyone tried TDD with Clojure? Is it possible to use mock objects? I couldn't find a reasonable way.
08:14AWizzArdHallo fhd.
08:14philip``LauJensen: Not my experience. Setting up xmonad for gdm was just weird... (okay, thats not x, but i had problems with that too!). I totally gave up trying to get stumpwm to work, but it's been smooth as a babys butt on gentoo (havent tried xmonad though, but stumpwm was piece of cake)
08:15LauJensenfhd: I've seen a few post on TDD, but if Im not mistaken Rich Hickey has pretty strong views on TDD, ie. not liking it. I could be wrong though
08:15LauJensenphilip``: Im using Awesome on Arch, though thats no cake-walk since they changed Cairo dramatically Im locked on version 1.8 and they're on 1.10 now IIRC
08:15fhdLauJensen: I've seen some posts too, but none go into detail.
08:16AWizzArdfhd: You say you can't find a reasonable way. What ways did you try so far?
08:16fhdMore general, even without TDD, how can I e.g. create a "provider" interface and create several implementations of it in Clojure?
08:16philip``LauJensen: That sucks. You
08:16fhdI never thought about doing something like that in Lisp because I only used it for scripting. But now I need an architecture that supports exchanging of backends.
08:17philip``LauJensen: You're the one from bestinclass right? It's very nice, part of what convinced me to try out clojure. Thank you for that :)
08:17fhdAWizzArd: Well, I tried a function that would accept an fn object as an argument, which was either the mock function or the real one. I hated that approach...
08:17kryftphilip``: Everything has been easy on Arch Linux. =)
08:17LauJensenphilip``: sweet, glad to hear it :) np
08:18LauJensenkryft: Which WM are you using?
08:18Chousukefhd: you can use protocols, multimethods or higher order fns
08:18Chousuke(higher order protocol fns work too I guess :P)
08:18kryftLauJensen: xmonad
08:19kryftLauJensen: I also opted for OSSv4 instead of ALSA, but other than that, I guess my setup is fairly standard (and minimalist :)
08:19fhdChousuke: I'll look into that stuff. Nothing rings a bell, but as I said, I've only used Lisp for simple scripting so far
08:19fhdBeing forced AFK now...
08:19Chousukefhd: protocols are kind of like interfaces, only more dynamic
08:20philip``kryft: How's OSSv4 working out for you?
08:22kryftphilip``: No complaints. :) Well, something occasionally blocks the soundcard although I have vmix enabled, so I should probably take a look at that at some point.
08:23kryftphilip``: I don't think I had that problem when I first installed my system, so probably something changed with a kernel update at some point or something.
08:23AWizzArdfhd: bist du aus Köln? :)
08:23ChousukeI should try installing a Linux distribution at some point but I can't be bothered :P OS X has fewer annoyances.
08:24Chousuke(big ones, but fewer)
08:26kryftIn addition to xmonad, I use a vertical keyboard from safetype ( http://www.safetype.com ) and vimperator for firefox, so guests who just want to check their webmail tend to be quite confused. :)
08:26Chousukeheh
08:26LauJensenkryft: You use Vimperator because you cant afford Conkeror?
08:26ChousukeI use vimperator too
08:27ChousukeI find vimperator to be better than conkeror :P
08:27LauJensenChousuke: how so ?
08:27kryftLauJensen: Conkeror?
08:27LauJensenkryft: conkeror.org
08:27Chousukevi keys work better for browsing than emacs keys
08:27LauJensenChousuke: how so ?
08:27Chousukeemacs keys require too much movement away from home row
08:28LauJensenChousuke: Got a link to an overview of the bindings?
08:28LauJensenafk
08:28fro0gas a conkeror alternative, have you tried keysnail?
08:28ChousukeLauJensen: j/k and link hints with mostly homerow characters. pretty much all you need.
08:28kryftLauJensen: Huh, hadn't heard about that. I'm quite happy with vimperator, though, and it's easier to install the extension all over the place than to actually install a new browser. :)
08:29fro0ghttp://github.com/mooz/keysnail/wiki
08:29shooverChousuke: define_key(default_global_keymap, "j", "cmd_scrollLineDown");
08:29shooverdefine_key(default_global_keymap, "k", "cmd_scrollLineUp");
08:29shoover
08:29Chousukebut I suppose if you're used to emacs Conkeror is better for you.
08:29kryftAlso, if Conkeror doesn't have vimish keybindings, it's not an alternative. =)
08:30kryftThat reminds me; I'm considering migrating from vim to emacs+vimpulse (or whatever they have these days)
08:30ChousukeI find the vi input model superior to emacs'. As an editor, however, emacs is better.
08:30kryftHas anyone tried that?
08:30kryftChousuke: Heh, that's precisely why I'm considering emacs+vimpulse. :) Best of both worlds, it would seem.
08:30kryftIn principle at least, which is why I'm curious about people's experiences.
08:30ChousukeThe problem with viper/vimpulse is that most emacs extensions don't work well with it.
08:31Chousukethey expect the emacs input model
08:31Chousukeand break vi stuff in weird ways.
08:31philip``I tried conkeror out one time, but i couldn't get RndPhrase working, so it was pretty much a no-go since i couldnt log in anywhere...
08:31Chousukeso basically you'll be able to edit text with vi keybindings just fine but any more advanced stuff is going to have to be done with emacs keybindings.
08:32philip``Liked the idea though.
08:32kryftChousuke: Can you give an example of more advanced stuff?
08:32Chousukekryft: using paredit, for example
08:32kryftChousuke: What's that? :P
08:33Chousukestructural editing for lisp code (and some non-lispy languages too)
08:33kryftAh, that's a minor mode, I guess viper/vimpulse is a minor mode too?
08:33Chousukeyeah
08:34kryftChousuke: So what do you use?
08:34philip``Going home.
08:34ChousukeI use vi for quick editing and emacs for serious stuff :P
08:35kryftHmm, I feel quite lost without vi editing commands. :/
08:35ChousukeWell I haven't invested that much into either editor.
09:08fhdAWizzArd: Ja :)
09:08kryftIs that 'yes' or 'and'?
09:09fhd"Yes" :)
09:09kryft(I'm guessing 'yes', but I'm a stupid parser ;)
09:36LauJensenChousuke: Okay cool, I'll try Vimperator. though I fear I will never be happy until I've integrated Conkerors keybindings into Uzbl
09:36fhdBut I'm wondering. If Hickey doesn't like TDD, why is the testing support of Clojure so neat?
09:37fhdSure, it could be used for plain old unit testing, but come on, that's boring...
09:38LauJensenfhd: I haven't heard his views directly from him so dont put too much weight on it. What I know is that Rich and I are both inspired by the talk Out of the Tar pit (http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf) which IIRC talks about reducing complexity to enhance your ability to reason up front as a way of quality assurance, as an opposite to letting your test suite dictate your code
09:40fhdHm, sounds similar to TDD. TDD is not really about testing, it's more about design in fact.
09:41fhdLeads to real nice designs in Java IMO, but I'm not yet sure if it makes sense in Clojure. I found that I have difficulties applying it, so I stopped and decided to try it once I'm more confident with the language.
09:42bobo_i agree
09:42bobo_the tests that come out of TDD is not the most important thing, but it is a realy nice addition :-)
09:44noidi_what's the difference between clojure.contrib.seq-utils and clojure.contrib.seq? is one deprecated in the favor of the other?
09:44noidi_their documentation is identical... http://richhickey.github.com/clojure-contrib/#seq
09:46chousernoidi_: hm. probably clojure.contrib.seq-utils is deprecated in favor of the other, though a docstring to that effect sure would be nice.
09:46chouserthen -utils naming scheme is "older"
09:49quizmemrbliss: thanks
09:51noidi_chouser, thanks
09:58defnchouser: good idea -- it would be nice to have doc-strings which say if we're using functions from a deprecated namespace
10:01chouserdefn: I think there are some plans in the works to manage contrib differently. Should help with this kind of version management task.
10:02LauJensenchouser: which plans?
10:03chouserLauJensen: I haven't heard any decisions announced
11:25MunksgaardWhen i try to evaluate something which throws an exception in my repl (in emacs, via cake swank) the exception-window (the one where i can chose to quit, continue etc) doesnt show up. The buffer is there, and i can switch to it, but (unlike normal slime with clisp or sbcl) emacs doesnt automatically switch to the error handling window. This causes some annoyances (in particular it makes error handling slow), is there
11:25Munksgaard any way to fix it?
11:25Munksgaard(It's me, philip´´´ from earlier :-) )
11:26kryftMunksgaard: Philip.. Munksgaard.. I think I see a connection!
11:26Munksgaardkryft: Indeed, Philip Munksgaard is my name! xD
11:26kryftMunksgaard: Amazing!
11:27MunksgaardI know right?
11:29MunksgaardStill doesn't help my problem though :/
11:29kryftSorry. :(
11:30kryftI suck at being helpful or useful.
11:30MunksgaardMe too, i just want help all the time :-(
11:31esjMunksgaard: I usually have two buffers up in emacs.
11:31esjso when an exception/stacktrace is thrown it turns up in one of them and its easy to tab over and deal with
11:33Munksgaardesj: Well yeah, thats kind of what happens when i'm working with clisp. I have to buffers (a file and a repl) and when i evaluate something which causes an exception, the other buffer automatically switches to the exception and focus is switched to that buffer.
11:35esjbut in clojure it doesn't ? Afraid I can't help you then, my emacs-fu is lame. I just installed form elpa to according Technomancy's instructions and went from there. Seems to work
11:40Munksgaardesj: Exactly, it's not the same in clojure :-(
11:40esjthat's a bummer dude.
11:42Munksgaardhm, yeah. Guess i'm going to have to write perfect code without exceptions :-)
11:49esjthat's the spirit
13:30defnchouser: good to hear -- i found the renames to be sort of a PITB
13:41DeusExPikachui just read http://www.learningclojure.com/2010/10/latest-collection-of-filthy-hacks-for.html and the author asks if he is allowed to require everything in an agent in order to not block the repl startup, is there any forseable problems with this method?
14:09scottjIs there a way to write (defmacro by [x fname forms] `(do ~@(map (partial cons fname) (partition x forms)))) so (by 2 def [a 1 b 2]) and (let [c [a 1 b 2]] (by 2 def c)) and (by 2 def '(a 1 b 2)) all work?
14:09chouserYes!
14:10chouseroh. no.
14:11scottjthere's some limitation to macros that I'm not grasping because I seem to run into this a lot
14:11chouserthe problem is youre middle example. At compile time (when the 'by' macro is expanded) the fact that there is a local named c is known, but it's runtime value has not yet been computed
14:12chouserthe runtime value of c could be anything, computed in any number of ways (user input, etc) so 'by' cannot at compile time change it's behavior or output different code based on the *value* of c
14:14chouserscottj: does that make sense?
14:18chouserif you were willing to go a little nuts with the use of lexical context introspection and eval, you could make something that would (usually) work, but would have surprising (in the bad sense) performance characteristics
14:18chouser...and in a larger sense is rarely the right approach.
14:20scottjyeah, the application is where I get tripped up. so macros can only output code based on their literal inputs, not what they resolve to?
14:20chouserThey can only output code based on what's known at the time that form is compiled.
14:21chouserImagine if your example were (defn f [& c] (by 2 def c)) (f a 1 b (slurp "foo.txt"))
14:26scottjnot following that, hung up on a being evaled bc f is a fn
14:27chouserok
14:27chousernp
14:27chouser(defn f [& c] (by 2 def c)) (f 'a 1 'b (slurp "foo.txt"))
14:27scottjwith macros re the inputs to the macro is the only thing known at compile time their literal value?
14:28chouserright, the arguments are the forms themselves, not what they would evaluate to at runtime.
14:28Chousukeeverything evaluated prior to the macro executing is available though
14:29Chousukeso def'd globals, java libraries (including reflection) etc.
14:29chouserwith the forms come metadata (you can get their line number, type hints, etc). You also get access to the lexical context via &env and &form, so you can (with some effort) discover the names and perhaps types of locals that will be available to the code your macro returns.
14:30chouserso once you're in this deep, more important than the fact you're getting literals is *when* you're getting them.
14:30chouserwhen (defn f ...) is compiled above, no macro in its body can possibly know what the value of c is going to be at runtime.
14:31chouserit just hasn't happened yet
14:31chouserscottj: but for you specific example, you've got a few options
14:32chouser(map (partial apply intern *ns*) '{a 1 b 2}) ; works fine -- no macros!
14:33chouseryou could write a function intern* so that it's just (map intern* '{a 1 b 2})
14:33chouser...but that's because there's a function 'intern' that does much of what 'def' does.
14:34chousermost other macros or builtins would be much harder to work with
14:34scottjnice, I actually want a generic by more than specifically a def with multiple args
14:34chouseryeah, I figured.
14:35LauJensenchouser: Isnt his middle-example doable by peeking in &env?
14:36chouser(let [c [true (prn :ok) (prn :oops)]] (by 3 if)) ; never gonna work right
14:36chouserLauJensen: no
14:38chouserpeeking at &env could tell you c is a local. If it's not a fn argument, you could (in a unsupported, fragile way) look at the form used to initialize it ...but that could itself of course be a function call or any other runtime thing.
14:39gary_posterHi. I'm using spare moments to play with clojure and liking it. While playing, I just encountered a behavior I can't figure out quickly. I don't understand something simple, I suspect. Given...
14:39gary_poster(require '[clojure.contrib.str-utils2 :as s])
14:39gary_posterThis works
14:39gary_poster(#(s/join " " %) `("hello" "world"))
14:39gary_posterbut this gives me "java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector"
14:39gary_poster(-> `("hello" "world") #(s/join " " %))
14:39chouserin hact, (let [c [a 1 c 2]] ...) is simply a syntax error unless a and b are already defined.
14:39chouserin fact
14:39gary_posterIs someone willing to enlghten?
14:39chouserand if they are defined, c will have their values, not their names.
14:40hiredmangary_poster: macroexpand the form
14:42raekgary_poster: -> and anonymous functions can be a bit surprising
14:42scottjchouser: thanks for the help
14:43raek(-> foo #(bar %)) --> (-> foo (fn [%] (bar %))) --> (fn foo [%] (bar %))
14:43gary_posterhiredman, raek, wow, yeah, that's not what I expected at all. thank you
14:47gary_posterSo I guess the intended work-around is either "don't do that" or
14:47gary_poster(-> `("hello" "world") (#(s/join " " %)))
14:47gary_posterwhich works
14:47TeXnomancygary_poster: you probably want ' instead of `
14:47TeXnomancythe latter is mostly meant for macro use
14:48gary_posterah, k, thank you TeXnomancy
14:48gary_posterI think I might have known that at one point ;-)
14:52chousergary_poster: right. or maybe you want the thrush combinator instead of ->
14:53chousergary_poster: http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
14:54chousergary_poster: (thrush '("hello" "world") #(s/join " " %)) might do what you expect
14:55raekgary_poster: had never thought about putting it in parens...
14:55hiredmanchouser: I doubt it
14:55gary_posterchouser: was reading, looks very nice. Experientially, it does work.
14:55raekbut that seems to solve the problem
14:55chouserhiredman: oh? why's that?
14:55hiredmanoh, thinking of K
14:55chouseroh
14:55gary_posterchouser: BTW, purchased your book & like it :-)
14:56gary_postercongrats
14:56chousergary_poster: thanks! glad you like it.
14:56chouserhiredman: I'm lousy with the combinators. 'map' is as much as I can handle.
15:08iwilligis there a way i can search for reference types from within slime ?
15:08iwilliglike i want to find the location of a type on my class path
15:14arkhI'd like to use a lazy and infinite sequence in a for - (take 100 (for [x (range 10) y (range 10) z (lazy-sequence-thing 1000)] ... ) ;;; Is there a better way than to use take ? Downside with take is a person has to multiply x and y to take the right number.
15:16chouserare you intentionally only using the first thing from (lazy-sequence-thing 1000)
15:16chouser?
15:16arkhwell ... multiply the number of elements in x and y
15:16chouserbut you want z to only ever be the first value from (lazy-sequence-thing 1000)?
15:16arkhI'd like to use as many things of the lazy sequence as there are elements in x and y combined/multipled
15:17chouserer, wait.
15:18chouser,(take 9 (for [x (range 3) y (range 3) z (range 100)] [x y z]))
15:18clojurebot([0 0 0] [0 0 1] [0 0 2] [0 0 3] [0 0 4] [0 0 5] [0 0 6] [0 0 7] [0 0 8])
15:18arkhactually, here's what I have: (take 20 (for [subday (range 10) day (range 2) value (next (lazy-change 1000))] (str day " " subday " " value))))
15:19chouserlazy-change is infinite?
15:19arkhyes
15:19chouserthen subday and day will always be 0
15:20chouserno matter how many you take
15:20arkhoh yeah! because it happens from the 'right-side' first ...
15:20arkh: ( lol
15:20chouseryeah
15:20arkhsorry
15:20arkhwe can reverse the order of subday, day, and value
15:20chouserdo you want to be cycling through subday and day in step with lazy-change?
15:21arkhyes
15:21chouser,(map vector (for [x (range 3) y (range 2)] [x y]) (range 100))
15:21clojurebot([[0 0] 0] [[0 1] 1] [[1 0] 2] [[1 1] 3] [[2 0] 4] [[2 1] 5])
15:22chousermap is the way to walk more than one seq in step, and stops as soon as any of them end, so ... just what you want, I think.
15:22arkhyes - thank you very much
15:23gary_poster...ooh, clojurebot, cool...
15:24jacortinas,(println "yup")
15:24clojurebotyup
15:24gary_posterlol
15:29lpetitHello ther e!
15:29chouserlpetit: hi!
15:30LauJensenlpetit: bonjour mon ami! c'est la vie? qui qui!
15:30lpetitLauJensen: I wish I could talk Danish as you speak French, my friend !
15:31LauJensenhaha
15:33iisjmiiCan anybody tell me how to gice clojure a typehint for an array of integers (as created by int-array) is it #^Integers?
15:33hiredman#^ints
15:34hiredmanI believe
15:34iisjmiithx
15:34hiredmanwell, ^ints if you are using 1.2
15:34iisjmiiand do you know if I have to give type hints to all nested bindings?
15:35shanmuhi all, any feedback on clj-record in the community? (I did google, but could not get any conclusive answers)
15:37shanmuIs it quite polished or does it need TLC to get it to work?
15:38ossarehwhat is clj-record?
15:38shanmuhttp://github.com/duelinmarkers/clj-record "clj-record is a Clojure persistence library inspired by Ruby on Rails’ ActiveRecord but aimed at using LISPey functional idioms."
15:38shanmuit does not seems to be based on clojureQL
15:42chouserI'm suspicious of all ORB
15:42lpetitchouser: you mean ORM ?
15:42chouserand my experience with ActiveRecord informs that opinion. But I haven't looked at clj-record at all.
15:43chouserlpetit: er, yeah, that. :-)
15:43shanmuI am tempted to roll my own with ClojureQL as an abstraction layer
15:43shanmunot a full blown ORM, but whatever my project demands.. (more of a FRM functional relational mapper)
15:46romain_phi, who wants to help a beginner improve his code?
15:46romain_phttp://pastebin.com/UnmC4g9J
15:46romain_p(trying to create a map that index a list of words by count)
15:47shanmuromain_p: if you want a ready made solution, look at frequencies
15:47shanmu,(doc frequencies)
15:47clojurebot"([coll]); Returns a map from distinct items in coll to the number of times they appear."
15:47shanmu(source frequencies) would help refine your code
15:47romain_pshanmu: tx
15:48LauJensen,(reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} ["hi" "there" "oh" "hi"])
15:48clojurebot{"oh" 1, "there" 1, "hi" 2}
15:48LauJensenromain_p: Coming from imperative languages you naturally look for loop, but often reduce is more idiomatic
15:48raekwhat is the best way of representing the null character in code? \u0000 ?
15:49raekit gets printed as \^@ for me
15:49raekmaybe that's slime...
15:49romain_pLauJensen: tx
15:51raek,\u0000
15:51clojurebot\
15:52shanmuwhat is (or is there) a group/artifact id for using clojureql with leiningen?
15:52bobo_shanmu: http://clojars.org/org.clojars.snuxoll/clojureql that one?
15:53shanmubobo_: not sure - clojureql seems to be from bestinclass.dk
15:53raekhttp://gitorious.org/clojureql/clojureql/blobs/master/build.gradle seems to indicate [clojureql "0.9.7"]
15:53shanmuraek: thanks!, checking
15:54raekhttp://new.clojars.org/repo/clojureql/clojureql/0.9.7/
15:54LauJensenbobo_: that snuxoll guy is weird. He worked ClojureQL, broke it, then put the jar on Clojars.
15:54raekthe only version on clojars, anyway
15:54bobo_LauJensen: :-/ thats the problem and benefit of clojars
15:54bobo_its ffa
15:54LauJensensure is.
15:55shanmuLauJensen: are you the LauJensen behind clojureql?
15:55LauJensenshanmu: yea
15:55bobo_im suprised to see a build.gradle from LauJensen ? wheres the cakelove?
15:55LauJensenhttp://clojars.org/clojureql
15:55shanmuLauJensen: cool.. thanks for the work!
15:55LauJensenbobo_: Meikel, my co-pilot on ClojureQL, wrote Clojuresque. Though for version 1.0 I'll likely switch to Cake :)
15:56LauJensenshanmu: np, its a team effort though
15:56bobo_:-)
15:59bobo_dont think ive been at gitorious before, i dont think i like i
15:59bobo_t
16:05LauJensenbobo_: We moved because Github at one time was unuseably slow. We emailed them for action and waited a couple of months, then moved
16:06LauJensenIts actually been quite pleasant. They have a great system for handling merge requests etc
16:10bobo_yeh github can be insaenly slow sometimes :-/
16:14LauJensenI haven't experienced it in the last 6 months or so
16:16kevins_I have a n00b question (just getting my feet wet w/ Clojure)
16:16kevins_trying this : user=> (map first ["hello" "world"])
16:16kevins_(\h \w)
16:17kevins_first is the first letter of each string, how do I get all of the chars of the string (i.e. results would be (\h \e \l \l \o...etc..)
16:17kevins_so not first, not rest....the entire string in chars..
16:17Chousuke(seq string)
16:17kevins_seq..
16:17Chousuke,(seq "foo")
16:17clojurebot(\f \o \o)
16:17Chousukeseq makes sequences of sequenceable things :)
16:18kevins_I tried .toCharArray...but I got back a list of references....I'll read up more on seq.
16:19raekthe functions that take a sequence in clojure will call seq on their argument
16:19Chousukekevins_: the sequence is a basic abstraction in clojure
16:19raekwhich is most often called 'coll' in the docs
16:20raek(seq (.getBytes "hello" "US-ASCII"))
16:20hiredmanI am sure you meant utf8 there
16:20raekcan turn almost anything sequential into a seq
16:21raekhiredman: I didn't want to scare the mundanes... :-)
16:21raekbut yes. UTF-8 is the one and only.
16:22karmazillaCan protocols extend other interfaces? 'cause I'd like to define a protocol that is also clojure.lang.Indexed
16:22kevins_so seq is saying turn this string into.....an array or vector? (or I shouldn't really care)
16:23Chousukekevins_: neither; it becomes a sequence.
16:23Chousukekevins_: and the sequence is actually just a list-like view into the underlying string
16:24Chousukeso the string doesn't change (it can't anyway, it's immutable). You instead get a new thing, which is the sequence.
16:25Chousukeand you can do lots of things to sequences. first and rest are the basic operations, but lots of clojure functions work with sequences.
16:25Chousukeusually you don't need to call seq on anything directly though. (unless you're checking for emptiness).
16:26Chousuke-> (map str "foo")
16:26Chousukeah blah, sexpbot not here
16:26Chousuke,(map str "foo")
16:26clojurebot("f" "o" "o")
16:26Chousukeso, like that.
16:26iveywhere is sexpbot?
16:27kevins_the larger example I was playing with was (frequencies (map first words)))
16:27Chousuke,(apply str (reverse "foo")); or like that.
16:27clojurebot"oof"
16:27kevins_and I wanted to get all letters out of the words list...not just first.
16:29Chousukehmm
16:29Chousuke,(apply concat ["some" "words"])
16:29clojurebot(\s \o \m \e \w \o \r \d \s)
16:30Chousukeconcat concatenates sequences (what the strings automatically become) and apply is needed to concat a sequence of sequences.
16:31fhdHi. I'm using defprotocol to use the mock object pattern in test-driven development, because someone in this channel pointed me to that function earlier.
16:31kevins_this works, but it's not idiomatic? (frequencies (map seq words))
16:31fhdIt works fine, but I feel like I'm trying to do Java in Clojure here. It doesn't help that the examples usually use camel case for defprotocol and deftype.
16:32fhdWhat do you think? Should I avoid these functions?
16:32Chousukekevins_: are you sure you want that?
16:32Chousukekevins_: wouldn't that count the frequencies of the words?
16:33Chousukekevins_: and that should be pretty much the same as (frequencies words) anyway
16:36kuriouskatHi! I'm new to clojure and fp in general. I saw the look-and-say golf puzzle in stack overflow (ref: http://en.wikipedia.org/wiki/Look-and-say_sequence)
16:36kuriouskatI thought I shall try it out in Clojure.
16:36kuriouskatHere is my attempt thus far.
16:36kuriouskat(defn lazy-look-and-generate[] (iterate (fn[x] (mapcat (fn[n] (loop[x1 (first n) y (rest n) count 1] (if (= x1 (first y)) (recur x1 (rest y) (inc count)) (conj nil count x1)))) x)) [1])) (print (lazy-look-and-generate))
16:37kencauseykuriouskat: please use a paste site like paste.lisp.org
16:37kuriouskatsure sorry
16:39kuriouskathttp://paste.lisp.org/+2H22.
16:39kuriouskatI'm seeing a runtime exception. Any pointers on where I might be going wrong would be appreciated
16:55amalloy,(conj nil count [1 2 3])
16:55clojurebot([1 2 3] #<core$count clojure.core$count@bc5a71>)
16:55raekkuriouskat: a runtime exception often means that the delayed code of the lazy seq raised an exception
16:55amalloykuriouskat: ^^
16:55raekkuriouskat: try looking at the 'cause' of it
16:56amalloyyou probably want (count x1), not count x1
16:56raekcount is a loop variable in his code
16:56amalloyoh. blurgh, so it is
16:57raek,(conj [] 1 2)
16:57clojurebot[1 2]
16:57amalloy,(conj nil 1 2)
16:57clojurebot(2 1)
16:58raek(conj nil count x1) could also be written as (list x1 count)
16:59jkkramerkuriouskat: you might also consider researching clojure's core seq functions. loop is usually not the best first choice
16:59jkkramer,(take 6 (iterate #(mapcat (juxt count first) (partition-by identity %)) [1]))
16:59clojurebot([1] (1 1) (2 1) (1 2 1 1) (1 1 1 2 2 1) (3 1 2 2 1 1))
17:00jkkramernot quite right...
17:00amalloyjkkramer: it looks right to me
17:01jkkrameroh, right, it is. misread the wikipedia page when double-checking
17:01kuriouskatI converted (conj nil 1 2) to (list count x1)
17:01kuriouskatstill the same exception
17:01kuriouskat@jkkramer: it looks right to me
17:04raekkuriouskat: in your call (rest n), n have the value 1
17:05raekthe function given to mapcat gets applied for all values in [1], i.e. 1
17:06raekI would split up that function into two: one for the "step" and one for the repeated invokation
17:06raekthat way, it is much easer to test the step logic in the repl
17:10kuriouskat<raek> is there something like list-of-lists then?
17:11kuriouskatBy the way, all these are useful pointers. Thx @raek and @jkkramer
17:12raek[[1]] ?
17:12kuriouskatyeah
17:12kuriouskatthat should be it right. I'm testing it out
17:13kuriouskatno respise
17:28scottjant in clojure dir builds .jar in clojure dir but mvn install tries to install the jar in clojure/targets . am I missing something for installing custom clojure build in maven?
17:36jjidogiven a function f, can you tell its maximal arity?
17:36amalloyTeXnomancy, ninjudd: i'm spending like hours fighting to get ant/maven to cooperate with eclipse in an open-source java project i'm trying to extend. i've never appreciated lein/cake more
17:37amalloy,(:arglists (meta (#clojure.core/seq)))
17:37clojurebotNo dispatch macro for: c
17:38amalloy,(:arglists (meta #'clojure.core/seq))
17:38clojurebot([coll])
17:38amalloyjjido: you can use this if you have the var associated with the function. not sure if you can do it when you've been passed it
17:39jjidoamalloy: I will try
17:46TeXnomancyjjido: there's an example of inspecting the arglists in leiningen.core; leiningen uses the arglists to determine if a task is standalone or needs to run in the context of a project
17:47jjidoI realised that I can't tell the arity of functions with &
17:48TeXnomancy,Double/POSITIVE_INFINITY
17:48clojurebotInfinity
17:49TeXnomancythat doesn't roundtrip; somewhat lame.
17:51jjidolol
17:51jjidowhat is the equivalent of (contains?) for a list?
17:53jjidoI can use not-any? since I want to negate it
17:55jkkramer,(doc some)
17:56clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
18:04raekjjido: you could use 'some', but in many cases it makes more sense to do contains? on a set
18:05ohpauleezjjido: 'some' is the standard idiom for lists or vectors
18:05ohpauleez,(some #{3} [1 2 3 4 5])
18:05clojurebot3
18:05ohpauleez,(some #{7} [1 2 3 4 5])
18:05clojurebotnil
18:05jjido,(contains? '("a" "b" "c") "c")
18:05clojurebotfalse
18:06jjido,(not-any? #(= % "c") '("a" "b" "c"))
18:06clojurebotfalse
18:06jjido,(not-any? #(= % "d") '("a" "b" "c"))
18:06clojurebottrue
18:07raek,(contains? #{1 2 3} 1)
18:07clojurebottrue
18:07jjido,(contains? (set '("a" "b" "c")) "c")
18:07clojurebottrue
18:08raekchecking if something is in a set is a very fast operation
18:08jjido,(nil? (some #{7} [1 2 3 4 5]))
18:08clojurebottrue
18:10jjido,(source not-any)
18:10clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
18:40jjido,(-> (fn [a] (+ a a)) (fn [f] (f 1)))
18:40clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
18:40jjidommh :(
18:41MayDaniel,(macroexpand-1 '(-> (fn [a] (+ a a)) (fn [f] (f 1))))
18:41clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
18:42MayDanielWell it's putting the first function into (fn *here* [f]
18:46Derander,(macroexpand #'foo)
18:46clojurebotjava.lang.Exception: Unable to resolve var: foo in this context
18:46MayDaniel,(macroexpand '#'foo)
18:46clojurebot(var foo)
18:46Deranderyou show off you
18:46MayDanielHehe.
18:48amalloy~source not-any?
18:48amalloyjjido: ^^
18:50jjidoamalloy: nice (def not-any? (comp not some))
18:51jjidoMayDaniel: I see, thanks
18:52amalloyalso, you could fix your -> woes with an extra layer of parentheses
18:52amalloy(macroexpand '(-> (fn [] foo) ((fn [f] (f)))))
18:52amalloy,(macroexpand '(-> (fn [] foo) ((fn [f] (f)))))
18:52clojurebot((fn [f] (f)) (fn [] foo))
18:52jjidoamalloy: I just defined a function that does (-> f rest)
18:53jjido,(-> (fn [a] (+ a a)) ((fn [f] (f 1))))
18:53clojurebot2
18:54amalloythe extra parens are to cause -> to splice after the whole fdecl, not just the first element (fn)
18:56jjidocan I tell Clojure to take the standard input as a file (ie. not opening an interactive session)?
18:57jjidosource file
18:58amalloytry cake run?
18:59jjidoamalloy: what is cake? ;)
18:59ohpauleezjjido: there is a lein run too :)
18:59amalloyjjido: how do you get your repl?
18:59ohpauleezyou can also setup a ./scripts
18:59jjidoamalloy: clj
18:59amalloyjjido: clj < myfil.clj, then?
19:00amalloyohpauleez: maybe i haven't upgraded, but lein help doesn't list run as a task for me
19:00ohpauleezexternal plugin
19:00jjidook I can pass - as argument to take the standard input as source, but (use) does not work
19:02Deranderdoes anyone have an example of -> or ->> in use?
19:03DeranderI read the description in the API doc but I can't visualize it
19:04hiredmanhttp://gist.github.com/184831
19:04hiredmanfrom before ->> existed
19:04jjidoDerander: not the best example, but I use -> for eg:
19:04jjido(-> [1, 2, 3] count)
19:04jjido,(-> [1, 2, 3] count)
19:04clojurebot3
19:05jjidoon my own objects of course.
19:05Deranderright
19:07ohpauleezDerander: typically you choose to use the threading macro if it simplifies readability only
19:07ohpauleezoften times you see it used when doing interop stuff
19:07amalloy,(->> (range) (filter even?) (drop 100) (map dec) (take 10))
19:07clojurebot(199 201 203 205 207 209 211 213 215 217)
19:07amalloyDerander: does the above make any sense?
19:07Deranderamalloy: reading
19:08amalloy,(clojure.walk/macroexpand-all '(->> (range) (filter even?) (drop 100) (map dec) (take 10)))
19:08clojurebotjava.lang.ClassNotFoundException: clojure.walk
19:09hiredman,(-> (+ x x) (->> (fn [x]) (update-in {:a 0} [:a])))
19:09clojurebot{:a 0}
19:09hiredman,(-> (+ x x) (->> (fn [x]) (update-in {:a 2} [:a])))
19:09clojurebot{:a 4}
19:09Deranderamalloy: I believe I understand
19:09Deranderchecking the documentation for "dec" though. never seen that one
19:09jjidodecrement
19:09Deranderah
19:10amalloyDerander: and if you want the source for anything you can always ask clojurebot
19:10Deranderright
19:10jjidoI solved my (use) issue, I needed to add . to the classpath
19:10DeranderI don't have emacs on this machine setup for clojure dev like I do on my desktop
19:10Deranderotherwise I'd just etags over to it :-/
19:24bmhWhat are the best practices for using Java libraries from clojure? Run everything through the interop or write a nice, tasty functional wrapper?
19:26freakazoidbmh: if you are making extensive use of the library you should wrap it
19:26freakazoidyou don't want your clojure code to start looking like java :)
19:27freakazoidthere are a number of wrappers for java libraries out there you could look at
19:27bmhThat is a very good point. OK. Next question: I'm trying to pull a java library into my project. I've got the source yanked in and I've compiled it with lein-javac
19:28bmhWhen I try to :use it, the universe explodes with a "could not locate kylm__init.class" error
19:28freakazoidA really simple one being http://richhickey.github.com/clojure-contrib/server-socket-api.html which wraps java sockets, though it only exposes a small part of the interface
19:28bmhthat's quite nice
19:28freakazoidis the jar file or class file in your classpath?
19:28dnolenbmh: you don't :use Java libraries, you :import the classes from that library
19:28freakazoidoh, java, right.
19:30bmhdnolen: Thanks
19:30jjido~ delay
19:30clojurebotExcuse me?
19:30jjido~delay
19:30clojurebotPardon?
19:31jjidotsk tsk
19:31jjido~get-me-a-beer
19:31clojurebotexcusez-moi
19:33bmhthanks freakazoid and dnolen. I'll wrap this lib up tomorrow.
19:34freakazoidno problemo
19:37nex_why does:
19:37nex_(def ops '(+ /))
19:37nex_(map #(% 5 5) ops)
19:38nex_return (5 5) while i would expect (10 0)
19:39nex_(or: is it possible to map on a list of functions?)
19:42amalloy,(map #(% 5 5) [+ /])
19:42clojurebot(10 1)
19:43amalloynex_: it's the '(blah) that's tripping you up: it quotes + and / so that they're just symbols, instead of refs to the function you want to call
19:43freakazoidOH
19:43amalloyto make a literal list of things, usually vectors [a b c etc] are the way to go
19:44freakazoidgeez, I'd been wondering what the difference was between '(…) and (list ...)
19:44freakazoidit's obvious in retrospect, but then again so are most things
19:44amalloy,(let [a 10] [[a 1] '(a 1) (list a 1) `(a 1)])
19:44clojurebot[[10 1] (a 1) (10 1) (sandbox/a 1)]
19:45nex_amalloy: thanks, im repling it
19:47freakazoidsyntax quotes rock
19:47nex_:) whoa fantastic
19:47freakazoidthe more I learn about clojure the more I realize how well thought out it is
19:48Dawgmatixit builds upon lisp :)
19:48freakazoidI don't know that i would say that
19:48freakazoidCL, at least, needed a bunch of stuff ripped out.
19:48Dawgmatixi meant conceptually
19:48freakazoidSo it builds upon lisp in the same way that people "add on" to their house in California
19:49freakazoidthey tear down all but one wall and then completely rebuild everything else.
19:49freakazoidTo keep the same property tax base.
19:49Dawgmatixi wasnt aware of this hack
19:50freakazoidFew people outside CA are, because it's ridiculous, because property tax law in CA is ridiculous.
19:50freakazoidIt's a blatant subsidy for the rich.
19:50Dawgmatix:)
19:51Dawgmatixin cali every section feels another section is getting blatant subsidies
19:51Dawgmatix:D
19:51freakazoidI suppose you could say that.
19:51freakazoidBut government is pretty much always coopted by the powerful.
19:52Dawgmatixi think were headed interesting offtopic territory
19:52freakazoidIndeed.
19:53freakazoidThe offtopic conversation always seems so much better in the channels of the better languages
19:53replaca_chouser: you around?
19:53freakazoid#erlang and #clojure, vs say #ruby and #python
19:53Dawgmatix#python is in fact a great channel, though yes it stays strongly ontopic
19:54Dawgmatix#clojure is great too, chouser is always ready with answers
19:54freakazoidactually I was only guessing. I don't hang out on #python or #ruby.
19:55freakazoidbeing more mainstream, I would just guess they have a larger fraction of dumb people
19:55freakazoidthough at least it's IRC, which many Ruby users probably can't figure out how to get into.
19:55Dawgmatixcome on!
19:55freakazoidheh, maybe I'm mixing it up with #php
19:56freakazoidRuby has a lot of smart people using it, but a lot of people who can't do any more than cut and paste.
20:03amalloyfreakazoid: what the clojure community needs is more CL-like elitism...
20:04freakazoidFine, fine
20:04freakazoidThough actually I'm perfectly happy to use Ruby or Python where they make sense
20:04freakazoidpretty much language agnostic except for languages that make it hard to write good code
20:06kmci feel really dumb, but i can't find (by google etc.) a simple way to compute exponentials, i.e. a^b in Clojure
20:06kmcis there no built-in operator for this?
20:06freakazoidMath/pow
20:07amalloykmc: i was doing this just the other night. clojure.math/expt
20:07amalloy(math.pow uses doubles, so won't work for bigints)
20:07freakazoidOhh
20:07amalloy,clojure.math/expt
20:07clojurebotjava.lang.ClassNotFoundException: clojure.math
20:07freakazoidclojure.contrib.math?
20:07clojurebotclojure > scheme
20:08amalloyno, he just doesn't have the other packages loaded
20:08amalloyit works in a real repl
20:08freakazoidoh, ok
20:08kmci'm an absolute noob, just started... do i need to import a package somehow?
20:08kmcah cool (Math/pow 2 3) works
20:08amalloykmc: (use 'clojure.math)
20:08amalloyif you need precision; math/pow converts to floating-point
20:08kmcok looks like i've got to set up my classpath etc
20:08amalloy,(Math/pow 2 100)
20:08clojurebot1.2676506002282294E30
20:09amalloykmc: let me strongly recommend using either lein or cake. they manageall this classpath nonsense for you
20:11freakazoidcake is written in ruby? interesting choice
20:11plathropkmc: +1 to what amalloy just said. With lein, clojure doesn't feel like java.
20:11amalloyclojurebot: lein?
20:11clojurebotthe leiningen screencast is on full disclojure: http://vimeo.com/8934942
20:11amalloyclojurebot: cake?
20:11clojurebotcheesecake is delicious.
20:11lancepantzfreakazoid: just the client script
20:11freakazoidoh, ok.
20:11lancepantzthe same part of lein that is written in bash
20:12freakazoidI guess these days ruby is almost as likely to be installed as bash
20:12amalloyclojurebot: cake is http://github.com/ninjudd/cake
20:12clojurebotc'est bon!
20:12lancepantzit's nice, it was a good decision, gives us windows compatibility without cygwin
20:13freakazoidoh right windows
20:13freakazoidI keep forgetting that exists
20:14freakazoidnot really but most of the time to me there are two platforms: mac and linux
20:14freakazoidit's from being molested by Windows as a child.
20:16amalloyanyway kmc i hope that wasn't all too overwhelming. let us know if you need help setting up a build tool
20:17kmcthanks a lot
20:17kmc"doesn't feel like java" is an attractive proposition
20:17kmci'm managing with the REPL right now
20:18kmcbtw does Clojure have a recursive "let" construct?
20:18amalloykmc: recursive how? the answer is surely yes, i just don't understand the question
20:18freakazoidlet* I'm guessing?
20:18kmci tried let*
20:18kmcthough it's possible i was doing something dumb
20:19amalloykmc: let in clojure acts like let* in CL
20:19amalloy,(let [x 1 a (inc x)] a)
20:19clojurebot2
20:19freakazoidoh hmm maybe I was thinking of racket
20:19amalloyfreakazoid: clojure has a let*, it's just not public. rich uses it to bootstrap
20:20amalloy,(macroexpand '(let [x 1] x))
20:20clojurebot(let* [x 1] x)
20:20freakazoidI thought I'd seen it somewhere.
20:20amalloy,(macroexpand '(let [x 1 y 2] x))
20:20clojurebot(let* [x 1 y 2] x)
20:20kmc,(let [f #(cond (= % 0) 1 :else (* % (f (- % 1))))] (f 5))
20:20hiredmanit is public
20:20clojurebotjava.lang.Exception: Unable to resolve symbol: f in this context
20:20hiredmanlet* is a special form in fact
20:21hiredmankmc: you want letfn
20:21amalloyhiredman: or recur
20:21hiredmanfor creating local recursive functions
20:21hiredmanamalloy: recur won't work there
20:21kmc,(letfn [f [n] (cond (= n 0) 1 :else (* n (f (- n 1))))] (f 5))
20:21clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
20:21amalloybut then you'd have to make it tail-recursive i guess
20:21hiredmankmc: you'll need to read the docs for letfn
20:21kmcok
20:22kmcletfn doesn't do TCO?
20:22amalloyTCO isn't automatic in clojure, and your function isn't tail-recursive
20:22kmcyeah this one isn't
20:22kmcmy real situation is
20:22amalloy,(letfn [(f [n] (cond (= n 0) 1 :else (* n (f (- n 1)))))] (f 5))
20:22clojurebot120
20:23kmcthanks!
20:23hiredmanif it is self recursive you can use recur if it is not you can use trampoline
20:27kmcso i use it with 'loop'?
20:27amalloykmc: or with functions. it recurs to either
20:28amalloyhiredman: since i've got you here, i haven't totally grokked the Github Way. i tried to submit a pull request for clojurebot; did i succeed?
20:29hiredmanyes
20:29amalloy,(loop [n 10 res []] (if (zero? n) res (recur (dec n (conj res n))))
20:29clojurebotEOF while reading
20:29amalloy,(loop [n 10 res []] (if (zero? n) res (recur (dec n (conj res n)))))
20:29clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$dec
20:29amalloybah
20:29amalloy,(loop [n 10 res []] (if (zero? n) res (recur (dec n) (conj res n))))
20:29clojurebot[10 9 8 7 6 5 4 3 2 1]
20:33amalloysay i have some code that requires a Foo object, but i keep forgetting and passing it Bar objects, and i waste a lot of time tracing the call stack to see where i messed up. is this the sort of thing that function preconditions are supposed to solve?
20:35kmcwow i ran just 'cake' and it went nuts on my hard drive
20:35kmcfeels like it tried to tar up my entire filesystem or somethingkillall java
20:35amalloyi think it downloads dependencies the first time you run it?
20:35lancepantzyep
20:35lancepantzmaven has an ass-ton
20:36lancepantzthere is a branch that uses ivy that's much more palatable, but it's still in progress
20:36kmcheh
20:36kmcok, so cake makes my system unusable. guess it's lein then
20:36amalloykmc: lein uses maven too
20:37lancepantzyeah, well you're installing something on your hard drive, ofcourse its going to spin up :)
20:37amalloybut this frenzied download should be a one-time thing, and i don't think it takes *that* much space, does it?
20:37lancepantzlike 10 megs i think
20:37amalloyhm. my ~/.m2 has 116MB in it
20:38lancepantzkmc: how did it make your system unusable?
20:38amalloybut cake only has 12MB, as you say, lance
20:41kmci don't know what it was doing but it pretty much killed my ability to use the system interactively
20:41kmcin way that bulk file transfers don't
20:42amalloymaybe build cake with --no-destroy-host-system :)
21:06freakazoidwoo, penumbra looks pretty neat
21:15kmclein takes about three seconds to start up and do anything
21:15kmcand 'lein repl' takes longer
21:15kmcis there a way i can reload my code inside the repl?
21:15coldheadcherish these moments
21:16hiredmanlein repl is not the recommended why to use lein
21:16hiredmanlein swank or whatever the equiv is for vimclojure
21:17hiredmanyou can reload your code using the provided features from your editor
21:19kmcok, there's not a good standalone repl?
21:21hiredmankmc: clojure.main
21:21kmcsuppose i'm representing coordinates within an image and i want to iterate from [0,0] to [w,h] in left-to-right, top-to-bottom order
21:21kmcwhat's the idiomatic clojure way to do this?
21:21hiredmanfor
21:21hiredman,(doc for)
21:21clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
21:22hiredman,(for [h (range 5) w (range 5)] [w h])
21:22clojurebot([0 0] [1 0] [2 0] [3 0] [4 0] [0 1] [1 1] [2 1] [3 1] [4 1] [0 2] [1 2] [2 2] [3 2] [4 2] [0 3] [1 3] [2 3] [3 3] [4 3] [0 4] [1 4] [2 4] [3 4] [4 4])
21:24dnolenkmc: cake is pretty good, IMO, but it sounds like it didn't work out for you.
21:24dnolenlein is pretty good too, now that you can hook into a running REPL via telnet
21:25kmcthanks hiredman
21:51scottjif I have [f1 f2] and [v1 v2] how do I get [(f1 v1) (f2 v2)] w/o writing that out?
21:59bhenry,(vector (map list [:f1 :f2] [:v1 :v2]))
21:59clojurebot[((:f1 :v1) (:f2 :v2))]
21:59bhenrynope.
22:00bhenry,(doc vec)
22:00clojurebot"([coll]); Creates a new vector containing the contents of coll."
22:00bhenry,(vec (map list [:f1 :f2] [:v1 :v2]))
22:00clojurebot[(:f1 :v1) (:f2 :v2)]
22:01bhenryscottj: something like that maybe? this is usually where someone else provides a better solution
22:01scottjbhenry: :) actually f's are functions
22:01scottj,(map list [inc dec] [1 1])
22:01clojurebot((#<core$inc clojure.core$inc@b9c46a> 1) (#<core$dec clojure.core$dec@58e72c> 1))
22:01bhenryooh
22:02jk_bobo_: the tests that come out of TDD are very useful just for testing when it comes to regression testing though
22:02jk_bobo_: not just a design thing
22:03chouser,(map #(%1 %2) [inc dec] [5 10])
22:03clojurebot(6 9)
22:04bhenrydamn chouser i just got that same thing, (map #(%1 %2) [inc dec] [1 1])
22:05scottjchouser: so there's no name for that?
22:05hiredmanit's almost apply
22:05hiredman(map apply [inc dec] [[1] [1]])
22:06hiredman,(map apply [inc dec] [[1] [1]])
22:06clojurebot(2 0)
22:39scottjI read news.arc (hacker news source)last night, pretty interesting. the entire website is in one file. Arc has this shorter member lookup syntax so instead of (host :ip) you just do host:ip. I implemented it in LispReader.java in a few lines. normally destructuring is better but if you have three objects with the same key name then I think (foo host:ip proxy:ip client:ip) would be nice. unfortunately it doesn't if the hash isn't already bound to a local, at
22:45dpritchettthe clojureCLR update on the mailing list is pretty exciting
22:46dpritchetti fired it up and tried a load-file and couldn't make it work though :(
23:05kmci have a sequence named 'points' defined with 'for'
23:05kmcand a function 'out-pt' which has some side effect
23:05kmc(doseq [pt points] (out-pt pt) ; will perform all the effects
23:05kmc(map out-pt points) ; will not
23:06kmcand i'm not sure why
23:06hiredmanread the docs for map and for doseq
23:06hiredmanI highly suggest you read docs
23:07kmci have been, but i'll take another look
23:08kmcah so the problem is that map returns a lazy sequence
23:09TeXnomancyclojurebot: map?
23:09clojurebotmap is lazy
23:10kmcso is there something i can use with the syntax of map, which will perform effects right away?
23:10TeXnomancya classic
23:10scottjsee dorun and doall
23:11kmcthanks
23:12amalloykmc: also doseq
23:13amalloyoh, i see you already found out about doseq. that's what i get for contributing before reading all the logs
23:51kmci'm mapping over a bunch (60,000) of independent computations
23:51kmci replaced map with pmap and it runs slower
23:51kmcfrom reading some discussion online, it sounds like this is common, but it's not clear what the solution is
23:51hiredmanhave you read the doc string for pmap?
23:52kmcyes
23:52hiredmanand you saw the last part?
23:52kmcyes
23:52kmcbut it's a vague qualitative statement; i don't know what the coordination overhead is
23:53kmclet me put it this way, my 60,000 computations take 20 seconds sequentially
23:53jkkramerkmc: a common strategy is to partition a collection into batches before parallel processing
23:53kmcwhich means each one takes 1/3 millisecond
23:53kmcwhich seems pretty big to me
23:53hiredmandoesn't sound computationally intensive
23:54kmceh like i said, the doc string gives no quantitative guideline
23:54kmcjkkramer, sounds good, is there a standard way to do this or shall i roll my own?
23:55jkkramerkmc: not sure if anyone's abstracted it out into a lib, but there are snippets out there
23:55kmcok
23:56jkkramerusually involving a combination of partition-all, pmap/futures, reduce, etc
23:56kmclooks not too bad
23:59jkkramerkmc: here's a rudimentary example: http://gist.github.com/517696