#clojure log - Jul 21 2010

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

0:58 Bahman: Hi all!

1:04 technomancy: hello!

1:15 who's at oscon?

1:40 cais2002: is clojure.contrib.io now clojure.java.io ?

1:41 mikem: cais2002: yes: http://www.assembla.com/spaces/clojure/tickets/311

1:42 cais2002: thanks, mike

1:56 konr: I'm building an interface using QT Jambi - it *should* work on Windows, right?

2:08 bortreb: is there any way to get rid of the explicit loop in this code? I'm trying to make it more idiomatic but I'm new to clojure --- http://gist.github.com/484131 thanks :)

2:15 talios: Home time. I'm outta here.

2:16 tomoj: bortreb: maybe it would be nicer to use a promise?

2:19 Raynes: Conjure looks cool.

2:35 bortreb: tomoj: use a promise instead of a future?

2:35 tomoj: instead of an atom

2:35 something like this maybe? https://gist.github.com/7108adefc34f7ff2ea73

2:37 raek: bortreb: when a thread derefs a promise object, that thread will block until some other thread delivers a value

2:37 tomoj: derefing a promise will block until it's delivered

2:37 bortreb: tomoj: but what if the other future tries to deliver to the promise before it's future-canceled? wouldn't that throw an exception?

2:37 tomoj: so you can have the futures all compete to be first to deliver

2:37 yeah, but do you care?

2:37 bortreb: nope! :)

2:37 tomoj: you won't get the exception in your thread

2:37 bortreb: so i could wrap it in try or something

2:38 tomoj: (right?)

2:38 oh, maybe you would, I dunno

2:39 seems not

2:40 raek: ,(let [p (promise)] (deliver p :foo) (deliver p :bar)]

2:40 clojurebot: Unmatched delimiter: ]

2:40 raek: ,(let [p (promise)] (deliver p :foo) (deliver p :bar))

2:40 clojurebot: java.lang.IllegalStateException: Multiple deliver calls to a promise

2:41 tomoj: ,(let [p (promise) f (future (deliver p :foo) (deliver p :bar))] @p)

2:41 clojurebot: :foo

2:41 tomoj: the future blows up but doesn't matter, you've got the answer already :)

2:43 bortreb: that's real nice, I did some timing and it seems to be a little faster than the loop method!

2:45 tomoj: won't be spinning on derefing to check ::void

2:46 bortreb: thank you so much!

2:50 konr: how can I get a static field of a java object?

2:51 oh, of course

3:33 neotyk: Hi #clojure!

3:34 Yesterday I got an issue that returning vector of bytes is bad design

3:35 That I should return ByteArrayOutputStream

3:36 I have my doubts, BAOS is java object and you have to use additional tools to deal with it, while vec is native

3:36 please advise.

3:37 raek: I guess that depends on what you are youing to do with it

3:38 neotyk: it is http client, and way to transfer body, or body parts, back to caller

3:39 http://github.com/neotyk/ahc-clj/issues#issue/1

3:42 Kaali: Hi everyone, I'm trying to create a simple web form validation library. I'm getting an error from my macro which I don't understand: http://gist.github.com/484140 -- the error message from SLIME is in the comment.

3:45 neotyk: Kaali: have you tried macroexpand-1?

3:45 Kaali: Yes, and it seems ok in my eyes.

3:45 The problem seems to be with the anonymous functions returned by transform, but they work fine when I run them in REPL.

3:46 With macroexpand, the map fn ~validators# expands to the key-fn map as it should.

3:49 tomoj: neotyk: when i was looking at your library earlier today, I found it very odd that a vector of bytes was returned

3:51 you're adding each byte one at a time onto that vector

3:51 which seems like it would be pretty slow

3:52 also consider cases where you don't want the whole response in memory at once

3:53 neotyk: tomoj: agree adding might be slow, disagree on whole resp in memory, as there is streaming api

3:54 tomoj: so you would also be in favor of ByteArrayOutputStream?

3:54 tomoj: dunno about that

3:54 all I really want is a string :)

3:55 neotyk: but if you're getting png, string will not work

3:55 tomoj: I'm not getting png

3:55 neotyk: lol

3:55 tomoj: (not suggesting String)

3:56 neotyk: helper function to extract string from responses body?

3:56 tomoj: I admit I did give up on your library when I saw the byte-at-a-time-into-vector thing

3:57 neotyk: tomoj: ok, this convinced me, moving out from byte vector to outputstream

3:58 tomoj: would (string (:body @resp)) be user friendly enough?

3:58 tomoj: I'd personally be happy with that

3:59 neotyk: tomoj: can I come back to you for review round, once I have it fixed?

3:59 tomoj: I don't think I'll be able to offer much advice.. ByteArrayOutputStream scares me too

3:59 my only input is that vector of bytes seemed wrong :)

4:00 but I'll be here

4:00 neotyk: I can handle BAOS, would like you tell me if getting string is good :-)

4:01 tomoj: thanks for been honest and your input, it is appreciated.

4:01 tomoj: hmm

4:01 ByteArrayOutputStream can't be right, can it?

4:02 I mean... it's an output stream

4:03 neotyk: tomoj: yes, should be ByteArrayInputStream

4:04 tomoj: btw, why'd you go with all-caps for GET/PUT/etc?

4:04 just curious

4:04 to avoid clobbering stuff in core?

4:19 neotyk: tomoj: it was named after http verbs, also is kind of counterpart of compojure

4:20 and partly because core defines get already

4:27 rdsr: Has anyone received the following error when cloning a repo

4:27 error: Unable to find bf17b72ec8320703015ba6509000cd20fed1fd0a under http://github.com/clojure/clojure-contrib.git

4:27 Cannot obtain needed tree bf17b72ec8320703015ba6509000cd20fed1fd0a

4:27 bulters: gday...

4:28 tomoj: rdsr: nope

4:28 just cloned clojure-contrib fresh, no problem

4:29 old git?

4:29 rdsr: git version

4:33 what's worse, its giving different errors on different retries, now it gives

4:33 error: Unable to find 3e3c10a5dfe5d0e8db0094324e55dd14ccb98f8d under http://github.com/clojure/clojure-contrib.git

4:33 Cannot obtain needed blob 3e3c10a5dfe5d0e8db0094324e55dd14ccb98f8d

4:33 while processing commit e0080e640a2d9b79564a3fb6eb7ee36be1882901.

4:33 fatal: Fetch failed.

4:37 Raynes: mmarczyk: Ping.

5:17 opqdonut: anyone else have problems with permgen filling up with clojure?

5:20 naeu: morning

5:21 AWizzArd: Hi naeu

5:21 naeu: is there an equivalent of subvec for lists?

5:21 I'm playing around with a basic implementation of quicksort

5:21 and I'm putting in a vector, which is then being split with subvec and then concatenated with concat

5:22 however, concat appears to return a list

5:22 which then faile

5:22 s/faile/fails

5:22 in the next recur as subvec needs a vector

5:22 AWizzArd: naeu: you could use a composition of take and nthrest

5:23 naeu: AWizzArd: interesting, i've not seen nthrest before

5:52 lozh: ,(vec (concat [1 2 3] [2 3 4]))

5:52 clojurebot: [1 2 3 2 3 4]

5:59 cais2002: how do I instruct leningen to ignore some files when creating the jar file?

6:09 Raynes: Why does shuffle return a vector?

6:12 lozh: Raynes: I guess it depends on having a reasonably performant nth implementation

6:14 Raynes: There should probably be a slower list option. :\

6:14 It's kind of screwing with me now.

6:17 lozh: shuffle just delegates to java.util.Collections.shuffle might be able to adapt it

6:18 ,(seq (shuffle [1 2 3]))

6:18 clojurebot: (2 3 1)

6:23 dsop: ,(clojure-version)

6:23 clojurebot: "1.2.0-master-SNAPSHOT"

6:24 dsop: ,(partition-all 5 [104 104])

6:24 clojurebot: ((104 104))

