#clojure log - Jul 25 2010

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

0:19 Bahman: Hi all!

0:59 rdsr: while constructing an uberjar with lein, why does lein do a cleanup first, could this also be the reason why my uberjar does contain any of my dependencies

0:59 s/does/doesn't/

0:59 sexpbot: while constructing an uberjar with lein, why doesn't lein do a cleanup first, could this also be the reason why my uberjar doesn't contain any of my dependencies

1:01 rdsr: crap, substitution fail

1:01 well the first one is "does" and the next one is "doesn't"

1:03 technomancy: it does a cleanup followed by a compile, which will force deps to be fetched

1:04 I mean, it should

1:11 rdsr: in my case my standalone jar just contains my files

1:12 technomancy: rdsr: does an explicit call to deps before calling uberjar fix it?

1:12 rdsr: anyway, if you have a simple repro case please create an issue

1:13 rdsr: nope, I tried that

1:13 ok I will do that, thanks

1:26 rubydiamond: hi guys..

1:26 clj script/run.clj

1:26 Exception in thread "main" java.io.FileNotFoundException: Could not locate ring/adapter/jetty__init.class or ring/adapter/jetty.clj on classpath: (run.clj:0)

1:26 at clojure.lang.Compiler.eval(Compiler.java:4658)

1:26 I am going thru this http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

1:28 seancron: Hi everyone. Does anyone know how can I do (while swing-window-is-open ...) in clojure?

1:29 rdsr: rubydiamond: ring.jetty.adaptor should be on your classpath

1:29 rubydiamond: rdsr: but that tutorial is not mentioning it..

1:29 rdsr: is there any other command I should try.. may be lein specific

1:29 rdsr: I see that the tutorial is using lein

1:30 technomancy: rubydiamond: everyone has their own definition of the "clj" script. it appears yours differs from the one used by the author of the tutorial

1:30 rdsr: is clj your custom script

1:30 rubydiamond: rdsr: nope.. I have installed clojure..

1:30 it's coming with it

1:30 technomancy: I have installed it with homebrew

1:31 technomancy: rubydiamond: clojure doesn't come with a shell script

1:31 seancron: rubydiamond: check the version of clojure and clojure-contrib in your project.clj file. Is it 1.2.0-beta1?

1:31 rubydiamond: technomancy: there are 18 jars in lib folder and i don't want to manually set classpath for each .. will lein help me to run it

1:32 technomancy: though whoever repackaged it for homebrew may have added one

1:32 sure

1:32 but the project has to be set up for it. the lein-run plugin might help though

1:35 rubydiamond: is installing the lein-run plugin

1:36 technomancy: it helped ... but another error looks like in tutorial

1:36 lein run script/run.clj

1:36 [null] Exception in thread "main" java.lang.Exception: Unable to resolve symbol: a in this context (core.clj:17)

1:37 https://gist.github.com/fc22629ac2fb6f30e144 here is code

1:37 I don't see any symbol 'a' there

1:40 seancron: rubydiamond: Try cloning the example from the tutorial and see if you can get that working http://github.com/mmcgrana/adder

1:43 rubydiamond: seancorfield: ok

1:43 _seancron: ok

1:48 _seancron: that cloned rep worked... so looks like a bug in tutorial..

1:48 :)

2:11 seancron: rubydiamond: Glad to hear that it worked for you

2:11 rubydiamond: seancron: clone worked .. but if you follow tutorial till clj run script.. it doesn't work

2:19 https://gist.github.com/9462c30f0b86bed809d8 technomancy get this error for lein repl

2:19 seancron: if you know more

2:27 seancron: rubydiamond: Maybe take a look at the clj script that was linked to at the beginning of the tutorial? http://mmcgrana.github.com/2010/03/clojure-setup.html

2:28 rubydiamond: I'm going to bed though. Good luck.

2:34 rubydiamond: seancron_: thanks

2:48 Derander: rubydiamond: how did you install lein-run?

2:49 rubydiamond: Derander: adding dependency for it

2:49 Derander: I did that, but "lein run" in the project root says undefined task lein, after I've run lein deps and it appeared to have installed

2:56 rubydiamond: Derander: let me help you

2:57 Derander: add "[lein-run "1.0.0-SNAPSHOT"]" in your project.clj as dependency..

2:57 Derander: done

3:01 slyrus_: surely an equivalent to this is built in somewhere: (defn position [coll x] (some (fn [[a b]] (when (= b x) a)) (indexed coll)))

3:03 Derander: rubydiamond: I am failing at the next step. lein reports that it has installed the dependency. lein run does not work, however.

3:05 Chousuke: slyrus_: maybe in contrib, but not in core.