6:25 lozh: Raynes: shuffle-to-list @ http://clojure.pastebin.com/8rKpGYfW

6:26 Raynes: (into '() ..) also works. :p

8:35 brweber2: any ideas how to submit a ticket via assembla? There is no create button on the tickets page....

8:36 raek: brweber2: if you aren't a contributor, you can create a ticket at the support tab: http://www.assembla.com/spaces/clojure/support/tickets

8:37 I think you need to create an account, though

8:38 but being a watcher of the project is enough to create tickets

8:38 brweber2: raek Even on that page, there is no button/link to create a ticket, sounds like I need more permission?

8:39 raek: brweber2: are you watching the space?

8:39 the new ticket is there once you have logged in

8:39 brweber2: raek Thought I was b/c it showed up in 'My Start Page' but turns out I wasn't! Fixed now, thanks.

8:39 raek: s/new ticket/new ticket button/

8:39 sexpbot: the new ticket button is there once you have logged in

8:40 raek: I really wish rhickey would check the CA post box soon

8:41 I have two really anoying bugs I want to fix

8:41 opqdonut: how much does 1.2 break at the moment?

8:42 is its performance any better?

8:42 Raynes: I'm pretty sure it's source compatible with 1.1.

8:42 opqdonut: our code is spending 23% execution time in isInstance...

8:47 lozh: What are you using to get the performance profile?

8:50 opqdonut: yourkit

11:42 lpetit: Hi,

11:48 rubydiamond: to buy kindle dx or not

11:49 nDuff: rubydiamond, I gave you my advice already.

11:50 esj: hey lpetit

11:50 nDuff: rubydiamond, ...if your goal is to read the Joy of Clojure or other content from Manning, it works well for the task.

11:50 rubydiamond: nDuff: heh

11:50 yes

11:50 nDuff: I had ordered it and it got returned back to shipper due to my absense

11:51 technomancy: it's great for public domain books as well; that's all I use mine for

11:51 but you don't need the DX for that

11:51 lpetit: esj: hey !

11:52 rubydiamond: technomancy: what do you mean by you don't need DX for that

11:53 technomancy: rubydiamond: well the point of a DX is that the page layout is kind of close to what you'd see in a paper book... so if you've got a carefully-crafted PDF with diagrams and such, it helps

11:54 but for just reading text, there's no advantage of having the larger model

11:54 lpetit: ccw users, like it or not, but the next release candidate will embark with an even more automatic mode :-) (I've not yet started to implement the result of the lessons learned from the ml thread)

11:55 rubydiamond: technomancy: so do you recommend Kindle 2?

11:55 technomancy: rubydiamond: I recommend the Kindle 1 actually

11:55 rubydiamond: haha .. ?

11:55 technomancy: why?

11:55 technomancy: I hate how they dropped the analog place-ribbon

11:55 they moved all the UI feedback to the screen, and the screen has a lousy refresh rate

11:56 lpetit: don't panic: in fact it will be a correction of a bug: currently, when you start a REPL (I should say launch a clojure environment via clojure.main), nobody is loaded by default. And as soon as you save any file, everything in the project is loaded. This was somehow inconsistent. With the bug corrected, a new launch wil automatically trigger the load of the project, without waiting for a...

11:56 ...first save

11:56 technomancy: with the Kindle 1, you could get faster feedback on what you were selecting that wasn't rate-limited by the crap refresh rate

11:56 rubydiamond: technomancy: do you have kindle 2 or 1?

11:56 technomancy: plus it had an analog scroll wheel instead of a d-pad, which is much nicer

11:56 rubydiamond: I have the v1

11:56 rubydiamond: plus it supports SD-cards

11:56 * lpetit has learned that they are far less users of ccw in #irc than on the ml, so is making questions / answers :-)

11:57 technomancy: the only advantage of the v2 is the 15%-ish faster refresh rate

11:57 rubydiamond: technomancy: okay.. but is Kindle 2 device worth buying?

11:58 technomancy: rubydiamond: sure, as long as you're not paying more for it than you'd pay for a v1

11:58 just don't buy any books from amazon

11:58 rubydiamond: technomancy: yeah.. also how many books you have read on your kindle 1?

11:58 and how many tech books ? :p

11:58 technomancy: probably 30-40 books; maybe 5 tech books

11:59 the code samples in tech books are hard to read on the smaller screen

12:00 rubydiamond: aw.. but technomancy, do you think that it's bad thing?

12:04 technomancy: depends on the book... some rely on code more than others

12:05 rubydiamond: okay.

12:05 technomancy: do you think kindle 2 is must have device?

12:06 lpetit: rubydiamond: by looking at the characteristics of the different models from the wikipedia page, seems like Kindle DX International 2 is what I would buy, would I buy one of these devices

12:07 rubydiamond: hmm

12:07 confused..

12:07 technomancy: rubydiamond: it's great for people who like to read, especially those who like to read books that are out of copyright

12:07 lpetit: http://en.wikipedia.org/wiki/Amazon_Kindle#Kindle_DX_International_2

12:07 technomancy: rubydiamond: I can't recommend the Amazon book store, but for reading content from feedbooks.com etc. it's absolutely fantastic.

12:08 rubydiamond: $379 > $189 I think I would go for Kindle 2 .. and not DX..

12:08 technomancy: and with tech publishers it varies; some of them are good about releasing DRM-free ebooks and some are not. oreilly and the prags are the best.

12:09 rubydiamond: I am hoping that I would be able read tech pdfs I have (10+ in my pool)

12:09 lpetit: rubydiamond: I understand, but I'm not a frenetic consumer, and when I spend money, I prefer to spend more money on something that will make me the most happy for the most time

12:10 technomancy: rubydiamond: ah, actually I realized the Kindle 2 does have one other advantage over v1; it supports PDFs natively

12:10 rubydiamond: lpetit: I think same.. but as technomancy said .. less size is better for mobility

12:10 technomancy: the v1 has to go through a manual conversion process. so I don't know how PDFs look on v2

12:10 rubydiamond: technomancy: yeah

12:10 technomancy: hmm

12:11 technomancy: but... there's still no way you could show some of the code samples without line-wraps

12:11 rubydiamond: the only missing information I have is that how people find reading pdfs on Kindle 2

12:11 :)

12:12 lpetit: rubydiamond, technomancy: I understand the less size argument, but I fear that it would somehow decrease the pleasure to read, because currently most formats still respect US / A4 and thus either the page will be reduced, either you will not be able to see one page at once

12:13 technomancy: also depends on where you're planning on reading it. if you have a long commute each day you'd need something smaller vs reading on the couch at home.

12:14 lpetit: sure

12:14 rubydiamond: http://upload.wikimedia.org/wikipedia/commons/0/0b/Kindle_DX_Front.jpg vs http://upload.wikimedia.org/wikipedia/commons/d/d7/Kindle_2_-_Front.jpg

12:14 lpetit: and the kindle dx is approximately the same size and price of an iPad, hmmmm

12:15 rubydiamond: lpetit: yeah

12:15 that's what I am thinking bad about it .. I think i would never click 'confirm payment' button for dx

12:16 looks like I am going to buy Kindle 2

12:16 lpetit: rubydiamond: your 2 screen shots convinced me that I'm not yet ready to read on these devices unless needed. So maybe yes, I also may choose the smallest one after all, and use it only when forced to

12:17 technomancy: those photos make it look blurry; it's actually very crisp.

12:17 rubydiamond: lpetit: why when forced..

12:17 lpetit: rubydiamond: 'cause I'm still considering that they are poor replacements for POBs.

12:17 Plain Old Books

12:18 rubydiamond: lpetit: that's true.. but when you are commuting or waiting state.. you don't have POB with you most of time

12:18 dakrone: lpetit: if you travel with books, a kindle is amazing

12:18 technomancy: lpetit: you should see how easy it is to get new content from feedbooks on the Kindle

12:18 dakrone: took mine to Europe, so much better than a suitcase full of books

12:18 technomancy: lpetit: you think to yourself, "I want to read Sherlock Holmes" and 30 seconds later it's in your hand.