3:13 slyrus_: yay: (map clojure.pprint/pprint (map #(vector % (graph-distance-matrix %)) (connected-components q10))) works. now i can go to bed.

3:16 rubydiamond: Derander: hmm

3:16 is it the same proj

3:16 Derander: rubydiamond: I got it figured out -- had to add it as a dev-dependency

3:16 for some reason

3:16 I am not certain what the difference between the two is, but it worked

3:16 rubydiamond: Derander: hmm.. ok

4:28 guys.. if I run a clojure factorial program for number 100

4:28 does it mean .. it's using mutiple cores while processing it

4:37 gregh: I suppose that depends on how you've written your program

4:52 rubydiamond: gregh: okay..

4:52 also I am getting error while loading compojure from command line

4:52 http://yfrog.com/f/jy2dvp/

4:54 anybody there

5:00 Chousuke: Is your classpath properly configured?

5:00 also unless you're using an old version of compojure, you'll need to require compojure.core instead

5:00 the namespace was renamed because single-segment namespaces cause problems.

5:12 rubydiamond: Chousuke: hmm

5:13 Chousuke: I am running lein swank

5:13 and I have compojure and clojureql as deps in it

5:14 Chousuke: somehow (use 'compojure.core) worked

5:15 but not able to use clojureql

5:15 (use 'clojureql)

5:15 bpsm: i've added patches for clojure #413, #410, #408, #277 if anyone's awake an bored and wants to look at them.

5:16 rubydiamond: bpsm: okay.. I hope.. I can learn clojure fast and I understand your patches so that I can take a look at them

5:16 bpsm: hey.. (use 'clojureql) not working for me

5:17 bpsm: not working, in what sense? exception?

5:17 rubydiamond: not working, in what sense? exception?

5:18 rubydiamond: bpsm: I have added it in project.clj as deps [org.clojars.snuxoll/clojureql "1.0.0"]

5:18 using lein

5:18 now trying to use those using REPL .. swank clojure

5:18 (use 'compojure.core)

5:18 Chousuke: rubydiamond: probably the namespace is wrong again

5:18 rubydiamond: that worked..

5:18 Chousuke: right

5:18 rubydiamond: but not clojureql

5:19 Chousuke: how do I know what to use

5:19 Chousuke: rubydiamond: you read the documentation for the library to see what namespaces there are

5:19 libraryname.core is a common convention (because clojure uses it)

5:19 rubydiamond: Chousuke: hmm

5:19 Chousuke: for the main namespace, that is

5:19 rubydiamond: Chousuke: .core seems to be not working

5:19 Chousuke: there are often others too.

5:22 rubydiamond: the namespace is dk.bestinclass.clojureql

5:22 rubydiamond: http://gitorious.org/clojureql/pages/Home#Documentation

5:22 rubydiamond: hmm?

5:22 let me try that

5:22 oh yeah .. it worked..

5:22 Chousuke: rubydiamond: clojure libraries contain namespaces, and you load those with use or require (prefer require; use pollutes your namespace)

5:23 so to start using a library you need to figure out what namespace you want to load.

5:23 rubydiamond: Chousuke: hmm

5:23 Chousuke: thanks very much.. trying out http://vimeo.com/8356990

5:24 Chousuke: hmm

5:24 that video is probably outdated

5:24 rubydiamond: Chousuke: yeah

5:24 Chousuke: so don't be too confused if some more things don't work :)

5:24 rubydiamond: btw do you know where lein copies jars

5:24 Chousuke: right

5:24 Chousuke: in the maven repo

5:25 ~/.m2 on unixoids :P

5:25 clojurebot: It's greek to me.

5:26 rubydiamond: Chousuke: looks like now I am stuck at open-global

5:26 open-global is not available for my clojure

5:27 Chousuke: it's probably a compojure or clojureql function

5:27 that has been either renamed or moved to some other namespace

5:27 rubydiamond: Chousuke: :(

5:28 Chousuke: rubydiamond: here's a more uptodate compojure tutorial http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

5:29 no emacs though, but the tutorial uses lein too so you can just use lein swank

5:29 rubydiamond: Chousuke: yeah I have tried that today morning..

6:41 isn't it wrong http://sicpinclojure.com/?q=print/book/export/html/16

6:41 define is not defined in clojure..

6:42 fyuryu: rubydiamond: yes, seems like a mistake

6:43 rubydiamond: fyuryu: right..

6:52 Nikelandjelo: rubydiamond: Isn't it about scheme?

6:53 rubydiamond: Nikelandjelo: it's sicp in clojure

6:53 so the syntax should be in clojure.. as I undestand

6:55 Nikelandjelo: rubydiamond: Actually I don't see any example of clojure syntax in this site. Weird...

6:56 fyuryu: rubydiamond: http://sicpinclojure.com/?q=sicp/1-1-2-naming-and-environment#comment-12

6:56 * Raynes smiles at the amusing use of the word "syntax". :)

6:56 rubydiamond: lol

6:57 fyuryu: seems like a work in progress

7:02 Raynes: It's definitely a work in progress.

7:02 I'm not sure how much *progress* is actually being made though.

7:02 Everything looks the same as it did about a year ago.

7:03 rubydiamond: hope I can contribute to it in future

7:03 I have recently started reading SCIP a

7:03 nd learnig clojure too

7:38 Raynes: chouser: ping

10:02 jli: hm, strange. I'm using a fixed thread pool executor to handle all my tasks, which all just commutatively add stuff to a set. but it seems like I only see actual concurrency when I have (println @ref) in my task function

10:02 (cpu% goes over 100%, I see stuff printed at the same time)

10:03 when I remove the println, I see everything printed all at once (my "getting future" and "thread pool shutting down" messages), and the code is capped at 100%

10:03 the answer is still correct, but not sure what's gong on

10:04 going

10:05 Raynes: The fact that there isn't a Clojure openid library yet makes a happy Raynes a sad Raynes.

10:10 raek: </3

10:10 I would want one too

10:11 Raynes: raek: If I can grok the spec, I'm considering writing one.

10:12 raek: The Java openID libraries make my eyes bleed.

10:15 raek: OpenId4Java?

10:15 Raynes: raek: I don't read Java very well.

10:15 raek: it woulde be nice to build the clojure library on another working library

10:15 Raynes: I don't think I'd be able to do that.

10:17 raek: AFAIK, there are two versions of OpenID in use

10:18 Raynes: http://code.google.com/p/openid4java/wiki/SampleConsumer

10:18 raek: maybe I'l check out OpenId4Java later this evening

10:19 Raynes: I'm not familiar with this httpservlet nonsense.

10:19 raek: that example shouldn't be too hard to port to clojure

10:19 maybe we could use some of clojure

10:19 's web frameworks for that

10:20 Raynes: Good luck with that.

10:20 raek: ring (and thus compojure) is servlet-based

10:20 I'll invsetigate it it's worth the effort

10:20 jli: okay, I think it's because I'm concat'ing onto my result ref, and concat is lazy

10:20 does that make any sense?

10:22 raek: well, lazy sequences (concat is one of them) and side-effects doesn't play very well together

10:23 what do you mean with "concat

10:23 'ing onty my result ref"

10:23 onto the contents of the ref??

10:23 * raek can't type today

10:24 jli: I have my reference to a set. I have a thread pool. the tasks that I run generate collections. I want to collect all the collections, so I concat each one to the set in a dosync

10:24 maybe I should be using pcalls, or something?

10:24 oh, I should use doseq to force it, right?

10:25 dnolen_: jli: doall

10:25 raek: doall forces a lazy sequence

10:25 doseq is just (dorun (for ...))

10:26 jli: nice! that was it. thanks dnolen_, raek.

10:28 dnolen_: jli: concat will convert your PersistentHashSet into a LazySequence

10:28 ,(reduce conj #{} [1 2 3 4])

10:28 clojurebot: #{1 2 3 4}

10:29 Raynes: -> (into #{} [1 2 3 4])

10:29 sexpbot: => #{1 2 3 4}

10:32 dnolen_: Raynes: yeah into is better

10:33 jli: (into current-ref new-data), yay

10:51 otfrom: Is anyone about who is familiar with pallet?

11:15 slyrus_: is there a built-in function to convert a java 2d array to a vector of vectors?

11:16 (vec (map vec (vec ...))) ?

12:38 notsonerdysunny: is adding an additional argument the only way to simulate return-type polymorphism ... or is there a better way?

12:41 raek: the polymorphism mechanisms provided by clojure only does dispatch based on the arguments

12:42 notsonerdysunny: yea I know .. that is why I said "simulate return-type polymorphism" .. :) .. but I see what you are saying ..

12:42 raek: notsonerdysunny: you want to dispatch differently based on what type the function is expected to return?

12:43 notsonerdysunny: raek: yes

12:43 raek: I guess the called would need tell the function what it want it to return

12:43 daaku: i'm a defmacro n00b, and can't quite get why this doesn't work: http://gist.github.com/489676 or how to debug what the hell is going on :) -- it's a 2 line macro which involves calling another macro

12:43 notsonerdysunny: so the function would be lazy .. probably created by application of partial

12:44 raek: daaku: have you tried using macroexpand-1 ?

12:44 you can use that to see what the macro expands to

12:44 lozh: You've missed the ` off the start of the macro form I think

12:44 raek: ,(macroexpand-1 '(and a b))

12:44 clojurebot: (clojure.core/let [and__3464__auto__ a] (if and__3464__auto__ (clojure.core/and b) and__3464__auto__))

12:45 daaku: cool, let me try those things

12:45 raek: the asgument you pass to it should be the code, and since macroexpand-1 is a function it needs to be quoted so that it isn't evaluated by clojure first

12:45 clojurebot: clojure-stub is http://github.com/nakkaya/clojure-stub/tree/master

12:47 raek: daaku: it often helps if you write a sample input and the the code you want that to become

12:47 in the simple cases, it's often just a matter of putting everything in a syntax-quote (`) and putting unquotes at the right places

12:48 also, you should not (except under special circumstances) need to resort to ~'

12:50 daaku: raek: cool, thanks for the info -- i've been trying different things to see how it plays

12:50 i added sample input and output as you suggested: http://gist.github.com/489676

12:50 i think what makes this trickier is that inside the macro i'm using another macro

12:51 raek: macros are simply functions from code to code

12:51 daaku: the (select ...) is a macro

12:51 raek: if the macro expansion contains a macro, that will be expanded when the compiler gets to it

12:51 but that's after you macro is done with the code

12:53 daaku: does the compiler to macroexpand or just the first level? i think what i'm running into is that i want the compiler to not expand the (select ..) macro at load time, but don't quite have that figured out

12:53 raek: that would be (defmacro entity-exists [kind conditions] `(= 1 (count (:result (select-batch (where ~kind (~conditions)) 1)))))

12:54 if the compiler sees a macro, it does the expansion

12:54 daaku: raek: nice. that works

12:54 raek: now to understand why :)

12:54 raek: then, it continues with the new code

12:54 just like if you had typed that instead

12:55 daaku: it's like a really smart s/macro-call/expanded/ before the compilation

12:55 or as part of the compilation rather?

12:56 raek: it's done somewher in the "compler parts" of clojure... that all i know. :)

12:58 also, ` is just a convenience feature so one does not have to make tons of nested (list ...) calls to build the new code

12:58 the code outside the syntax quote is executed during expand-time

12:59 daaku: raek: yeah, that was what i didn't get

12:59 i thought everything inside a defmacro is part of expand-time

12:59 but now that seems obviously limiting :) so it all kinda makes more sense

13:02 tommg: Hi! I'm just starting to learn Clojure and I came across a tutorial that uses leiningen - I'm using snow leopard and have this installed but whenever I use the command: lein deps I always get errors saying it cannot satisfy dependencies. It looks like its downloading what it needs then errors with '7 artifacts are missing' error - is this the best place to ask?

13:03 raek: here and in #leiningen is fine, I think

13:04 ihodes: try running lein clean; lein deps

13:04 and make sure you're not behind something like WebSense (or another firewall) that could stop access to Clojars.org.

13:04 raek: I don't have much advice, but if everything else fails, try removing the local repository

13:04 ~/.m2 in unix

13:05 ihodes: truth, you can rm ~/.m2 and try again

13:05 clojurebot: it's a UNIX system! I know this!

13:05 tommg: thanks, ill try again with it - it just seems like it failing to download from the repo's but it doesn't mention this - although I have checked the sites and the paths do exist

13:05 hiredman: also likely you have the wrong names/versions of artifacts so of course those artifacts cannot be found

13:07 tommg: ahah!

13:07 removed my local repo and its working now

13:07 thanks! simple

13:08 ihodes: great! lein is a great tool. learn to love it ^^. i'd also check out cljr (http://github.com/liebke/cljr) for jus ttestign out ideas you have with a quick repl

13:18 does anyone have any suggestions for a Java or Clojure lib that can handle drawing a hundred thousand point xy-plot in under 30 seconds? Incanter isn't able to on my c2duo

13:19 (which uses JFreeChart)

13:29 notsonerdysunny: given a function can I find out how arguments it needs in a programmatic way ... ( i know slime does ... this ..) but otherwise ..is it possible?

13:31 rhudson: ,(:arglists (meta #'reduce))

13:31 clojurebot: nil

13:31 rhudson: hmm, that worked in my repl

13:32 ihodes: *clojure-version*

13:32 ,*clojure-version*

13:32 clojurebot: {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}

13:33 ihodes: ,(meta #'reduce)

13:33 clojurebot: {:ns #<Namespace clojure.core>, :name reduce, :file "clojure/core.clj", :line 773}

13:33 ihodes: odd...

13:33 doesn't have as much here...

13:33 works in my repl as well.

13:34 rhudson: -> (:arglists (meta #'reduce))

13:34 sexpbot: => ([f coll] [f val coll])

13:35 rhudson: -> (clojure-version)

13:35 sexpbot: => "1.2.0-beta1"

13:36 tomoj: but it doesn't really work

13:36 (:arglists (meta #'apply)) gives ([f args* argseq]) for instance

13:36 hiredman: and only works on vars

13:37 rhudson: But it's all that's available at runtime, unless there's some IFn method that can cough up info

13:38 raek: hrm, I'm looking for a blog which recently compared the "craft of coding" to being a cook

13:38 anyone seen that?

13:38 notsonerdysunny: thanks rhudson ..

13:39 raek: ,(:arglists (meta #'map))

13:39 clojurebot: ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])

13:39 raek: reduce is a protocol method now

13:39 rhudson: ?

13:39 raek: those should also set the arglists metadata, imho

13:40 but apparently, the doesn't now

13:40 daaku: anyone using compojure? i'm wondering how i'm supposed to get the ring request object (need to access cookies)

13:40 hiredman: rhudson: fns are just objects, so you can do various reflection things to them

13:40 rhudson: right

13:40 raek: daaku: the request map is what is handed to your handler

13:42 ok, I take it back: reduce is not a procol method (internal-reduce is)

13:42 daaku: raek: isn't that for a ring handler? my compojure handlers (the ones setup using defroutes) seem to get url/form/query params

13:42 raek: the old 0.3 versions binds the request map to the magic variable 'request'

13:43 in the 0.4 versions one has to provide a name for the request manually

13:44 defroutes makes a ring handler

13:46 hrm, I can't find the docs where I saw it

13:48 daaku: raek: i see, i'm using 0.4. i can't find docs, and i'm not smart enough to figure out what's going on looking at the source here http://github.com/weavejester/compojure/blob/master/src/compojure/core.clj

13:50 raek: (defn- compile-route [method route bindings body]

13:50 (GET "toute" <bindings> <body>)

13:50 *route

13:50 now I found where the bindings should go

13:51 daaku: bind-request does the heavy lifting?

13:51 rhall: tomoj: thanks for your help yesterday with swank.core/break... turns out my project was polluted with some version mismatches... I cleaned it up and everything is fine now

13:52 raek: appears so

13:53 try (GET "..." request <body>)

13:55 as far as I can tell from the code, that should result in a (let [request <request-map>] <body>)

13:55 daaku: raek: so that worked, but i can't understand why -- i see that we get into the else clause of the if in bind-request

13:55 cool, i think i get it now

13:56 raek: I can swear I have seen some docs exaplining this

13:56 but compojure seems to be a turbulent project

13:57 apparently, a lot of it's functionality was accumulated into ring

13:57 I've only used the 0.3 versions

13:58 daaku: i'm just getting started, and i'm not so sure i should be using compojure or ring directly

13:58 i started off with a sample app engine project, so kinda stuck with it

13:59 raek: the projects I'm aware of are: compojure, ring, moustache and aleph

14:04 daaku: aleph seemed cool. i've been using nodejs for random projects, and while the async nature gave huge perf gains, the callback model sucked. i was surprised to see aleph perform so well.

14:06 raek: I'm considering using moustache, due to it's nestable nature

14:07 I want to generate the routes from another hierarchy

14:07 like saying, foos has many bars, and automatically get urls like /foo/1/bar/2

14:08 daaku: i hadn't see this -- i thought you were refering to the templating language

14:08 *seen

14:12 i think i need to try this

14:12 thanks for pointing it out raek

14:40 gfrlog: test

14:42 Does anybody know about why functions like split-with are implemented so inefficiently? (http://github.com/richhickey/clojure/blob/a1eff35124b923ef8539a35e7a292813ba54a0e0/src/clj/clojure/core.clj#L2212)

14:42 like is it a subtlety involving lazy seqs, or has nobody gotten to it yet?

14:42 (basically I'd be happy to do it, just wanted to make sure it wouldn't be wasted effort)

14:45 qbg: gfrlog: The results of take-while and drop-while are lazy, so they won't be evaluated until needed

14:45 gfrlog: but that implementation will still evaluate them twice, won't it?

14:46 qbg: Evaluate what twice?

14:46 gfrlog: the predicate

14:47 qbg: If you are forcing both of them all the way, yes

14:47 gfrlog: so is there no way to do it lazily without double evaluation?

14:49 qbg: You should be able to, but it wouldn't make much of a difference unless the predicate was expensive

14:50 Benchmarking would be needed to see if there would be any real gain

14:50 somnium: gfrlog: it returns two different lazy-seqs, I think you would have to do the take-while part eagerly to only evaluate the predicates once

14:51 gfrlog: off the top of my head I would think something like this:

14:52 qbg: I'm going try to write it with only one evaluation of pred

14:52 gfrlog: map the collection to pairs of the elements and the results of the function, then create a take-while and a drop-while that just examines the computed result, and return something that maps the elements back out

14:52 I was gonna write code, but then I thought explaining it might be clearer. Now I think I would've been better with code

14:52 one sec

14:53 '(1 [:a :b :c])

14:54 ,(1 [:a :b :c])

14:54 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

14:54 ihodes: other way around

14:54 gfrlog: ,([:a :b :c] 1)

14:54 clojurebot: :b

14:54 gfrlog: very good

14:56 okay

14:56 http://gist.github.com/489785

14:56 (my-split-with #(> % 0) [5 1 2 3 -2 -1 0 1 2])

14:56 [(5 1 2 3) (-2 -1 0 1 2)]

14:57 I've never contributed anything to the codebase before -- does anyone know if this sort of thing would be welcome?

15:01 qbg: Your split-with is about 3.27 times slower that the built in one for a simple predicate

15:01 somnium: gfrlog: that version does add an extra lazy seq that both close over. some cases (eg: my-split-with identity [ ... ]) might get slower too.

15:02 qbg: #(< % 0) on the coll (range -10000 10000)

15:02 somnium: gfrlog: in any case, you may want to read:

15:02 http://clojure.org/contributing

15:07 gfrlog: So I suppose this has already been thought through, and the conclusion is that for large predicates the programmer should create his own implementation?

15:10 ,((fn [x] (x x)) (fn [x] (x x)))

15:10 clojurebot: java.lang.StackOverflowError

15:12 raek: nice, my CA got in

15:17 can somewhone here who's a member on the assembla space bump up my membership from watcher to member?

15:25 gfrlog: , (*

15:25 clojurebot: EOF while reading

15:25 gfrlog: (*

15:25 (+

15:25 (+ (*) (*))

15:25 (*))

15:25 (+

15:25 (*

15:25 (+ (*) (*))

15:25 (+

15:25 (+ (*) (*))

15:25 (*)))

15:25 (*)))

15:25 (+ (*) (*)))

15:26 ,(* (* (+ (+ (*) (*)) (*)) (+ (* (+ (*) (*)) (+ (+ (*) (*)) (*))) (*))) (+ (*) (*)))

15:26 clojurebot: 42

15:28 serp_: ,(*)

15:28 clojurebot: 1

15:40 chouser: cute

15:41 rhall: can anyone point me to doc on the contents of the project.clj file?

15:42 raek: rhall: http://github.com/technomancy/leiningen

15:42 rhall: http://github.com/technomancy/leiningen/blob/master/sample.project.clj

15:42 the second link contains more details

15:43 rhall: ok, yeah... read that... I was wondering if there was an actual manual, or if that sample contains all the options

15:43 map_reduce: hey, i've got a memory management question: I've got about 1.3M lines of data split over 32 files. I open up the files using (map #(duck-streams/read-lines %) file-list)) . Then I pass the map into seq-utils/flatten. Everything works just fine, but when I was doing some tests, I noticed that just asking for (count (flatten etc... )) my memory usage skyrockets. Does this mean i'm some how maintaing a reference

15:43 raek: there's not much more than that

15:43 rhall: (thx, tho raek... didn't mean that to sound so "short")

15:43 raek: other plugins may more keys to the defproject form, of course

15:44 rhall: yeah... what I'm really trying to work out is how to include a fairly large directory of jars

15:44 without coping them all to my lib dir

15:45 raek: now I will attempt to use leiningens new checkout dependecy feature

15:45 Drakeson: which swank-clojure is most common? technomancy's ore jochu's?

15:45 raek: technomancy's

15:45 jochu was the original maintainer, but technomancy is the current, IIRC

15:46 chouser: map_reduce: probably

15:47 Drakeson: I see. could someone with commit access please fix the completion? (src/swank/commands/completion.clj and .../contrib/swank_c_p_c.clj need a very minor fix)

15:47 map_reduce: chouser: are there some basic things I should look for to debug this?

15:47 lozh: map-reduce: try running java with a reduced heap size, if it doesn't go oom it could just be a garbage collection artifact

15:47 Drakeson: technomancy: ping

15:48 map_reduce: lozh: cool thanks, i'll try that

15:48 raek: Drakeson: if you have a github accound, you can fork it, patch it, and send a pull request to technomancy

15:49 Drakeson: raek, yeah I know, I am probably being lazy. the fix is basically a typo, though

15:51 raek: he might be busy with his job, but he will take a look at your pull request eventually

15:51 Drakeson: raek: nevermind, I'll do that if I cannot reach him

15:51 raek: I made a small 2-line patch for clojure-mode once

15:53 can one delegate commit acces on github?

15:54 Drakeson: raek: there is this "organization" thing, targeted at businesses that pay monthly, ...

15:55 map_reduce: lozh: thanks, i just played with the heap size and set it to a uselessly small number. The reported memory usage went down by about 40% and the thing still didn't squak

15:55 Drakeson: apparently they occasionally allow free software projects to use that, though.

15:56 raek: yeah, saw that clojure got an organization account recently

15:58 Derander: Drakeson: yeah, I think that suitably large foss can get those accounts because they figure it'll draw in more profitable users than it costs

15:58 hiredman: huh?

15:59 I think you can just start an organization

15:59 seajure (seattle clojure group) has one

15:59 Derander: oh, yes. I'm wrong

15:59 I was mixing private/public in my head

16:01 edbond: how to create a subclass of java class in clojure?

16:02 raek: edbond:

16:02 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/proxy

16:02 hiredman: edbond: don't

16:04 raek: ifaik, proxy is for interfacing with java when the api requires subclassing

16:05 edbond: I want to subclass Folder from javax.mail but don't want to do this in java.

16:05 raek: hiredman: what are the alternatives?

16:06 edbond: proxy will let you do it.

16:06 edbond: ok, thanks

16:06 Raynes: raek: He sells magic wands.

16:08 raek: inheriting from classes is not very clojure-ish, and should not be used when designing clojure code

16:08 but clojure cannot fix java

16:24 daaku: is there a way to figure out what's pulling in a specific dependency in lein?

16:46 hugod: daaku: you could run "mvn dependency:tree", which would use the lein generated pom.xml

16:47 daaku: hugod: cool, it's running

16:48 nice, that worked

17:07 Bahman: Hi all!

17:11 daaku: anyone know of a good library (or plugin) for running app engine via lein repl? i have a bunch of hacks that work from various places atm, looking for something better

17:12 raek: there is a lein-gae plugin

17:12 I have never used it nor app engine, though

17:15 daaku: looks like that's for setting up the stub xml and the dependencies

17:31 raek: anyone know if Apache License v2.0 is compatible with the EPL (clojure's license)?

17:37 Raynes: raek: I believe so.

17:38 raek: just investigating if openid4java can be used at all

17:38 it's really sad that there are incompatible free software licenses

17:39 but at least the clojure world seems to use the same license

17:40 someone should make a license compability graph...

17:40 that would be awesome!

17:41 like this, but not only to/from GPL: http://www.gnu.org/licenses/quick-guide-gplv3-compatibility.png

17:48 quidnunc: Is there a specific reason clojure wasn't GPL licensed?

17:49 nvm, clojure.org/funding

17:54 raek: hrm, TagSoup has that license too, and I recall that I found out that its license should be compatible with the EPL

17:57 then, what license should a openid4java wrapper library for clojure have? Apache or EPL?

17:57 both?

18:24 gfrlog: ,(take 11 (iterate dec 10))

18:24 clojurebot: (10 9 8 7 6 5 4 3 2 1 0)

18:29 seancron: Does anyone know how can I do (while swing-window-is-open ...) in clojure?

18:31 raek: I suspect you could do an event handler for the close event and update an atom, or something

18:34 seancron: I'm working with Incanter and I want it to continuously set-data until I close the table window

18:39 raek: maybe you could subclas WindowAdapter with proxy and implement windowClosing/windowClosed

18:39 and add it to the frame with addWindowListner

18:39 seancron: raek: here's the code I'm using right now http://gist.github.com/489954

18:40 raek: you'd need to get access to te JFrame

18:41 I'm not an incater user (yet), so I don't know how

18:43 seancron: It looks like (view ...) returns the JFrame

18:45 raek: then you could invoke .addWindowLister on it and pass your proxy object

18:59 seancron: Is there a break statement in clojure?

19:00 gfrlog: what would it do?

19:01 seancron: Break out of an infinite loop that's updating a window

19:03 raek: no, you'll have to "not loop" instead

19:04 (loop [] (when @running (do-stuff) (recur)))

19:04 (here running could be an atom containing a boolean)

19:06 seancron: what does the @ do?

19:06 gfrlog: dereferences the atom

19:07 'running' refers to the atom, while '@running' refers to its current value

19:07 (it could also be a ref or agent with the same syntax)

19:08 seancron: Thank you. Still getting the hang of clojure

19:08 gfrlog: np

19:08 raek: @foo is the same as (deref foo), if you need to lookup some details about it

19:08 gfrlog: ,(let [a (atom true)] (println a) (println @a))

19:08 clojurebot: #<Atom@17d8325: true> true

19:09 gfrlog: (doc deref)

19:09 clojurebot: "([ref]); Also reader macro: @ref/@agent/@var/@atom/@delay/@future. Within a transaction, returns the in-transaction-value of ref, else returns the most-recently-committed value of ref. When applied to a var, agent or atom, returns its current state. When applied to a delay, forces it if not already forced. When applied to a future, will block if computation not complete"

19:10 raek: the concurrency primitives (ref/agent/var/atom) are used rather than mutating variables

19:11 names introduced by let aren't even called "local variables" (instead, often just "locals") since they cannot be changed

19:12 the concurrency primitives provide different solutions for doing "variable assignment" in a multithreaded environment

19:14 seancron: Okay, thanks

19:45 Is there a more idiomatic way to pause for 10 seconds than (. Thread (sleep 10000)) ?

19:47 gfrlog: there sure oughta be

19:47 raek: (Thread/sleep 10000)

19:47 Lajla: raek, does Clojure support the COMEFROM statement to create a new thread?

19:48 raek: but other than that, none what I'm aware of

19:48 Lajla: never heard of that

19:49 Lajla: raek, essentially an inverted GOTO.

19:49 If the program hits a certain line number, it automatically jumps back to the point where you put the COMEFROM statement.

19:49 Like, if you put COMEFROM 120:

19:49 The moment you hit line 120, execution continues at that label.

19:50 rlb: http://en.wikipedia.org/wiki/COMEFROM

19:50 Lajla: Irrespective of what is on line 120

19:50 So, if you have COMEFROM 120: on different palces in your program.

19:50 You start different threads if you end up at 120.

19:50 raek: ah

20:03 Lajla: raek, but does it?

20:04 raek: Lajla: what do you think? :)

20:07 daaku: is there a url query string parsing/generating library for clojure (maybe full blown url parsing library)?

20:08 Lajla: raek, who made the bot ignore me?

20:09 aldebrn: I have an xml-derived hash map, with a key :tag which can take on multiple values such as :title, :section, and :paragraph. For each of these possibilities, I have an eponymous function. What's the right way to invoke e.g. the paragraph function when the value is :paragraph?

20:09 (Multiple values as in, one of a finite set of values)

20:09 raek: daaku: java.net.URL could be used

20:09 ,(bean (java.net.URL. "http://clojure.org/api"))

20:09 clojurebot: java.lang.reflect.InvocationTargetException

20:10 raek: user=> ,(bean (java.net.URL. "http://clojure.org/api"))

20:10 {:path "/api", :protocol "http", :authority "clojure.org", :host "clojure.org", :ref nil, :content #<HttpInputStream sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1ae90c>, :class java.net.URL, :defaultPort 80, :port -1, :query nil, :file "/api", :userInfo nil}

20:10 daaku: clojurebot fail?

20:11 oh, wow. bean huh

20:11 raek: probably the sandbox disallowing it

20:12 basically, it turns the object into a read-only map, with each key representing a getter method

20:13 daaku: i'm not a java guy, so forgive me if it's obvious, but isn't that a bad thing to go call every getter function?

20:13 or are beans special in that getters are always light weight?

20:14 raek: it only calls the function when you get the value of the key

20:14 it returns an object that implements APersistentMap

20:14 daaku: of course, lazy clojure

20:15 i'm ashamed of how much code i keep deleting. i had 200 lines of code this morning, now i'm down to 160.

20:15 and that's after _adding_ functionality

20:15 raek: I had the same experience when I started with clojure

20:15 the more I coded, the more the code shrank

20:16 daaku: it's both gratifying and demoralizing at the same time

20:17 raek: aldebrn: if I understood your question correctly, you could use multimethods

20:17 (defmulti some-fn :tag)

20:18 (defmethod some-fn :title [m] code-for-when-tag-is-title)

20:18 the third argument to defmulti is the dispatch function

20:18 (keywords are functions too and works like this: #(get % :tag) )

20:19 the distpatch function is applied to the arguments of a some-fn call and returns a value

20:19 that value is used to choose which implementation to invoke

20:19 hope this helps, now I need to sleep

20:20 aldebrn: Thanks raek, I could implement just that

20:20 raek: Lajla: I have no idea

20:20 good night

20:20 Lajla: raek, it was you wasn't it.

20:20 beause you're angry that yu couldn't have me.

21:44 seancron: raek: I realize you're asleep right now, but thanks for your help. I finally my code working. It now updates the data table every 10 seconds and actually exits on closing the window. If you want to see what I ended up with, you can check it out at http://gist.github.com/489954

21:46 Lajla: seancorfield, an I take the thanks instead then?

21:47 seancorfield: huh? oh you mean seancron

21:52 Lajla: seancorfield, I do.

21:52 Damned autocomplete.

21:52 Any way, you can thank and worship My Shadow too.

22:13 daaku: is there a private equivalent of def? i need to hold a private vector which will never change

22:18 gfrlog: (def #^{:private true} my-vector [:a :b :c])

22:18 I think

22:19 hiredman: #^ is deprecated, use ^

22:19 gfrlog: ooh nice

22:19 I always thought that looked clunky

22:19 hiredman: if you are on master I think ^:private should work

22:19 daaku: beta1?

22:19 hiredman: but maybe not for 1.2-beta?

22:20 I think the ^:private stuff comes with the static branch, which isn't part of 1.2

22:20 so in 1.3 ^:foo is equiv of ^{:foo true}

22:21 daaku: hiredman: yep, didn't work in 1.2

22:21 hiredman: :/

22:21 daaku: the map syntax did, so good for now :)

22:22 gfrlog: also, a shortcut when using defn is defn-

22:22 at least in the tired worn out versions of clojure that I use

22:22 daaku: yep, i was hoping there'd be def-

22:23 hehe

22:25 how "moving" would you say the clojure core/libraries are? do things change in breaking ways often?

22:25 just trying to get a rough idea, i know this is subjective

22:30 brehaut: is there a way to create a set (eg hash-set) from a seq where it discards duplicates rather than raising an exception?

22:33 rhudson: brehaut, I think you only get exceptions with duplicates in set literals

22:33 brehaut: i had thought that

22:33 rhudson: ,(into #{} [:a :a :a :a :a :a])

22:33 clojurebot: #{:a}

22:33 brehaut: ,(apply hash-set [:a :a :a])

22:33 clojurebot: java.lang.IllegalArgumentException: Duplicate key: :a

22:34 brehaut: thats probably why im having a problem ;)

22:34 rhudson: but that's equivalent to (hash-set :a :a :a)

22:34 gfrlog: ,(hash-set :a :a :a)

22:34 clojurebot: java.lang.IllegalArgumentException: Duplicate key: :a

22:36 brehaut: yes it is

22:36 but its what im doing ;) i dont hav ea literal vector to fill from

22:36 into ftw anyway

Logging service provided by n01se.net