12:19 rubydiamond: I spend time when I am waiting for somebody .. that time I could just open up my bad and start reading books .. like Joy of Clojure on my Kindle

12:19 lpetit: pain of taking notes, no colors yet, you can't jump with your fingers from one page to the other, bad support for "visual memory", etc.

12:19 rubydiamond: dakrone: kindle 2 or dx?

12:19 dakrone: rubydiamond: kindle 2

12:20 lpetit: dakrone: granted, but still seens as a "plan B" for when travelling

12:20 dakrone: it's not a replacement for physical books, but it still quite nice

12:21 put stuff on instapaper, put your instapaper on your kindle

12:21 rubydiamond: dakrone: how is for reading tech pdfs?

12:22 lpetit: technomancy: is it a real feature, or a gadget feature ? Having the book quickly is now easy, reading it not so (or do you have the same learning machine as is used in Matrix ? :-) )

12:22 dakrone: rubydiamond: I've read the Practical Clojure book on it with no problems. I also read a lot of tech whitepapers without too much trouble

12:22 if you have bad eyes or like large text, it will be harder

12:22 lpetit: rubydiamond: I almost always have a bag with my laptop and a book in it :-)

12:22 rubydiamond: dakrone: can't I just zoom text on pdf?

12:23 lpetit: rubydiamond: a good muscle exercise, for us who sit behind a desktop all day long :)

12:23 technomancy: lpetit: I'm just saying I have read significantly more fiction since getting a kindle

12:23 dakrone: rubydiamond: yea, you can. If it's a text/azw/html document though, when the text is large the wrapping can make code snippets hard to read

12:23 lpetit: technomancy: now that's interesting

12:24 dakrone: but that's only if you use a large text size

12:24 rubydiamond: dakrone: you mean I can't zoom for pdf .. that's not good news

12:24 technomancy: YMMV of course. =)

12:24 dakrone: rubydiamond: no, you can zoom for pdf

12:24 rubydiamond: dakrone: then I can just zoom and read

12:24 :)

12:24 dakrone: rubydiamond: yep

12:25 plus, super-basic web browsing for emergencies ;)

12:25 lpetit: I make a difference between books from which there is something to be learned, to which one will want to come back (and make his "sensorial" / "visual" memory work), from fiction book you will rarely ever re-read again

12:25 technomancy: lpetit: yes, the kindle is terrible for reference materials

12:25 if it's something you want to come back to and page through

12:25 lpetit: technomancy: forgive my bad english: terrible with the "very bad" meaning ?

12:26 technomancy: right

12:26 rubydiamond: :(

12:26 that's my use case .. reading lots of tech pdfs ..

12:27 dakrone: rubydiamond: how do you normally study/read tech stuff?

12:27 technomancy: rubydiamond: well there are different kind of tech books

12:27 dakrone: do you take notes? highlight?

12:27 technomancy: some are meant for a linear read, while others are meant for a more "cookbook" style of reading

12:27 rubydiamond: dakrone: I normal read physical tech books.. I also read pdfs on macbook pro

12:27 lpetit: do you have a more "visual" than "auditive" memory ?

12:28 rubydiamond: I have purchased 10+ tech books in last year .. I never completed reading my tech pdfs..

12:28 lpetit: that's a sign ...

12:30 dakrone: rubydiamond: do you normally just read through them, or do you take notes and/or highlight as you go?

12:30 do you use margins in books?

12:30 lpetit: not trying to prevent you from consuming, but setting the expectations at the right level helps not being disappointed

12:31 dakrone: if you want to see how a particular PDF looks, I suppose I could load it up and take a picture of the kindle for you if that would help

12:33 rubydiamond: got disconnected..

12:33 did I miss something

12:34 dakrone: rubydiamond: if you want to see how a particular pdf looks, I offered to load it up on mine and take a picture if that would help

12:34 rubydiamond: dakrone: yea it would definitely help

12:35 dakrone: rubydiamond: do you have a PDF you want to see?

12:35 rubydiamond: you can use practical clojure / joy of clojure

12:36 technomancy: I wonder how Practical Clojure would sell if they had actually promoted it before it came out.

12:37 rubydiamond: I am wondering how Jay Fields and Uncle Bob are liking and loving Clojure

12:37 both are icons..

12:37 dakrone: rubydiamond: the only clojure book I own is _Programming Clojure_, that okay?

12:37 rubydiamond: dakrone: yeah okay..

12:37 :)

12:40 lpetit: rubydiamond: First time I'm hearing of Jay Fields, that okay ? :)

12:41 rubydiamond: lpetit: not very okay.. if you are online for last 5-6 years and following programming things..

12:41 lpetit: http://blog.jayfields.com/

12:41 lpetit: 'cmon

12:42 slyrus: what's the conventional leiningen layout for test code myproject/test or myproject/src/test?

12:43 rubydiamond: dakrone: waiting for your pic.. :)

12:44 tomoj: anyone successfully installed clojure-test-mode from elpa lately?

12:44 dakrone: rubydiamond: takes time, hold on :)

12:44 technomancy: tomoj: there are problems using the stock package.el; try my patched version: http://p.hagelb.org/package.el

12:44 tomoj: technomancy: thanks

12:44 lpetit: must leave, bye guys

12:48 dakrone: rubydiamond: http://imgur.com/oYBvd.jpg http://imgur.com/Z6o01.jpg http://imgur.com/GsG6N.jpg http://imgur.com/Vqd9n.jpg

12:48 Lajla: ,(let [large + black 1 phallic 2 cock 3] (large black phallic cock))

12:48 clojurebot: 6

12:49 dakrone: excuse the poor quality, it's a phone camera

12:49 technomancy: dammit, what happened to my /ignore list

12:49 rubydiamond: dakrone: checking

12:52 dakrone: have you zoomed the text in later screenshots

12:52 dakrone: rubydiamond: yea, 150%

12:53 rubydiamond: dakrone: okay..

12:53 text looks good when zoomed... but not for 100% size

12:53 but that's fine..

12:54 dakrone: yea, however, Amazon also has a free service that will convert a doc to kindle format so it behaves like regular text, if you would rather use that

12:55 rubydiamond: dakrone: okay..

12:55 dakrone: anyway, we've hijacked the #clojure room for long enough probably, feel free to pm me if you have any other questions :)

12:55 rubydiamond: dakrone: thanks for the help.. it would definitely help me

12:56 dakrone: yeah.. lets stop talking about kindle.. and i am ordering one .. kindle 2

12:56 technomancy, lpetit thanks guys.. gonna order one

12:57 nDuff: rubydiamond, ...personally, I wouldn't buy a non-DX Kindle -- if I wanted something for which I'd be using non-reflowed text (that is, not PDFs), I'd buy a reader with ePub support to reduce vendor lockin.

12:59 technomancy: it's pretty trivial to translate between .epub and .mobi though

12:59 they're both HTML subsets

13:00 rubydiamond: technomancy: yeah right ..but code snippets would lose formatting

13:03 TakeV: What is the function to import clojure scripts into the current namespace, if they are not in the same directory? Like, if I was working in ~/cljapp, and I needed a script from ~/libraries/clojure?

13:05 rys: load-file at a guess

13:05 TakeV: (doc load-file)

13:05 clojurebot: "([name]); Sequentially read and evaluate the set of forms contained in the file."

13:05 pdk: (doc alias)

13:05 clojurebot: "([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."

13:06 TakeV: Hmm, alright, thanks.

13:07 tomoj: TakeV: don't do that, though

13:07 :)

13:09 TakeV: tomoj: Why not?

13:09 tomoj: well, maybe there could be some situation in which that would be a good thing to do

13:10 cmiles74: TakeV: I think you want to use the "ns" macro.

13:10 tomoj: if it's simply that your project in ~/cljapp depends on a project living in ~/libraries/clojure, you should use leiningen or maven or something instead

13:11 or at least jar up whatever's in ~/libraries/clojure and put it on the classpath for ~/cljapp

13:11 cmiles74: Something line (ns takev.cljapp (:use [clojure.contrib.logging]))

13:14 tomoj: if you do a load-file with an explicit path to ~/libraries/clojure/..., no one else will be able to use your code, it will be a pain in the ass to deploy

13:14 and probably other terrible things will happen

13:14 polypus: ~ping

13:14 clojurebot: PONG!

13:17 TakeV: tomoj: Hmm, then is there anyway to have a general library like I'm trying to do, without having to recompile it and move it to the new folder, each time I make a change to one of the files?

13:19 tomoj: lein 1.2.0 can do that

13:20 it may actually be easier for you right now to use some evil load-file stuff for development

13:20 just get rid of it eventually :)

13:20 TakeV: I'd rather do it right than do it easy, but if they are one in the same then I'll do that. :)

13:21 rhudson: Don't use and require work with source files as well as compiled?

13:21 tomoj: but these source files aren't on the classpath

13:21 (unless using lein's new checkouts thingy..)

13:21 TakeV: rhudson: I'm just not sure how to get them to work, when they are not in the project folder.

13:21 rhudson: The containing directory would have to be, sure

13:24 If you have ~/mylib/pkg1/src1.clj, and src1.clj starts with (ns pkg1.src1), and ~/mylib is on your classpath

13:25 tomoj: hmm, looks like lein will end up putting a checkout dep on the classpath twice, one from the checkout, one from whatever's in your .m2

13:25 wonder if that could cause trouble

13:27 TakeV: Hmm, actually, wonder if Clojars would be a good way to handle that. Lein would take care of the busywork.

13:27 tomoj: how would clojars help?

13:29 TakeV: tomoj: Lein's deps function would pull the library when needed.

13:30 technomancy: tomoj: the copy in checkouts will take precedence

13:30 tomoj: I guess clojure jars are special in that having multiples can break things?

13:31 technomancy: shouldn't be

13:31 tomoj: oh, maybe it's just that when you have multiples they might end up in the wrong order on the classpath

13:31 technomancy: there are ways to search the classpath beyond the first hit for a given file, but use and require will only honor the first.

13:31 yes, ordering is important.

13:31 tomoj: I meant clojure jars as in, clojure.jar and clojure-contrib.jar

13:32 TakeV: yeah, but you'd have to recompile and push every time you made a change

13:32 you could get the same effect without clojars by just `lein install`ing after each change, but again that's a pain, so, checkout deps to the rescue :)

13:32 TakeV: tomoj: Yeah, but that is still easier than manually copying the jar to each project that uses it when I make a change.

13:33 tomoj: ah, right

13:33 TakeV: Hmm, how do checkout deps work? I'm not familiar with them.

13:33 tomoj: `lein install` in the changed project then `lein deps` in the other will do that for you

13:33 (no need for clojars)

13:34 TakeV: Deps can grab a jar from, say, ~/libraries/clojure?

13:34 tomoj: `lein install` in your ~/libraries/clojure/foo lein project will install the foo jar into your local maven repo

13:35 then `lein deps` in the other project uses that one

13:35 technomancy: TakeV: create a "checkouts" dir in your project root, and then symlink the checkout of the dependency into that directory

13:35 TakeV: The checkout being the jar?

13:39 Bahman: Hi all!

13:40 technomancy: TakeV: no, the root directory of the project you're depending on

13:40 TakeV: Ah, alright. That makes sense.

13:40 Thank you.

13:43 matt3402382: Hi! Any pointers on how I can access the xml in a POST request in compojure? (btw I can get key=value params from a POST request in compojure and all works fine)

13:46 tomoj: hmm, do you have to visit the file in emacs through the symlink?

13:46 guess I'll try it out..

13:51 somehow it works, awesome

13:54 matt3402382: anyone familiar with compojure? I have a simple example working, and can pull out key=value pairs from an http POST on the server side, however when I use a client side framework which does an http POST with a piece of xml (not key=value pairs) I have no idea how to access it from the request on the server. Any ideas?

14:08 dakrone: matt3402382: I would try the #compojure room and see if anyone there knows

14:10 matt3402382: dakrone: ok thanks!

14:23 cemerick: hrm, looks like it's not possible to redefine a protocol interface if it's available in a prior AOT'ed form on the classpath

14:23 ...even if the only evaluated form is a new protocol definition :-/

14:32 * nDuff compulsively hits "refresh" on the Clojure 1.2 milestone page

14:41 yacin: is there a way to make lein compile-java have the -Xlint:deprecation option?

14:47 lancepantz: yacin: i don't know, but i would expect it to respect the JAVA_OPTS env

14:48 dpritchett: Silly question but does anyone know a particular resource that will help me understand when to use which higher-order function? I find myself using map or reduce when I see other folks using apply and I don't know if it matters.

14:49 I'm doing simple arithmetic for project euler problems such as "find the max of this list" or "find the max of the products of the contents of these lists"

14:51 jmatt: dpritchett: Look at the source is probably the simplest way to decide which function to use.

14:54 yacin: lancepantz: huh, doesn't seem to work so hot

14:54 25402 clj-ml-3.7.1:upstream!? % lein compile-java 2010-07-21 14:53:01 ynadji ttys012

14:54 Unrecognized option: -Xlint:all

14:54 Could not create the Java virtual machine.

14:55 jmatt: dpritchett: (use 'clojure.contrib.repl-utils) then you can do (source apply) etc

14:55 lancepantz: yacin: not sure man, i actually don't use lein, but i'm surprised that doesn't work

14:56 yacin: you and me both

14:56 dpritchett: thanks jmatt! I'm looking at map, reduce, and apply on clojuredocs.org right now

14:59 hugod: cemerick: same problem as #371?

15:00 jmatt: dpritchett: also doc is useful from the repl example: (doc apply) If you want more information on those concepts - any scheme or lisp book will work. No reason to look for something that is clojure specific.

15:00 cemerick: hugod: Seems like it, yes

15:01 dpritchett: jmatt: maybe i should dig sicp out again tonight. i'm not too far through it yet

15:06 kriyative: Hi all, quick leiningen question: any suggestions on speeding up `lein deps'? Seems to take a long time cycling through the various repos. Or is this more an issue with maven?

15:07 technomancy: kriyative: the more snapshot versions you have, the slower lein deps runs.

15:08 kriyative: technomancy: I'm not intentionally specifying any snapshot versions i.e, all the dependencies are to stable versions

15:09 technomancy: hmm; in that case future runs should be fast

15:09 the first run will always be slow

15:10 kriyative: ok, perhaps the repo servers themselves are hard hit, because it seems to take 60-120 seconds to decide the repo doesn't have the necessary pom or jar, and move on to the next repo

15:14 technomancy: so, this initial slow run is maven related?, and does it help to have a local maven proxy, at least for second and later developers?

15:15 sorry to badger with these questions, but I'm new to maven and leiningen. I really like leiningen but maven ... not so much :)

16:04 erikcw1: I just upgraded to lein-1.2 and now I'm having trouble creating jars. I'm using lein-javac to compile so Java code into my project. It seems to work fine (puts class files in classes/ directory). The problem is that lein uberjar deletes the contents of the classes/ directory as its first step. So I get a compile error about the missing class. How do I include lein-javac as a build step?

16:12 tomoj: erikcw1: hooks

16:12 I assume

16:13 erikcw1: tomoj: I guess I'll have to read up on that. Wasn't sure if anyone else had run up against the same issue

16:13 tomoj: there's a bit of info in the PLUGINS.md

16:17 bhenry: can someone help me make this better. https://gist.github.com/62e3f6c5c8cd3ddd4d5e i'd like to be able to have a list of extensions and match all files case-insensitively with those extensions.

16:18 (get-files dir) returns all file objects within that dir and its subdirs.

16:19 for now i'm only looking at jpg, gif, and png, but in the future i may want to add more to that list, so it would be nice to make the get-images function more adaptable

16:20 Chousuke: bhenry: you could combine the regexes into a single one

16:21 bhenry: i'm not so good with regexes. plus how do i make it match JPG as well?

16:21 tomoj: clojurebot: regex?

16:21 clojurebot: Sometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.

16:22 Chousuke: bhenry: I think there are some special regex thingies

16:22 mefesto: bhenry: i think this would work: #"[.](jpg|png|gif)$"

16:23 Chousuke: hmm

16:23 bhenry: mefesto: i'll try it out

16:24 Chousuke: put a ?i at the front of the regexp to make it case-insensitive

16:26 blais: Is there a way to escape a newline char in a multi-line string literal in clojure?

16:26 e.g. using '\' at the EOL does not work

16:26 tomoj: Chousuke: how? thought we couldn't do that in java

16:27 bhenry: mefesto that worked! thank you.

16:27 chouser: blais: as in you want a newline in your code, but not in the resulting string?

16:27 mefesto: ,(re-find #"(?i)[.](png|jpg|gif)$" "test.JPG")

16:27 clojurebot: [".JPG" "JPG"]

16:27 tomoj: oh, in parens?

16:27 blais: chouser: Yes.

16:27 Chousuke: tomoj: I got that from the JVM docs :/

16:28 blais: I have some sort of multi-line template which I'm declaring (and later on, massaging). I want the first line without a newline, but I also want to start it at column 0 in my input file. I'd escape the first newline char.

16:28 chouser: blais: yeah, I don't think there's a way to do that in a single string literal

16:28 blais: tomoj: btw thx the other day for your assistance, the problem was that somehow leiningen fell out of sync, I must have interrupted it while it was downloading, and it was in a funky state. Killing ~/.m2 and redownloading fixed the issue.

16:29 chouser: thx.

16:29 bhenry: mefesto: thanks again! i couldn't get chousuke's suggestion to work until you posted the correct syntax.

16:29 mefesto: np, lemme pass a thanks to chousuke since I didn't even know about (?i) till he said it :)

16:38 blais: An emacs / swank question: when I eval (println "blablabla") output goes to my slime repl buffer.

16:39 However, when I eval (do (for [x [1 2 3 4]] (println x))), output goes to my minibuffer.

16:39 Any idea why?

16:40 mefesto: blais: where does a (doall (for [x [1 2 3 4]] (println x))) go?

16:41 blais: Ah.

16:41 To the repl

16:42 I suppose the code that forces the evaluation of the seq overrides the out stream somehow.

16:42 mefesto: Thx.

16:42 technomancy: kriyative: sorry, was at lunch. yes, a local maven proxy will help.

16:46 blais: What is the best way to (read) and entire file's definition and return the values of all the top-level expressions contained therein?

16:48 chouser: blais: 'read' consumes only one top-level expression at a time from the IO stream you give it, so you could do that in a loop, eval'ing each one separately.

16:49 fualo: bas

16:49 blais: chouser: thx; That's what I've been doing just now; I thought there might be something pre-cooked since it feels like something common (e.g. use a clj file itself as an input file and gather the definitions therefrom).

16:49 fualo: er, sorry, wrong window!

16:50 chouser: blais: if you can require the input be a single expression (perhaps a literal map) that would simplify things.

16:50 blais: Riiight.

16:51 dpritchett: I'm uncomfortable with the look of this code, can anyone offer an improvement? (take 10 (map first (iterate (fn [[t n]] (let [i (inc n)] [(+ t i) i])) [1 1]))))

16:51 my first attempt had (+ 1 i) in two places so I figured I'd replace those with (inc i) and then I really didn't want to write (inc i) twice and so i switched to the let but now it's longer than before and I don't like that either

16:53 looks like I have a superfluous ) at the end, sorry. i copied this from my definition of a lazy sequence for triangle numbers

16:53 clojurebot: gender is irrelevant

16:53 blais: chouser: here's what I did: http://pastebin.com/pm10kn8d

16:53 chouser: (I'm a clj newbie, any comments welcome)

16:53 chouser: dpritchett: perhaps (take 10 (map first (iterate (fn [[t n]] [(+ t n) (inc n)]) [1 2])))

16:54 LauJensen: Any Clojure-Maven fundamentalists in the house tonight?

16:55 chouser: dpritchett: ooh, I think I found a nice solution using 'reductions'

16:56 blais: I'm on a REPL high, don't want to go back to the compiler. Have been trying to wean myself of this clj toy project all day now :-)

16:56 chouser: blais: read-expressions looks solid. I suspect there may be a better formulation of read-eval-expr

16:57 hm, actually you should probably close the reader too when you're done. maybe use 'with-open'

16:59 blais: read-eval-expr has a non-tail recursion that's a bit worrisome. perhaps use 'repeatedly' insteada?

17:00 mefesto: is it possible to create a temp namespace, load the file, then inspect that ns using ns-publics or something?

17:00 dpritchett: your rewrite of my triangle function makes sense chouser, curious about your reduction solution

17:00 chouser: mefesto: yeah, I've done that, but it's probably not ideal.

17:00 ,(reductions + (range 1 10))

17:00 clojurebot: (1 3 6 10 15 21 28 36 45)

17:01 chouser: mefesto: you'd lose the order of things (if that matters), plus it's simply not pure functional anymore.

17:01 fualo: this is more of a introductory lispy question (I come from python/C) but what is the clojurey/lispy way to insert something in the middle of a list? or is this code smell?

17:01 arete: is there a canonical way of defining a root binding that preserves the bound value across a compile-and-load cycle?

17:01 or does one just use an if bound?

17:02 chouser: fualo: depends on what you're doing. not automatically a code small at all.

17:03 arete: defonce

17:03 arete: hah go figure, thanks =)

17:05 erikcw1: How do I use :keywords with a space in them. (keyword "test this") seems to work, but I can figure out how to use the keyword using the : syntax.

17:05 technomancy: erikcw1: keywords with spaces in them aren't really kosher

17:06 it's an open question whether (keyword "test this") should even work

17:06 chouser: erikcw1: that's not a readable keyword. the fact that the 'keyword' function lets you make them is a bit of a bug.

17:06 http://www.assembla.com/spaces/clojure/tickets/17

17:06 fualo: thanks chouser!

17:07 * technomancy vaguely remembers submitting a patch for that bug over a year ago

17:07 technomancy: oh hey, there it is

17:07 chouser: fualo: you can insert stuff in the middle of a sorted map, for example.

17:07 fualo: or in the middle of a sequence

17:08 fualo: chouser: ah, that seems to be a good way. If you had to do it in a list, would you just cycle through to the point and return the concatenated list?

17:08 this is just early understanding stuff - nothing practical

17:08 (for me)

17:08 chouser: well -- I would generally try to avoid doing it in a list.

17:09 fualo: chouser: ah, ok. It would be O(n) worst unvoidably, no?

17:09 chouser: fualo: right

17:09 fualo: thanks

17:09 chouser: fualo: for something like a priority queue, a sorted map works well

17:10 fualo: right, right

17:10 awesome thanks

17:10 I have the MEAP version of your book btw, great work; I quite like it

17:10 chouser: if you *really* want to insert something at a specific index and still want fast lookup by index, this may be one of the rare use cases for finger trees.

17:10 fualo: ah great, thanks!

17:11 Blaine: I'm using clojure for the first time, it is freakin' sweet

17:12 dpritchett: Here's an ugly attempt, not sure you'd want to keep it but:

17:12 ,((fn [n] (lazy-cat (take-while #(not= n %) '(1 2 3 4 5 6 7)) (drop-while #(not= n %) '(1 2 3 4 5 6 7)))) 5)

17:12 clojurebot: (1 2 3 4 5 6 7)

17:15 Blaine: I wish the docs had examples under each function though

17:15 chouser: Blaine: not an uncommon desire. clojuredocs.org seems to be filling in pretty well there at the moment.

17:15 mefesto: Blaine: the mailing list was talking about this site: http://clojuredocs.org/

17:15 dpritchett: Blaine - clojuredocs.org and clojure-examples.appspot.com both have examples side by side with docstrings and source

17:17 Blaine: oh wow

17:17 that is slick

17:22 dpritchett: chouser how would you turn your (reductions + (range 1 10)) example into a lazy sequence?

17:25 chouser: ,(take 10 (reductions + (iterate inc 1)))

17:25 clojurebot: (1 3 6 10 15 21 28 36 45 55)

17:27 dpritchett: Is that O(n)? I can't figure out whether or not it is starting from 1 each time you pop one off

17:28 chouser: heh, it's not starting anything over. reductions is O(1) per item consumed

17:28 reductions is like reduce in that it feeds the result of one iteration into the next

17:29 dpritchett: ah, thanks

17:29 chouser: the difference is that instead of doing that eagerly and returning a single value at the end, it does it lazily, returning a lazy seq of each intermediate value

17:34 dpritchett: so the final value of the reduction is the same as the return value of reduce would've been?

17:34 final element in the reduction sequence that is

17:34 ,(last (take 10 (reductions + (iterate inc 1))))

17:34 clojurebot: 55

17:35 chouser: drewolson: right, but you'll have to rearrange that to keep reduce from running forever.

17:36 ,(reduce + (take 10 (iterate inc 1)))

17:36 clojurebot: 55

17:36 chouser: ,(last (reductions + (take 10 (iterate inc 1))))

17:36 clojurebot: 55

18:03 thunk: e

18:04 er, sorry. emacsarrhea.

18:05 kriyative: technomancy: thanks for the follow-up; the "deps" performance improved over time, which leads me to think it was either a connectivity issue or server load. I'll look into setting up a local maven proxy.

18:09 mabes|away: aside from removing it, how does one handle a circular dependency in clojure?

18:10 mabes: is there some way to do forward declaration (across namespaces)? I've tried opening up the ns and using declare but it seems like the real ns is then never compiled...

18:13 danlarkin: mabes: pet peeve of mine

18:13 you cannot have circular dependencies

18:14 unless you do it at runtime... which you really shouldn't

18:14 mabes: danlarkin: sigh.. I know it is usually a sign of coupling but it seems legit in this case

18:20 arohner: mabes: you can (with-ns 'foo (declare bar))

18:20 danlarkin: mabes: yep :-/ it's dumb

18:21 well, dumb is not right. I understand the reasons it's not supported. It's hard

18:21 it's just occasionally quite annoying

18:21 mabes: arohner: ah, I had tried in-ns and just ns.. let me try that.. in one case that may help, but I'm also running into issues with defrecord as well which I'm willing to bet there is no way around it..

18:21 arohner: mabes: with-ns is in contrib somewhere, don't remember off the top of my head

18:21 *don't remember where

18:22 mabes: arohner: I'll find it and try it out

18:24 danlarkin: ns-utils or something

18:26 mabes: it is in with-ns .. however, I am getting class not found errors with it

18:46 arohner: is this what you meant when you suggested with-ns? https://gist.github.com/485247/2b012c9f6403ff7c12402733cdfeb97d1ce1d0dd

18:47 arohner: see foo.core

18:47 arohner: I've tried that, in-ns, and simply ns, and I think danlarkin is right.. you can't really have circular deps in clojure (unless you do it during runtime as dan pointed out)

19:15 technomancy: anyone know what the plexus/components.xml file in jars is for?

19:29 Blaine: is there a clojure equivalent to something like this in haskell: function 1 = false; function 2 = true; function n = [...] ?

19:31 * Blaine isn't sure what that feature is called

19:32 Blaine: basically some pattern matching foo that determines the behavior of the function

19:32 or am I just going to have to use some big nasty if statements?

19:33 defn: im not following you

19:34 Blaine: defn: http://gist.github.com/485313

19:34 something like that

19:34 it doesn't work of course

19:34 but it'd be awesome if it did

19:35 haskell supports something like that

19:35 defn: so you want a specific condition for 1, 0, 2, and x?

19:35 Blaine: yeah, without a big mess of if statements

19:35 defn: use cond

19:35 eckroth: what is the simplest way to replace an element in a vector without knowing its position in the vector?

19:35 defn: or condp

19:35 * Blaine cracks open the docs

19:35 defn: Blaine: depending on what x is you sort of have the right idea

19:36 Blaine: sweet, that'll do

19:36 defn: (defn foo ([x] ...) ([x & xs] ...))

19:36 you can do that when the arity is different

19:36 but otherwise you need cond

19:37 Blaine: could one whip up a macro to implement that hair-brained idea?

19:37 defn: er uhh emmm, *thinking*

19:38 Blaine: it's a really nice feature I miss from haskell

19:38 it has a more mathy feel to it

19:38 defn: i guess you could write a macro i think

19:38 im not a macro aficionado

19:38 but that seems doable

19:38 Blaine: me either, unfortunately

19:41 also, what the heck is this? #<user$is_prime_QMARK___2 user$is_prime_QMARK___2@320cf66b> 101

19:41 technomancy: Blaine: http://github.com/technomancy/serializable-fn

19:42 (it's the compiled representation of a function)

19:43 Blaine: oh, freakin' sweet

19:44 eckroth: It's a bit counter-intuitive to me that (find map key) needs a key and returns the value; is there a function like (find' map val) that returns the key?

19:46 Blaine: technomancy: this may seem like a retarded question, but is there a way to install that nifty library globally?

19:47 other than specifying it as a dependency in my project.cls file

19:47 technomancy: Blaine: no, dependencies are done on a per-project basis

19:47 mabes: Blaine: when you use leinigen it uses maven under the hook and it caches it in your ~/.m2 dir

19:47 Blaine: this project may be what you are looking for though: http://github.com/liebke/cljr

19:48 Blaine: oooh yeah, that sounds exactly like what I'm looking for

19:48 something like rubygems or python's easy_install

19:50 mabes: technomancy: wow, I have been looking for something like serializable-fn forever, thanks!

19:52 dnolen_: eckroth: you could write a function that iterates over the whole map and find the matching key for a val. But that'll be slow. Might be wiser if your going to do that a lot to create a map that holds the reverse lookup. With Clojure's STM you can sleep well at night knowing that you can update both maps atomically.

19:52 eckroth: fwiw, my solution: (assoc this :vals (map #(if (= % special-value) (transform special-value) %)) (:vals this))

19:52 technomancy: mabes: cool

19:52 eckroth: dnolen_: ah a reverse-lookup map; good idea

19:54 technomancy: ,(let [m {:a :b :c :d}] (zipmap (vals m) (keys m)))

19:54 clojurebot: {:d :c, :b :a}

19:55 eckroth: technomancy: thanks I'll copy that

19:58 mmarczyk: technomancy: have you actually come across a jar with a plexus/components.xml file inside it?

19:58 technomancy: here's a description of what it's supposed to do: http://plexus.codehaus.org/guides/developer-guide/configuration/index.html

19:58 technomancy: mmarczyk: no... I am just trying to clean up some lein code that mentions it

19:59 thanks

19:59 mmarczyk: technomancy: but to my eyes, it's some inscrutable piece of Javaish weirdness

19:59 technomancy: also, thanks for the bump to my lein access level

19:59 technomancy: yeah, pretty much

20:00 mmarczyk: np... just remember the spiderman thing about great power/great responsibility =)

20:00 mmarczyk: sure... I'm still planning to have my code reviewed before inclusion, so you're not escaping pings when new stuff is ready :-P

20:05 blais: Is there a way to implement a constructor for a (deftype) if it is not AOT compiled?

20:05 mmarczyk: technomancy: this might be relevant too... just to get a muddier (= more realistic) picture of thiings: http://www.mail-archive.com/dev@maven.apache.org/msg74346.html

20:08 TakeV: So, if 1.2 in it's pre-release stage? I notice it hasn't been updating in a while.

20:08 mmarczyk: blais: it doesn't matter whether it's aot'd or not, (deftype Foo []) -> (Foo.) is available

20:09 TakeV: have you noticed the move to GitHub's "organisation" facility? -> http://github.com/clojure

20:09 Raynes: pong? (I think I missed a ping earlier...)

20:10 TakeV: mmarczyk: Ah, no.

20:11 Raynes: mmarczyk: I was wondering if you ever got around to fixing that quote bug in that monstrosity?

20:11 ;p

20:12 I'm actually using it in gotmilk, because it's not necessarily likely that anyone will try to escape quotes.

20:12 mmarczyk: Raynes: check out that SO answer, I've updated it recently :-)

20:12 Raynes: Cool. I'll check it out in a little while.

20:12 mmarczyk: Raynes: I've definitely not fixed the 'monstrosity' part, though

20:12 Raynes: It works though!

20:12 :D

20:12 And I didn't have to write it.

20:12 :)

20:12 mmarczyk: well, hopefully :-)

20:12 right. :-)

20:35 arohner: is there a fast way to "memset" a whole java array, rather than looping on aset?

20:36 hugod: technomancy: plexus/components.xml is used in maven plugins

20:37 technomancy: have a look in clojure-maven-plugin.jar

20:41 technomancy: hugod: any idea what this is about? http://github.com/technomancy/leiningen/blob/master/src/leiningen/uberjar.clj#L58

20:43 dnolen_: arohner: this might be helpful, http://www.searchenginecaffe.com/2007/03/how-to-quickly-reset-value-of-java.html

20:44 arohner: dnolen_: thanks

20:45 hugod: technomancy: at a higher level than that it is just skipping the component.xml's?

20:54 dnolen_: hmm

20:55 why can't you derive, underive, derive?

20:55 ,(derive ::bar ::foo)

20:55 clojurebot: nil

20:55 dnolen_: ,(underive ::bar ::foo)

20:55 clojurebot: nil

20:55 dnolen_: (,derive ::bar ::foo)

20:55 ,(derive ::bar ::foo)

20:55 clojurebot: java.lang.NullPointerException

20:56 dnolen_: clojurebot henceforth can no longer derive ::bar ::foo

21:00 pdk: how many other ways are there that we can break the bot then

21:01 id figure its smart enough to not let you put in obvious infinite loops

21:05 dnolen_: pdk: the point wasn't really about breaking the bot, I think that's a bug in Clojure's hierarchies

21:05 pdk: well

21:05 in spirit!

21:06 dnolen_: ,(derive ::y ::x)

21:06 clojurebot: java.lang.NullPointerException

21:06 dnolen_: huh actually the hierarchy is now borked

21:06 period

21:10 mmarczyk: dnolen_: got it -- there's a typo in underive

21:10 dnolen_: mmarczyk: sweet

21:10 mmarczyk: dnolen_: should be :parents, is: :parent

21:11 dnolen_: apparently underive is not among the most used functions in clojure.core ;-)

21:13 dnolen_: I'll make a ticket for that, though with my CA still not ack'd, it'll be without a patch...

21:14 dnolen_: mmarcyzk: it's a pretty bad bug and an easy fix, perhaps some else will move on that.

21:14 * dnolen_ wonders what rhickey can possibly cover in 20mins tomorrow at OSCON ...

21:16 hugod: technomancy: sorry, bed time for the kids. It looks like it is building a combined components.xml, out of the individual components.xml files.

21:17 'just collecting all the :component tags

21:18 putting the return of copy-entries into the result vector, and then ignoring it looks strange

21:20 mmarczyk: dnolen_: https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-underive-causes-breaking-in-the-resulting-hierarchy

21:22 dnolen_: mmarczyk: thx.

21:36 blais: mmarczyk: but can I override it and provide my own?

21:41 mmarczyk: blais: you can't do that with deftype regardless of whether you aot or not

21:56 blais: Does clojure have memq? What's the equivalent?

21:56 Arrg contains?, go tit.

22:10 mmarczyk: blais: contains? is *not* a memq equivalent

22:11 blais: in fact, there isn't one... you can build it yourself with some, though

22:11 ,(some #{:foo} [:bar :foo :baz])

22:11 clojurebot: :foo

22:12 mmarczyk: (notice how it only checks for the presence of the element in the collection; but you could use the general idea to recreate member/memq with help from other seq fns)

22:24 Lajla: ,(contains? 2 '(1 2 3 4 5))

22:24 clojurebot: false

22:24 Lajla: mmarczyk, how does contains work then?

22:24 ,(contains? '(1 2 3 4 5) 3)

22:24 clojurebot: false

22:25 Lajla: ,:phallic

22:25 clojurebot: :phallic

22:27 Lajla: ,(let [I + Worship 1 His 2 Shadow 3] (I Worship His Shadow))

22:27 clojurebot: 6

22:29 lancepantz: ,(contains? #{1 2 3 4 5} 3)

22:29 clojurebot: true

22:29 lancepantz: Lajla: it operates on sets

22:29 Lajla: lancepantz, ahhh

22:29 Then

22:29 Ahh

22:30 it gives a bool

22:30 not null/3

22:30 lancepantz: yes

22:30 Lajla: lancepantz, may I worship your shadow?

22:30 Your Divine Shadow

22:31 lancepantz: i hate tool

22:35 tomoj: ,(contains? [3 4 5] 2)

22:35 clojurebot: true

22:35 lancepantz: suppose one should say it operates on indexed seqs?

22:36 oh wait

22:36 tomoj: oh fuck

22:36 suddenly M-x slime-connect doesn't bring up a repl

22:36 lancepantz: ah, right, because 2 is the index of 5

22:36 blais: tomoj: you're using the old stuff.

22:36 tomoj: I think it operates on Associatives or something like that

22:36 old stuff?

22:37 blais: I like the new way better: you start your process (which runs swank).

22:37 Then use slime-connect to connect to it.

22:37 So much less confusion.

22:37 tomoj: isn't that what I said?

22:37 blais: oh right.

22:38 mmarczyk: what's the equivalent of memq/memberq then?

22:38 tomoj: I just recently upgraded slime and slime-repl, but have restarted emacs since then and verified that they still work :(

22:38 ,(some #{2} [1 2 3])

22:38 clojurebot: 2

22:38 blais: who

22:38 whoa

22:38 that sounds inefficient

22:39 come on... there just HAS to be a find operation, that just HAS to be supported.

22:39 tomoj: umm

22:39 blais: e.g. (find-first coll k) or soemthing

22:39 tomoj: were you expecting constant time?

22:39 blais: Nope.

22:39 tomoj: why does it sound inefficient, then?

22:40 blais: I took note of this while reading SHalloway's book, but of course the book is sitting at home now.

22:40 tomoj: there is a find-first, but it's not like that

22:40 blais: B/c what you wrote is more general, it's checking for inclusion of a set, i just want to check for a single element

22:40 "is this element present in the sequence"-p

22:40 tomoj: yes, (some #{element} sequence) is the idiomatic way

22:41 blais: Wow.

22:41 tomoj: and it's just as efficient as any other solution

22:41 blais: I just have t fall on my butt for a 1000 years.

22:41 Wait, I need to get back on my chair now.

22:41 (some #{2 3 4} seq) will have to build a temp. data structure, or be > O(N)

22:42 tomoj: huh?

22:42 blais: i'll go to the repl, I _must_ be missing something

22:42 tomoj: it just calls #{2 3 4} on successive elements of seq until it gets a truthy return value

22:42 i.e. it has found either 2, 3, or 4

22:43 (or it returns nil if it never does)

22:43 blais: Ah I seen, EITHER is the key

22:43 got it.

22:43 In any case, wouldn't it make sense to have memq too?

22:43 tomoj: I dunno

22:44 blais: Languages are so interesting.

22:44 tomoj: this is a FAQ

22:44 but if rich didn't have a good reason, he would've changed it by now

22:44 wonder what the reason is

22:46 blais: "Sequential lookup is not an important operation."

22:46 rhudson: As I recall, he's said that he really wants to encourage people to use the appropriate collection type for the operations expected on it.

22:47 blais: in the programming faq.

22:48 Well there is a "verb" in my mind that means "is-this-object-in-this-sequence"-p and I'll code myself one.

22:49 Languages have funny quirks; this is one. This is the equivalent of Python not having linked-lists as a native data type and people being fine with it.

22:50 tomoj: that doesn't sound right

22:50 blais: This is an interesting quirk though.

22:50 tomoj: which part?

22:50 tomoj: (memq foo bar) vs. (some #{foo} bar) seems trivial

22:50 lack of a certain native data type could be a big pain though

22:50 hiredman: ,(.contains '(foo) 'foo)

22:50 clojurebot: true

22:51 blais: It's a slightly different "verb.", the latter just happens to include the former.

22:52 tomoj: it does seem quirky, yeah

22:52 I wonder if rich has explained this somewhere on the ML

22:52 that .contains is already there might be good enough reason

22:54 blais: Ahh I see. .contains. See I don't know anything about java so these don't come to mind.

22:55 tomoj: good enough reason for rich, I should say

22:55 mmarczyk: blais: you can use (some #(= foo %) bar)

22:56 if you're worried about constructing a set

22:56 but you shouldn't be

22:56 blais: mmarczyk: yeah, that's closer to what I'm interested in. Thx.

22:56 tomoj: constructin a set seems cheaper than constructing a fn

22:57 mmarczyk: blais: I'm finding it hard to measure the difference in runtime between (some #{:foo} ...) and (some #(= :foo %) ...)

22:57 tomoj: oh, d'oh

22:57 blais: Wont' the fn be baked at compile time?

22:58 I can bet, maybe it's me being a bit of a purist.

22:58 tomoj: but you get a class for the fn, right?

22:58 mmarczyk: I wouldn't call that "purist"

22:58 tomoj: I didn't have slime-repl installed

22:59 mmarczyk: used to memq, perhaps ;-)

22:59 blais: tomoj: DK. Still a newbie, don't quite understand what's going on under the covers yet.

22:59 Maybe I should just play it idiomatic and stfu.

23:00 mmarczyk: there are valid reasons for #(= foo %) in some, though

23:00 if foo might be nil or false

23:01 blais: good point

23:01 mmarczyk: you'll want either that or {foo true} (a map)

23:01 etc.

23:01 tomoj: huh

23:01 never thought about that

23:01 mmarczyk: and I don't think anyone would complain about your code being nonidiomatic if you write #(= foo %) as a matter of preference

23:01 tomoj: I missed it, you mean like (let [x nil] (some #{x} aseq)) ?

23:01 mmarczyk: tomoj: yeah

23:02 tomoj: guess that is pretty rare

23:03 mmarczyk: blais: but there's no performance issue with (some #{foo} ...), except that often it is a better idea to use a data structure which better supports key lookups to begin with

23:04 tomoj: ,(doc some)

23:04 clojurebot: "([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)"

23:04 mmarczyk: thereby avoiding O(n) complexity

23:04 blais: mmarczyk: totally in your boat.

23:04 mmarczyk: blais: :-)

23:05 blais: Note that I'm using Clojure to avoid writing Java (:-)) and I'm having to deal with a lot of snafu'ed stuff.

23:05 (Not always my choice.)

23:05 mmarczyk: :-)

23:05 blais: I've been hacking some Clojure shtuff all day, I can't stop. Still sitting at the terminal at work and it's 11pm!

23:06 "The repl experience"

23:06 So addictive.

23:06 mmarczyk: indeed :-)

23:09 tomoj: hacks and glory await!

23:17 blais: How do you convert a keyword into its equivalent symbol?

23:17 arohner: ,(symbol (name :foo))

23:17 clojurebot: foo

23:18 blais: Aaa, nice. (name). Didn't know. Thx arohner.

23:32 tomoj: I think you need a macro

23:33 blais: tomoj: in order to eval within "." ?

23:33 this fails too:

23:33 (let [msg (VersionMessage.)] (set! (. msg (symbol (name :version_major))) 2))

23:33 (same story)

23:34 tomoj: I believe the problem is that you can't do (. msg (symbol "foo"))

23:34 needs to be (. msg foo)

23:34 don't have any objects with public fields handy to play around with

23:35 (or do I?)

23:35 talios: System.out :)

23:35 Its a class with a public field at least

23:37 tomoj: can you set! it?

23:37 it's final I think?

23:37 talios: yep

23:38 I do it often - reassign System.out to a be a Writer than delegates to log4j or something

23:38 blais: public and non-final

23:38 tomoj: hmm

23:38 blais: I can set it when I specify the attribute explcitly.

23:38 tomoj: I get an IllegalAccessError trying to set it to nil

23:39 blais: Hey, another one: is there a way to set the cdr to a cons cell not as a list, in CLojure?

23:39 mmarczyk: (.set (some #(= (.getName %) "foo") (.getFields VersionMessage)) "value")

23:39 ?

23:39 blais: nope, no classic cons cells

23:39 blais: e.g. in elisp: '(1 . 2)

23:39 I see.

23:40 mmarczyk: there are also setBoolean, setChar etc. methods for primitive types

23:40 blais: So I'd use something like `(~x ~y) instead of a cons cell

23:40 Which makes it tempting to use [x y] instead (but more costly)

23:40 mmarczyk: you'd use [x y]

23:40 and it is not costly

23:41 blais: Well it creates a vector underneath, no?

23:42 I mean, costly in the sense that vectors will pre-allocate a minimum size, vs. a list

23:42 mmarczyk: '(1 . 2) creates a cons cell underneath

23:42 blais: Or maybe it's not idiomatic to worry about such petty things :-)

23:42 tomoj: if it matters, your program is not doing anything else but this

23:43 I mean, it doesn't matter

23:43 blais: a single cons cell is cheap; not sure how that translates for vectors, but them being persistent, I'm guessing parts of them allocated in chunks of 16 or 32 entries.

23:43 mmarczyk: 32, yes

23:44 still, allocating Object[32] is not that expensive, unless you do it excessively often, in which case you might want to consider not using a data structure at all

23:44 tomoj: (list x y) > `(~x ~y) imo

23:45 mmarczyk: if you could pass those things around as function arguments, say

23:45 blais: mmarczyk: in a map where you're consing for every single element the thought of allocating a 32-entry array for each does worry me.

23:46 mmarczyk: of course you can make yourself a classic cons in 1.2, btw, (deftype LispCons [car cdr]) :-)

23:46 blais: It's all relative I guess.

23:46 hahahah

23:46 tomoj: but isn't your map bound by the number of fields in this object?

23:48 seancron: Hi everyone

23:48 I'm trying to read a csv file, and create a new dataset if the file doesn't exist using Incanter, but my code is behaving weirdly. Can anyone see what I'm doing wrong? http://gist.github.com/485530

23:48 mmarczyk: or if you want to take this a bit further, (defprotocol PLispCons (car [this]) (cdr [this]) (set-car! [this obj]) (set-cdr! [this obj])) (deftype LispCons [^{:volatile-mutable true} _car ^{:volatile-mutable true} _cdr] PLispCons (car [_] _car) (cdr [_] _cdr) (set-car! [this obj] (set! _car obj) this) (set-cdr! [this obj] (set! _cdr obj) this))

23:49 (car (set-car! (LispCons. 1 2) 5)) ; => 5

23:51 blais: anyway, don't optimise your code just yet ;-)

23:52 seancron: weirdly in what way?

23:53 seancron: mmarczyk: I get this error "java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$assoc" when I type "data" into the REPL

23:53 clojurebot: you mean clojure.main

23:56 defn: im having a hard time (use)ing a library i included as a dependency -- i check out clojure-hadoop*.jar in my lib/ directory, look at the pom and it says org.clojars.choas, artifactID: clojure-hadoop

23:56 however, i can't seem to load this...

23:56 ive tried all sorts of permutations with no luck

23:58 mmarczyk: seancron: could you see if the (dataset ...) form throws the same exception?

23:59 tomoj: defn: does (use 'clojure-hadoop.job) work?

Logging service provided by n01se.net