#clojure logs

2010-07-21

00:58BahmanHi all!
01:04technomancyhello!
01:15technomancywho's at oscon?
01:40cais2002is clojure.contrib.io now clojure.java.io ?
01:41mikemcais2002: yes: http://www.assembla.com/spaces/clojure/tickets/311
01:42cais2002thanks, mike
01:56konrI'm building an interface using QT Jambi - it *should* work on Windows, right?
02:08bortrebis 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 :)
02:15taliosHome time. I'm outta here.
02:16tomojbortreb: maybe it would be nicer to use a promise?
02:19RaynesConjure looks cool.
02:35bortrebtomoj: use a promise instead of a future?
02:35tomojinstead of an atom
02:35tomojsomething like this maybe? https://gist.github.com/7108adefc34f7ff2ea73
02:37raekbortreb: when a thread derefs a promise object, that thread will block until some other thread delivers a value
02:37tomojderefing a promise will block until it's delivered
02:37bortrebtomoj: but what if the other future tries to deliver to the promise before it's future-canceled? wouldn't that throw an exception?
02:37tomojso you can have the futures all compete to be first to deliver
02:37tomojyeah, but do you care?
02:37bortrebnope! :)
02:37tomojyou won't get the exception in your thread
02:37bortrebso i could wrap it in try or something
02:38tomoj(right?)
02:38tomojoh, maybe you would, I dunno
02:39tomojseems not
02:40raek,(let [p (promise)] (deliver p :foo) (deliver p :bar)]
02:40clojurebotUnmatched delimiter: ]
02:40raek,(let [p (promise)] (deliver p :foo) (deliver p :bar))
02:40clojurebotjava.lang.IllegalStateException: Multiple deliver calls to a promise
02:41tomoj,(let [p (promise) f (future (deliver p :foo) (deliver p :bar))] @p)
02:41clojurebot:foo
02:41tomojthe future blows up but doesn't matter, you've got the answer already :)
02:43bortrebthat's real nice, I did some timing and it seems to be a little faster than the loop method!
02:45tomojwon't be spinning on derefing to check ::void
02:46bortrebthank you so much!
02:50konrhow can I get a static field of a java object?
02:51konroh, of course
03:33neotykHi #clojure!
03:34neotykYesterday I got an issue that returning vector of bytes is bad design
03:35neotykThat I should return ByteArrayOutputStream
03:36neotykI have my doubts, BAOS is java object and you have to use additional tools to deal with it, while vec is native
03:36neotykplease advise.
03:37raekI guess that depends on what you are youing to do with it
03:38neotykit is http client, and way to transfer body, or body parts, back to caller
03:39neotykhttp://github.com/neotyk/ahc-clj/issues#issue/1
03:42KaaliHi 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.
03:45neotykKaali: have you tried macroexpand-1?
03:45KaaliYes, and it seems ok in my eyes.
03:45KaaliThe problem seems to be with the anonymous functions returned by transform, but they work fine when I run them in REPL.
03:46KaaliWith macroexpand, the map fn ~validators# expands to the key-fn map as it should.
03:49tomojneotyk: when i was looking at your library earlier today, I found it very odd that a vector of bytes was returned
03:51tomojyou're adding each byte one at a time onto that vector
03:51tomojwhich seems like it would be pretty slow
03:52tomojalso consider cases where you don't want the whole response in memory at once
03:53neotyktomoj: agree adding might be slow, disagree on whole resp in memory, as there is streaming api
03:54neotyktomoj: so you would also be in favor of ByteArrayOutputStream?
03:54tomojdunno about that
03:54tomojall I really want is a string :)
03:55neotykbut if you're getting png, string will not work
03:55tomojI'm not getting png
03:55neotyklol
03:55tomoj(not suggesting String)
03:56neotykhelper function to extract string from responses body?
03:56tomojI admit I did give up on your library when I saw the byte-at-a-time-into-vector thing
03:57neotyktomoj: ok, this convinced me, moving out from byte vector to outputstream
03:58neotyktomoj: would (string (:body @resp)) be user friendly enough?
03:58tomojI'd personally be happy with that
03:59neotyktomoj: can I come back to you for review round, once I have it fixed?
03:59tomojI don't think I'll be able to offer much advice.. ByteArrayOutputStream scares me too
03:59tomojmy only input is that vector of bytes seemed wrong :)
04:00tomojbut I'll be here
04:00neotykI can handle BAOS, would like you tell me if getting string is good :-)
04:01neotyktomoj: thanks for been honest and your input, it is appreciated.
04:01tomojhmm
04:01tomojByteArrayOutputStream can't be right, can it?
04:02tomojI mean... it's an output stream
04:03neotyktomoj: yes, should be ByteArrayInputStream
04:04tomojbtw, why'd you go with all-caps for GET/PUT/etc?
04:04tomojjust curious
04:04tomojto avoid clobbering stuff in core?
04:19neotyktomoj: it was named after http verbs, also is kind of counterpart of compojure
04:20neotykand partly because core defines get already
04:27rdsrHas anyone received the following error when cloning a repo
04:27rdsrerror: Unable to find bf17b72ec8320703015ba6509000cd20fed1fd0a under http://github.com/clojure/clojure-contrib.git
04:27rdsrCannot obtain needed tree bf17b72ec8320703015ba6509000cd20fed1fd0a
04:27bultersgday...
04:28tomojrdsr: nope
04:28tomojjust cloned clojure-contrib fresh, no problem
04:29tomojold git?
04:29rdsrgit version 1.6.2.2
04:33rdsrwhat's worse, its giving different errors on different retries, now it gives
04:33rdsrerror: Unable to find 3e3c10a5dfe5d0e8db0094324e55dd14ccb98f8d under http://github.com/clojure/clojure-contrib.git
04:33rdsrCannot obtain needed blob 3e3c10a5dfe5d0e8db0094324e55dd14ccb98f8d
04:33rdsrwhile processing commit e0080e640a2d9b79564a3fb6eb7ee36be1882901.
04:33rdsrfatal: Fetch failed.
04:37Raynesmmarczyk: Ping.
05:17opqdonutanyone else have problems with permgen filling up with clojure?
05:20naeumorning
05:21AWizzArdHi naeu
05:21naeuis there an equivalent of subvec for lists?
05:21naeuI'm playing around with a basic implementation of quicksort
05:21naeuand I'm putting in a vector, which is then being split with subvec and then concatenated with concat
05:22naeuhowever, concat appears to return a list
05:22naeuwhich then faile
05:22naeus/faile/fails
05:22naeuin the next recur as subvec needs a vector
05:22AWizzArdnaeu: you could use a composition of take and nthrest
05:23naeuAWizzArd: interesting, i've not seen nthrest before
05:52lozh,(vec (concat [1 2 3] [2 3 4]))
05:52clojurebot[1 2 3 2 3 4]
05:59cais2002how do I instruct leningen to ignore some files when creating the jar file?
06:09RaynesWhy does shuffle return a vector?
06:12lozhRaynes: I guess it depends on having a reasonably performant nth implementation
06:14RaynesThere should probably be a slower list option. :\
06:14RaynesIt's kind of screwing with me now.
06:17lozhshuffle just delegates to java.util.Collections.shuffle might be able to adapt it
06:18lozh,(seq (shuffle [1 2 3]))
06:18clojurebot(2 3 1)
06:23dsop,(clojure-version)
06:23clojurebot"1.2.0-master-SNAPSHOT"
06:24dsop,(partition-all 5 [104 104])
06:24clojurebot((104 104))
06:25lozhRaynes: shuffle-to-list @ http://clojure.pastebin.com/8rKpGYfW
06:26Raynes(into '() ..) also works. :p
08:35brweber2any ideas how to submit a ticket via assembla? There is no create button on the tickets page....
08:36raekbrweber2: if you aren't a contributor, you can create a ticket at the support tab: http://www.assembla.com/spaces/clojure/support/tickets
08:37raekI think you need to create an account, though
08:38raekbut being a watcher of the project is enough to create tickets
08:38brweber2raek Even on that page, there is no button/link to create a ticket, sounds like I need more permission?
08:39raekbrweber2: are you watching the space?
08:39raekthe new ticket is there once you have logged in
08:39brweber2raek Thought I was b/c it showed up in 'My Start Page' but turns out I wasn't! Fixed now, thanks.
08:39raeks/new ticket/new ticket button/
08:39sexpbotthe new ticket button is there once you have logged in
08:40raekI really wish rhickey would check the CA post box soon
08:41raekI have two really anoying bugs I want to fix
08:41opqdonuthow much does 1.2 break at the moment?
08:42opqdonutis its performance any better?
08:42RaynesI'm pretty sure it's source compatible with 1.1.
08:42opqdonutour code is spending 23% execution time in isInstance...
08:47lozhWhat are you using to get the performance profile?
08:50opqdonutyourkit
11:42lpetitHi,
11:48rubydiamondto buy kindle dx or not
11:49nDuffrubydiamond, I gave you my advice already.
11:50esjhey lpetit
11:50nDuffrubydiamond, ...if your goal is to read the Joy of Clojure or other content from Manning, it works well for the task.
11:50rubydiamondnDuff: heh
11:50rubydiamondyes
11:50rubydiamondnDuff: I had ordered it and it got returned back to shipper due to my absense
11:51technomancyit's great for public domain books as well; that's all I use mine for
11:51technomancybut you don't need the DX for that
11:51lpetitesj: hey !
11:52rubydiamondtechnomancy: what do you mean by you don't need DX for that
11:53technomancyrubydiamond: 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:54technomancybut for just reading text, there's no advantage of having the larger model
11:54lpetitccw 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:55rubydiamondtechnomancy: so do you recommend Kindle 2?
11:55technomancyrubydiamond: I recommend the Kindle 1 actually
11:55rubydiamondhaha .. ?
11:55rubydiamondtechnomancy: why?
11:55technomancyI hate how they dropped the analog place-ribbon
11:55technomancythey moved all the UI feedback to the screen, and the screen has a lousy refresh rate
11:56lpetitdon'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:56lpetit...first save
11:56technomancywith the Kindle 1, you could get faster feedback on what you were selecting that wasn't rate-limited by the crap refresh rate
11:56rubydiamondtechnomancy: do you have kindle 2 or 1?
11:56technomancyplus it had an analog scroll wheel instead of a d-pad, which is much nicer
11:56technomancyrubydiamond: I have the v1
11:56technomancyrubydiamond: plus it supports SD-cards
11:57technomancythe only advantage of the v2 is the 15%-ish faster refresh rate
11:57rubydiamondtechnomancy: okay.. but is Kindle 2 device worth buying?
11:58technomancyrubydiamond: sure, as long as you're not paying more for it than you'd pay for a v1
11:58technomancyjust don't buy any books from amazon
11:58rubydiamondtechnomancy: yeah.. also how many books you have read on your kindle 1?
11:58rubydiamondand how many tech books ? :p
11:58technomancyprobably 30-40 books; maybe 5 tech books
11:59technomancythe code samples in tech books are hard to read on the smaller screen
12:00rubydiamondaw.. but technomancy, do you think that it's bad thing?
12:04technomancydepends on the book... some rely on code more than others
12:05rubydiamondokay.
12:05rubydiamondtechnomancy: do you think kindle 2 is must have device?
12:06lpetitrubydiamond: 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:07rubydiamondhmm
12:07rubydiamondconfused..
12:07technomancyrubydiamond: it's great for people who like to read, especially those who like to read books that are out of copyright
12:07lpetithttp://en.wikipedia.org/wiki/Amazon_Kindle#Kindle_DX_International_2
12:07technomancyrubydiamond: I can't recommend the Amazon book store, but for reading content from feedbooks.com etc. it's absolutely fantastic.
12:08rubydiamond$379 > $189 I think I would go for Kindle 2 .. and not DX..
12:08technomancyand 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:09rubydiamondI am hoping that I would be able read tech pdfs I have (10+ in my pool)
12:09lpetitrubydiamond: 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:10technomancyrubydiamond: ah, actually I realized the Kindle 2 does have one other advantage over v1; it supports PDFs natively
12:10rubydiamondlpetit: I think same.. but as technomancy said .. less size is better for mobility
12:10technomancythe v1 has to go through a manual conversion process. so I don't know how PDFs look on v2
12:10rubydiamondtechnomancy: yeah
12:10rubydiamondtechnomancy: hmm
12:11technomancybut... there's still no way you could show some of the code samples without line-wraps
12:11rubydiamondthe only missing information I have is that how people find reading pdfs on Kindle 2
12:11rubydiamond:)
12:12lpetitrubydiamond, 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:13technomancyalso 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:14lpetitsure
12:14rubydiamondhttp://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:14lpetitand the kindle dx is approximately the same size and price of an iPad, hmmmm
12:15rubydiamondlpetit: yeah
12:15rubydiamondthat's what I am thinking bad about it .. I think i would never click 'confirm payment' button for dx
12:16rubydiamondlooks like I am going to buy Kindle 2
12:16lpetitrubydiamond: 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:17technomancythose photos make it look blurry; it's actually very crisp.
12:17rubydiamondlpetit: why when forced..
12:17lpetitrubydiamond: 'cause I'm still considering that they are poor replacements for POBs.
12:17lpetitPlain Old Books
12:18rubydiamondlpetit: that's true.. but when you are commuting or waiting state.. you don't have POB with you most of time
12:18dakronelpetit: if you travel with books, a kindle is amazing
12:18technomancylpetit: you should see how easy it is to get new content from feedbooks on the Kindle
12:18dakronetook mine to Europe, so much better than a suitcase full of books
12:18technomancylpetit: you think to yourself, "I want to read Sherlock Holmes" and 30 seconds later it's in your hand.
12:19rubydiamondI 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:19lpetitpain 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:19rubydiamonddakrone: kindle 2 or dx?
12:19dakronerubydiamond: kindle 2
12:20lpetitdakrone: granted, but still seens as a "plan B" for when travelling
12:20dakroneit's not a replacement for physical books, but it still quite nice
12:21dakroneput stuff on instapaper, put your instapaper on your kindle
12:21rubydiamonddakrone: how is for reading tech pdfs?
12:22lpetittechnomancy: 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:22dakronerubydiamond: 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:22dakroneif you have bad eyes or like large text, it will be harder
12:22lpetitrubydiamond: I almost always have a bag with my laptop and a book in it :-)
12:22rubydiamonddakrone: can't I just zoom text on pdf?
12:23lpetitrubydiamond: a good muscle exercise, for us who sit behind a desktop all day long :)
12:23technomancylpetit: I'm just saying I have read significantly more fiction since getting a kindle
12:23dakronerubydiamond: 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:23lpetittechnomancy: now that's interesting
12:24dakronebut that's only if you use a large text size
12:24rubydiamonddakrone: you mean I can't zoom for pdf .. that's not good news
12:24technomancyYMMV of course. =)
12:24dakronerubydiamond: no, you can zoom for pdf
12:24rubydiamonddakrone: then I can just zoom and read
12:24rubydiamond:)
12:24dakronerubydiamond: yep
12:25dakroneplus, super-basic web browsing for emergencies ;)
12:25lpetitI 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:25technomancylpetit: yes, the kindle is terrible for reference materials
12:25technomancyif it's something you want to come back to and page through
12:25lpetittechnomancy: forgive my bad english: terrible with the "very bad" meaning ?
12:26technomancyright
12:26rubydiamond:(
12:26rubydiamondthat's my use case .. reading lots of tech pdfs ..
12:27dakronerubydiamond: how do you normally study/read tech stuff?
12:27technomancyrubydiamond: well there are different kind of tech books
12:27dakronedo you take notes? highlight?
12:27technomancysome are meant for a linear read, while others are meant for a more "cookbook" style of reading
12:27rubydiamonddakrone: I normal read physical tech books.. I also read pdfs on macbook pro
12:27lpetitdo you have a more "visual" than "auditive" memory ?
12:28rubydiamondI have purchased 10+ tech books in last year .. I never completed reading my tech pdfs..
12:28lpetitthat's a sign ...
12:30dakronerubydiamond: do you normally just read through them, or do you take notes and/or highlight as you go?
12:30dakronedo you use margins in books?
12:30lpetitnot trying to prevent you from consuming, but setting the expectations at the right level helps not being disappointed
12:31dakroneif 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:33rubydiamondgot disconnected..
12:33rubydiamonddid I miss something
12:34dakronerubydiamond: 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:34rubydiamonddakrone: yea it would definitely help
12:35dakronerubydiamond: do you have a PDF you want to see?
12:35rubydiamondyou can use practical clojure / joy of clojure
12:36technomancyI wonder how Practical Clojure would sell if they had actually promoted it before it came out.
12:37rubydiamondI am wondering how Jay Fields and Uncle Bob are liking and loving Clojure
12:37rubydiamondboth are icons..
12:37dakronerubydiamond: the only clojure book I own is _Programming Clojure_, that okay?
12:37rubydiamonddakrone: yeah okay..
12:37rubydiamond:)
12:40lpetitrubydiamond: First time I'm hearing of Jay Fields, that okay ? :)
12:41rubydiamondlpetit: not very okay.. if you are online for last 5-6 years and following programming things..
12:41rubydiamondlpetit: http://blog.jayfields.com/
12:41lpetit'cmon
12:42slyruswhat's the conventional leiningen layout for test code myproject/test or myproject/src/test?
12:43rubydiamonddakrone: waiting for your pic.. :)
12:44tomojanyone successfully installed clojure-test-mode from elpa lately?
12:44dakronerubydiamond: takes time, hold on :)
12:44technomancytomoj: there are problems using the stock package.el; try my patched version: http://p.hagelb.org/package.el
12:44tomojtechnomancy: thanks
12:44lpetitmust leave, bye guys
12:48dakronerubydiamond: http://imgur.com/oYBvd.jpg http://imgur.com/Z6o01.jpg http://imgur.com/GsG6N.jpg http://imgur.com/Vqd9n.jpg
12:48Lajla,(let [large + black 1 phallic 2 cock 3] (large black phallic cock))
12:48clojurebot6
12:49dakroneexcuse the poor quality, it's a phone camera
12:49technomancydammit, what happened to my /ignore list
12:49rubydiamonddakrone: checking
12:52rubydiamonddakrone: have you zoomed the text in later screenshots
12:52dakronerubydiamond: yea, 150%
12:53rubydiamonddakrone: okay..
12:53rubydiamondtext looks good when zoomed... but not for 100% size
12:53rubydiamondbut that's fine..
12:54dakroneyea, 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:55rubydiamonddakrone: okay..
12:55dakroneanyway, we've hijacked the #clojure room for long enough probably, feel free to pm me if you have any other questions :)
12:55rubydiamonddakrone: thanks for the help.. it would definitely help me
12:56rubydiamonddakrone: yeah.. lets stop talking about kindle.. and i am ordering one .. kindle 2
12:56rubydiamondtechnomancy, lpetit thanks guys.. gonna order one
12:57nDuffrubydiamond, ...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:59technomancyit's pretty trivial to translate between .epub and .mobi though
12:59technomancythey're both HTML subsets
13:00rubydiamondtechnomancy: yeah right ..but code snippets would lose formatting
13:03TakeVWhat 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:05rysload-file at a guess
13:05TakeV(doc load-file)
13:05clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
13:05pdk(doc alias)
13:05clojurebot"([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:06TakeVHmm, alright, thanks.
13:07tomojTakeV: don't do that, though
13:07tomoj:)
13:09TakeVtomoj: Why not?
13:09tomojwell, maybe there could be some situation in which that would be a good thing to do
13:10cmiles74TakeV: I think you want to use the "ns" macro.
13:10tomojif 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:11tomojor at least jar up whatever's in ~/libraries/clojure and put it on the classpath for ~/cljapp
13:11cmiles74Something line (ns takev.cljapp (:use [clojure.contrib.logging]))
13:14tomojif 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:14tomojand probably other terrible things will happen
13:14polypus~ping
13:14clojurebotPONG!
13:17TakeVtomoj: 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:19tomojlein 1.2.0 can do that
13:20tomojit may actually be easier for you right now to use some evil load-file stuff for development
13:20tomojjust get rid of it eventually :)
13:20TakeVI'd rather do it right than do it easy, but if they are one in the same then I'll do that. :)
13:21rhudsonDon't use and require work with source files as well as compiled?
13:21tomojbut these source files aren't on the classpath
13:21tomoj(unless using lein's new checkouts thingy..)
13:21TakeVrhudson: I'm just not sure how to get them to work, when they are not in the project folder.
13:21rhudsonThe containing directory would have to be, sure
13:24rhudsonIf you have ~/mylib/pkg1/src1.clj, and src1.clj starts with (ns pkg1.src1), and ~/mylib is on your classpath
13:25tomojhmm, 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:25tomojwonder if that could cause trouble
13:27TakeVHmm, actually, wonder if Clojars would be a good way to handle that. Lein would take care of the busywork.
13:27tomojhow would clojars help?
13:29TakeVtomoj: Lein's deps function would pull the library when needed.
13:30technomancytomoj: the copy in checkouts will take precedence
13:30tomojI guess clojure jars are special in that having multiples can break things?
13:31technomancyshouldn't be
13:31tomojoh, maybe it's just that when you have multiples they might end up in the wrong order on the classpath
13:31technomancythere are ways to search the classpath beyond the first hit for a given file, but use and require will only honor the first.
13:31technomancyyes, ordering is important.
13:31tomojI meant clojure jars as in, clojure.jar and clojure-contrib.jar
13:32tomojTakeV: yeah, but you'd have to recompile and push every time you made a change
13:32tomojyou 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:32TakeVtomoj: Yeah, but that is still easier than manually copying the jar to each project that uses it when I make a change.
13:33tomojah, right
13:33TakeVHmm, how do checkout deps work? I'm not familiar with them.
13:33tomoj`lein install` in the changed project then `lein deps` in the other will do that for you
13:33tomoj(no need for clojars)
13:34TakeVDeps can grab a jar from, say, ~/libraries/clojure?
13:34tomoj`lein install` in your ~/libraries/clojure/foo lein project will install the foo jar into your local maven repo
13:35tomojthen `lein deps` in the other project uses that one
13:35technomancyTakeV: create a "checkouts" dir in your project root, and then symlink the checkout of the dependency into that directory
13:35TakeVThe checkout being the jar?
13:39BahmanHi all!
13:40technomancyTakeV: no, the root directory of the project you're depending on
13:40TakeVAh, alright. That makes sense.
13:40TakeVThank you.
13:43matt3402382Hi! 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:46tomojhmm, do you have to visit the file in emacs through the symlink?
13:46tomojguess I'll try it out..
13:51tomojsomehow it works, awesome
13:54matt3402382anyone 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:08dakronematt3402382: I would try the #compojure room and see if anyone there knows
14:10matt3402382dakrone: ok thanks!
14:23cemerickhrm, 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:23cemerick...even if the only evaluated form is a new protocol definition :-/
14:41yacinis there a way to make lein compile-java have the -Xlint:deprecation option?
14:47lancepantzyacin: i don't know, but i would expect it to respect the JAVA_OPTS env
14:48dpritchettSilly 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:49dpritchettI'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:51jmattdpritchett: Look at the source is probably the simplest way to decide which function to use.
14:54yacinlancepantz: huh, doesn't seem to work so hot
14:54yacin25402 clj-ml-3.7.1:upstream!? % lein compile-java 2010-07-21 14:53:01 ynadji ttys012
14:54yacinUnrecognized option: -Xlint:all
14:54yacinCould not create the Java virtual machine.
14:55jmattdpritchett: (use 'clojure.contrib.repl-utils) then you can do (source apply) etc
14:55lancepantzyacin: not sure man, i actually don't use lein, but i'm surprised that doesn't work
14:56yacinyou and me both
14:56dpritchettthanks jmatt! I'm looking at map, reduce, and apply on clojuredocs.org right now
14:59hugodcemerick: same problem as #371?
15:00jmattdpritchett: 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:00cemerickhugod: Seems like it, yes
15:01dpritchettjmatt: maybe i should dig sicp out again tonight. i'm not too far through it yet
15:06kriyativeHi 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:07technomancykriyative: the more snapshot versions you have, the slower lein deps runs.
15:08kriyativetechnomancy: I'm not intentionally specifying any snapshot versions i.e, all the dependencies are to stable versions
15:09technomancyhmm; in that case future runs should be fast
15:09technomancythe first run will always be slow
15:10kriyativeok, 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:14kriyativetechnomancy: 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:15kriyativesorry to badger with these questions, but I'm new to maven and leiningen. I really like leiningen but maven ... not so much :)
16:04erikcw1I 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:12tomojerikcw1: hooks
16:12tomojI assume
16:13erikcw1tomoj: I guess I'll have to read up on that. Wasn't sure if anyone else had run up against the same issue
16:13tomojthere's a bit of info in the PLUGINS.md
16:17bhenrycan 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:18bhenry(get-files dir) returns all file objects within that dir and its subdirs.
16:19bhenryfor 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:20Chousukebhenry: you could combine the regexes into a single one
16:21bhenryi'm not so good with regexes. plus how do i make it match JPG as well?
16:21tomojclojurebot: regex?
16:21clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
16:22Chousukebhenry: I think there are some special regex thingies
16:22mefestobhenry: i think this would work: #"[.](jpg|png|gif)$"
16:23Chousukehmm
16:23bhenrymefesto: i'll try it out
16:24Chousukeput a ?i at the front of the regexp to make it case-insensitive
16:26blaisIs there a way to escape a newline char in a multi-line string literal in clojure?
16:26blaise.g. using '\' at the EOL does not work
16:26tomojChousuke: how? thought we couldn't do that in java
16:27bhenrymefesto that worked! thank you.
16:27chouserblais: as in you want a newline in your code, but not in the resulting string?
16:27mefesto,(re-find #"(?i)[.](png|jpg|gif)$" "test.JPG")
16:27clojurebot[".JPG" "JPG"]
16:27tomojoh, in parens?
16:27blaischouser: Yes.
16:27Chousuketomoj: I got that from the JVM docs :/
16:28blaisI 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:28chouserblais: yeah, I don't think there's a way to do that in a single string literal
16:28blaistomoj: 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:29blaischouser: thx.
16:29bhenrymefesto: thanks again! i couldn't get chousuke's suggestion to work until you posted the correct syntax.
16:29mefestonp, lemme pass a thanks to chousuke since I didn't even know about (?i) till he said it :)
16:38blaisAn emacs / swank question: when I eval (println "blablabla") output goes to my slime repl buffer.
16:39blaisHowever, when I eval (do (for [x [1 2 3 4]] (println x))), output goes to my minibuffer.
16:39blaisAny idea why?
16:40mefestoblais: where does a (doall (for [x [1 2 3 4]] (println x))) go?
16:41blaisAh.
16:41blaisTo the repl
16:42blaisI suppose the code that forces the evaluation of the seq overrides the out stream somehow.
16:42blaismefesto: Thx.
16:42technomancykriyative: sorry, was at lunch. yes, a local maven proxy will help.
16:46blaisWhat is the best way to (read) and entire file's definition and return the values of all the top-level expressions contained therein?
16:48chouserblais: '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:49fualobas
16:49blaischouser: 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:49fualoer, sorry, wrong window!
16:50chouserblais: if you can require the input be a single expression (perhaps a literal map) that would simplify things.
16:50blaisRiiight.
16:51dpritchettI'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:51dpritchettmy 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:53dpritchettlooks like I have a superfluous ) at the end, sorry. i copied this from my definition of a lazy sequence for triangle numbers
16:53clojurebotgender is irrelevant
16:53blaischouser: here's what I did: http://pastebin.com/pm10kn8d
16:53blaischouser: (I'm a clj newbie, any comments welcome)
16:53chouserdpritchett: perhaps (take 10 (map first (iterate (fn [[t n]] [(+ t n) (inc n)]) [1 2])))
16:54LauJensenAny Clojure-Maven fundamentalists in the house tonight?
16:55chouserdpritchett: ooh, I think I found a nice solution using 'reductions'
16:56blaisI'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:56chouserblais: read-expressions looks solid. I suspect there may be a better formulation of read-eval-expr
16:57chouserhm, actually you should probably close the reader too when you're done. maybe use 'with-open'
16:59chouserblais: read-eval-expr has a non-tail recursion that's a bit worrisome. perhaps use 'repeatedly' insteada?
17:00mefestois it possible to create a temp namespace, load the file, then inspect that ns using ns-publics or something?
17:00dpritchettyour rewrite of my triangle function makes sense chouser, curious about your reduction solution
17:00chousermefesto: yeah, I've done that, but it's probably not ideal.
17:00chouser,(reductions + (range 1 10))
17:00clojurebot(1 3 6 10 15 21 28 36 45)
17:01chousermefesto: you'd lose the order of things (if that matters), plus it's simply not pure functional anymore.
17:01fualothis 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:01areteis there a canonical way of defining a root binding that preserves the bound value across a compile-and-load cycle?
17:01areteor does one just use an if bound?
17:02chouserfualo: depends on what you're doing. not automatically a code small at all.
17:03chouserarete: defonce
17:03aretehah go figure, thanks =)
17:05erikcw1How 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:05technomancyerikcw1: keywords with spaces in them aren't really kosher
17:06technomancyit's an open question whether (keyword "test this") should even work
17:06chousererikcw1: that's not a readable keyword. the fact that the 'keyword' function lets you make them is a bit of a bug.
17:06chouserhttp://www.assembla.com/spaces/clojure/tickets/17
17:06fualothanks chouser!
17:07technomancyoh hey, there it is
17:07chouserfualo: you can insert stuff in the middle of a sorted map, for example.
17:07chouserfualo: or in the middle of a sequence
17:08fualochouser: 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:08fualothis is just early understanding stuff - nothing practical
17:08fualo(for me)
17:08chouserwell -- I would generally try to avoid doing it in a list.
17:09fualochouser: ah, ok. It would be O(n) worst unvoidably, no?
17:09chouserfualo: right
17:09fualothanks
17:09chouserfualo: for something like a priority queue, a sorted map works well
17:10fualoright, right
17:10fualoawesome thanks
17:10fualoI have the MEAP version of your book btw, great work; I quite like it
17:10chouserif 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:10chouserfualo: ah great, thanks!
17:11BlaineI'm using clojure for the first time, it is freakin' sweet
17:12dpritchettHere's an ugly attempt, not sure you'd want to keep it but:
17:12dpritchett,((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:12clojurebot(1 2 3 4 5 6 7)
17:15BlaineI wish the docs had examples under each function though
17:15chouserBlaine: not an uncommon desire. clojuredocs.org seems to be filling in pretty well there at the moment.
17:15mefestoBlaine: the mailing list was talking about this site: http://clojuredocs.org/
17:15dpritchettBlaine - clojuredocs.org and clojure-examples.appspot.com both have examples side by side with docstrings and source
17:17Blaineoh wow
17:17Blainethat is slick
17:22dpritchettchouser how would you turn your (reductions + (range 1 10)) example into a lazy sequence?
17:25chouser,(take 10 (reductions + (iterate inc 1)))
17:25clojurebot(1 3 6 10 15 21 28 36 45 55)
17:27dpritchettIs that O(n)? I can't figure out whether or not it is starting from 1 each time you pop one off
17:28chouserheh, it's not starting anything over. reductions is O(1) per item consumed
17:28chouserreductions is like reduce in that it feeds the result of one iteration into the next
17:29dpritchettah, thanks
17:29chouserthe 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:34dpritchettso the final value of the reduction is the same as the return value of reduce would've been?
17:34dpritchettfinal element in the reduction sequence that is
17:34dpritchett,(last (take 10 (reductions + (iterate inc 1))))
17:34clojurebot55
17:35chouserdrewolson: right, but you'll have to rearrange that to keep reduce from running forever.
17:36chouser,(reduce + (take 10 (iterate inc 1)))
17:36clojurebot55
17:36chouser,(last (reductions + (take 10 (iterate inc 1))))
17:36clojurebot55
18:03thunke
18:04thunker, sorry. emacsarrhea.
18:05kriyativetechnomancy: 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:09mabes|awayaside from removing it, how does one handle a circular dependency in clojure?
18:10mabesis 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:13danlarkinmabes: pet peeve of mine
18:13danlarkinyou cannot have circular dependencies
18:14danlarkinunless you do it at runtime... which you really shouldn't
18:14mabesdanlarkin: sigh.. I know it is usually a sign of coupling but it seems legit in this case
18:20arohnermabes: you can (with-ns 'foo (declare bar))
18:20danlarkinmabes: yep :-/ it's dumb
18:21danlarkinwell, dumb is not right. I understand the reasons it's not supported. It's hard
18:21danlarkinit's just occasionally quite annoying
18:21mabesarohner: 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:21arohnermabes: with-ns is in contrib somewhere, don't remember off the top of my head
18:21arohner*don't remember where
18:22mabesarohner: I'll find it and try it out
18:24danlarkinns-utils or something
18:26mabesit is in with-ns .. however, I am getting class not found errors with it
18:46mabesarohner: is this what you meant when you suggested with-ns? https://gist.github.com/485247/2b012c9f6403ff7c12402733cdfeb97d1ce1d0dd
18:47mabesarohner: see foo.core
18:47mabesarohner: 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:15technomancyanyone know what the plexus/components.xml file in jars is for?
19:29Blaineis there a clojure equivalent to something like this in haskell: function 1 = false; function 2 = true; function n = [...] ?
19:32Blainebasically some pattern matching foo that determines the behavior of the function
19:32Blaineor am I just going to have to use some big nasty if statements?
19:33defnim not following you
19:34Blainedefn: http://gist.github.com/485313
19:34Blainesomething like that
19:34Blaineit doesn't work of course
19:34Blainebut it'd be awesome if it did
19:35Blainehaskell supports something like that
19:35defnso you want a specific condition for 1, 0, 2, and x?
19:35Blaineyeah, without a big mess of if statements
19:35defnuse cond
19:35eckrothwhat is the simplest way to replace an element in a vector without knowing its position in the vector?
19:35defnor condp
19:35defnBlaine: depending on what x is you sort of have the right idea
19:36Blainesweet, that'll do
19:36defn(defn foo ([x] ...) ([x & xs] ...))
19:36defnyou can do that when the arity is different
19:36defnbut otherwise you need cond
19:37Blainecould one whip up a macro to implement that hair-brained idea?
19:37defner uhh emmm, *thinking*
19:38Blaineit's a really nice feature I miss from haskell
19:38Blaineit has a more mathy feel to it
19:38defni guess you could write a macro i think
19:38defnim not a macro aficionado
19:38defnbut that seems doable
19:38Blaineme either, unfortunately
19:41Blainealso, what the heck is this? #<user$is_prime_QMARK___2 user$is_prime_QMARK___2@320cf66b> 101
19:41technomancyBlaine: http://github.com/technomancy/serializable-fn
19:42technomancy(it's the compiled representation of a function)
19:43Blaineoh, freakin' sweet
19:44eckrothIt'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:46Blainetechnomancy: this may seem like a retarded question, but is there a way to install that nifty library globally?
19:47Blaineother than specifying it as a dependency in my project.cls file
19:47technomancyBlaine: no, dependencies are done on a per-project basis
19:47mabesBlaine: when you use leinigen it uses maven under the hook and it caches it in your ~/.m2 dir
19:47mabesBlaine: this project may be what you are looking for though: http://github.com/liebke/cljr
19:48Blaineoooh yeah, that sounds exactly like what I'm looking for
19:48Blainesomething like rubygems or python's easy_install
19:50mabestechnomancy: wow, I have been looking for something like serializable-fn forever, thanks!
19:52dnolen_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:52eckrothfwiw, my solution: (assoc this :vals (map #(if (= % special-value) (transform special-value) %)) (:vals this))
19:52technomancymabes: cool
19:52eckrothdnolen_: ah a reverse-lookup map; good idea
19:54technomancy,(let [m {:a :b :c :d}] (zipmap (vals m) (keys m)))
19:54clojurebot{:d :c, :b :a}
19:55eckrothtechnomancy: thanks I'll copy that
19:58mmarczyktechnomancy: have you actually come across a jar with a plexus/components.xml file inside it?
19:58mmarczyktechnomancy: here's a description of what it's supposed to do: http://plexus.codehaus.org/guides/developer-guide/configuration/index.html
19:58technomancymmarczyk: no... I am just trying to clean up some lein code that mentions it
19:59technomancythanks
19:59mmarczyktechnomancy: but to my eyes, it's some inscrutable piece of Javaish weirdness
19:59mmarczyktechnomancy: also, thanks for the bump to my lein access level
19:59technomancyyeah, pretty much
20:00technomancymmarczyk: np... just remember the spiderman thing about great power/great responsibility =)
20:00mmarczyksure... I'm still planning to have my code reviewed before inclusion, so you're not escaping pings when new stuff is ready :-P
20:05blaisIs there a way to implement a constructor for a (deftype) if it is not AOT compiled?
20:05mmarczyktechnomancy: 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:08TakeVSo, if 1.2 in it's pre-release stage? I notice it hasn't been updating in a while.
20:08mmarczykblais: it doesn't matter whether it's aot'd or not, (deftype Foo []) -> (Foo.) is available
20:09mmarczykTakeV: have you noticed the move to GitHub's "organisation" facility? -> http://github.com/clojure
20:09mmarczykRaynes: pong? (I think I missed a ping earlier...)
20:10TakeVmmarczyk: Ah, no.
20:11Raynesmmarczyk: I was wondering if you ever got around to fixing that quote bug in that monstrosity?
20:11Raynes;p
20:12RaynesI'm actually using it in gotmilk, because it's not necessarily likely that anyone will try to escape quotes.
20:12mmarczykRaynes: check out that SO answer, I've updated it recently :-)
20:12RaynesCool. I'll check it out in a little while.
20:12mmarczykRaynes: I've definitely not fixed the 'monstrosity' part, though
20:12RaynesIt works though!
20:12Raynes:D
20:12RaynesAnd I didn't have to write it.
20:12Raynes:)
20:12mmarczykwell, hopefully :-)
20:12mmarczykright. :-)
20:35arohneris there a fast way to "memset" a whole java array, rather than looping on aset?
20:36hugodtechnomancy: plexus/components.xml is used in maven plugins
20:37hugodtechnomancy: have a look in clojure-maven-plugin.jar
20:41technomancyhugod: any idea what this is about? http://github.com/technomancy/leiningen/blob/master/src/leiningen/uberjar.clj#L58
20:43dnolen_arohner: this might be helpful, http://www.searchenginecaffe.com/2007/03/how-to-quickly-reset-value-of-java.html
20:44arohnerdnolen_: thanks
20:45hugodtechnomancy: at a higher level than that it is just skipping the component.xml's?
20:54dnolen_hmm
20:55dnolen_why can't you derive, underive, derive?
20:55dnolen_,(derive ::bar ::foo)
20:55clojurebotnil
20:55dnolen_,(underive ::bar ::foo)
20:55clojurebotnil
20:55dnolen_(,derive ::bar ::foo)
20:55dnolen_,(derive ::bar ::foo)
20:55clojurebotjava.lang.NullPointerException
20:56dnolen_clojurebot henceforth can no longer derive ::bar ::foo
21:00pdkhow many other ways are there that we can break the bot then
21:01pdkid figure its smart enough to not let you put in obvious infinite loops
21:05dnolen_pdk: the point wasn't really about breaking the bot, I think that's a bug in Clojure's hierarchies
21:05pdkwell
21:05pdkin spirit!
21:06dnolen_,(derive ::y ::x)
21:06clojurebotjava.lang.NullPointerException
21:06dnolen_huh actually the hierarchy is now borked
21:06dnolen_period
21:10mmarczykdnolen_: got it -- there's a typo in underive
21:10dnolen_mmarczyk: sweet
21:10mmarczykdnolen_: should be :parents, is: :parent
21:11mmarczykdnolen_: apparently underive is not among the most used functions in clojure.core ;-)
21:13mmarczykdnolen_: I'll make a ticket for that, though with my CA still not ack'd, it'll be without a patch...
21:14dnolen_mmarcyzk: it's a pretty bad bug and an easy fix, perhaps some else will move on that.
21:16hugodtechnomancy: sorry, bed time for the kids. It looks like it is building a combined components.xml, out of the individual components.xml files.
21:17hugod'just collecting all the :component tags
21:18hugodputting the return of copy-entries into the result vector, and then ignoring it looks strange
21:20mmarczykdnolen_: https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-underive-causes-breaking-in-the-resulting-hierarchy
21:22dnolen_mmarczyk: thx.
21:36blaismmarczyk: but can I override it and provide my own?
21:41mmarczykblais: you can't do that with deftype regardless of whether you aot or not
21:56blaisDoes clojure have memq? What's the equivalent?
21:56blaisArrg contains?, go tit.
22:10mmarczykblais: contains? is *not* a memq equivalent
22:11mmarczykblais: in fact, there isn't one... you can build it yourself with some, though
22:11mmarczyk,(some #{:foo} [:bar :foo :baz])
22:11clojurebot:foo
22:12mmarczyk(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:24Lajla,(contains? 2 '(1 2 3 4 5))
22:24clojurebotfalse
22:24Lajlammarczyk, how does contains work then?
22:24Lajla,(contains? '(1 2 3 4 5) 3)
22:24clojurebotfalse
22:25Lajla,:phallic
22:25clojurebot:phallic
22:27Lajla,(let [I + Worship 1 His 2 Shadow 3] (I Worship His Shadow))
22:27clojurebot6
22:29lancepantz,(contains? #{1 2 3 4 5} 3)
22:29clojurebottrue
22:29lancepantzLajla: it operates on sets
22:29Lajlalancepantz, ahhh
22:29LajlaThen
22:29LajlaAhh
22:30Lajlait gives a bool
22:30Lajlanot null/3
22:30lancepantzyes
22:30Lajlalancepantz, may I worship your shadow?
22:30LajlaYour Divine Shadow
22:31lancepantzi hate tool
22:35tomoj,(contains? [3 4 5] 2)
22:35clojurebottrue
22:35lancepantzsuppose one should say it operates on indexed seqs?
22:36lancepantzoh wait
22:36tomojoh fuck
22:36tomojsuddenly M-x slime-connect doesn't bring up a repl
22:36lancepantzah, right, because 2 is the index of 5
22:36blaistomoj: you're using the old stuff.
22:36tomojI think it operates on Associatives or something like that
22:36tomojold stuff?
22:37blaisI like the new way better: you start your process (which runs swank).
22:37blaisThen use slime-connect to connect to it.
22:37blaisSo much less confusion.
22:37tomojisn't that what I said?
22:37blaisoh right.
22:38blaismmarczyk: what's the equivalent of memq/memberq then?
22:38tomojI just recently upgraded slime and slime-repl, but have restarted emacs since then and verified that they still work :(
22:38tomoj,(some #{2} [1 2 3])
22:38clojurebot2
22:38blaiswho
22:38blaiswhoa
22:38blaisthat sounds inefficient
22:39blaiscome on... there just HAS to be a find operation, that just HAS to be supported.
22:39tomojumm
22:39blaise.g. (find-first coll k) or soemthing
22:39tomojwere you expecting constant time?
22:39blaisNope.
22:39tomojwhy does it sound inefficient, then?
22:40blaisI took note of this while reading SHalloway's book, but of course the book is sitting at home now.
22:40tomojthere is a find-first, but it's not like that
22:40blaisB/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:40blais"is this element present in the sequence"-p
22:40tomojyes, (some #{element} sequence) is the idiomatic way
22:41blaisWow.
22:41tomojand it's just as efficient as any other solution
22:41blaisI just have t fall on my butt for a 1000 years.
22:41blaisWait, I need to get back on my chair now.
22:41blais(some #{2 3 4} seq) will have to build a temp. data structure, or be > O(N)
22:42tomojhuh?
22:42blaisi'll go to the repl, I _must_ be missing something
22:42tomojit just calls #{2 3 4} on successive elements of seq until it gets a truthy return value
22:42tomoji.e. it has found either 2, 3, or 4
22:43tomoj(or it returns nil if it never does)
22:43blaisAh I seen, EITHER is the key
22:43blaisgot it.
22:43blaisIn any case, wouldn't it make sense to have memq too?
22:43tomojI dunno
22:44blaisLanguages are so interesting.
22:44tomojthis is a FAQ
22:44tomojbut if rich didn't have a good reason, he would've changed it by now
22:44tomojwonder what the reason is
22:46blais"Sequential lookup is not an important operation."
22:46rhudsonAs 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:47blaisin the programming faq.
22:48blaisWell there is a "verb" in my mind that means "is-this-object-in-this-sequence"-p and I'll code myself one.
22:49blaisLanguages 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:50tomojthat doesn't sound right
22:50blaisThis is an interesting quirk though.
22:50blaistomoj: which part?
22:50tomoj(memq foo bar) vs. (some #{foo} bar) seems trivial
22:50tomojlack of a certain native data type could be a big pain though
22:50hiredman,(.contains '(foo) 'foo)
22:50clojurebottrue
22:51blaisIt's a slightly different "verb.", the latter just happens to include the former.
22:52tomojit does seem quirky, yeah
22:52tomojI wonder if rich has explained this somewhere on the ML
22:52tomojthat .contains is already there might be good enough reason
22:54blaisAhh I see. .contains. See I don't know anything about java so these don't come to mind.
22:55tomojgood enough reason for rich, I should say
22:55mmarczykblais: you can use (some #(= foo %) bar)
22:56mmarczykif you're worried about constructing a set
22:56mmarczykbut you shouldn't be
22:56blaismmarczyk: yeah, that's closer to what I'm interested in. Thx.
22:56tomojconstructin a set seems cheaper than constructing a fn
22:57mmarczykblais: I'm finding it hard to measure the difference in runtime between (some #{:foo} ...) and (some #(= :foo %) ...)
22:57tomojoh, d'oh
22:57blaisWont' the fn be baked at compile time?
22:58blaisI can bet, maybe it's me being a bit of a purist.
22:58tomojbut you get a class for the fn, right?
22:58mmarczykI wouldn't call that "purist"
22:58tomojI didn't have slime-repl installed
22:59mmarczykused to memq, perhaps ;-)
22:59blaistomoj: DK. Still a newbie, don't quite understand what's going on under the covers yet.
22:59blaisMaybe I should just play it idiomatic and stfu.
23:00mmarczykthere are valid reasons for #(= foo %) in some, though
23:00mmarczykif foo might be nil or false
23:01blaisgood point
23:01mmarczykyou'll want either that or {foo true} (a map)
23:01mmarczyketc.
23:01tomojhuh
23:01tomojnever thought about that
23:01mmarczykand I don't think anyone would complain about your code being nonidiomatic if you write #(= foo %) as a matter of preference
23:01tomojI missed it, you mean like (let [x nil] (some #{x} aseq)) ?
23:01mmarczyktomoj: yeah
23:02tomojguess that is pretty rare
23:03mmarczykblais: 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:04tomoj,(doc some)
23:04clojurebot"([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:04mmarczykthereby avoiding O(n) complexity
23:04blaismmarczyk: totally in your boat.
23:04mmarczykblais: :-)
23:05blaisNote that I'm using Clojure to avoid writing Java (:-)) and I'm having to deal with a lot of snafu'ed stuff.
23:05blais(Not always my choice.)
23:05mmarczyk:-)
23:05blaisI've been hacking some Clojure shtuff all day, I can't stop. Still sitting at the terminal at work and it's 11pm!
23:06blais"The repl experience"
23:06blaisSo addictive.
23:06mmarczykindeed :-)
23:09tomojhacks and glory await!
23:17blaisHow do you convert a keyword into its equivalent symbol?
23:17arohner,(symbol (name :foo))
23:17clojurebotfoo
23:18blaisAaa, nice. (name). Didn't know. Thx arohner.
23:32tomojI think you need a macro
23:33blaistomoj: in order to eval within "." ?
23:33blaisthis fails too:
23:33blais(let [msg (VersionMessage.)] (set! (. msg (symbol (name :version_major))) 2))
23:33blais(same story)
23:34tomojI believe the problem is that you can't do (. msg (symbol "foo"))
23:34tomojneeds to be (. msg foo)
23:34tomojdon't have any objects with public fields handy to play around with
23:35tomoj(or do I?)
23:35taliosSystem.out :)
23:35taliosIts a class with a public field at least
23:37tomojcan you set! it?
23:37tomojit's final I think?
23:37taliosyep
23:38taliosI do it often - reassign System.out to a be a Writer than delegates to log4j or something
23:38blaispublic and non-final
23:38tomojhmm
23:38blaisI can set it when I specify the attribute explcitly.
23:38tomojI get an IllegalAccessError trying to set it to nil
23:39blaisHey, another one: is there a way to set the cdr to a cons cell not as a list, in CLojure?
23:39mmarczyk(.set (some #(= (.getName %) "foo") (.getFields VersionMessage)) "value")
23:39mmarczyk?
23:39mmarczykblais: nope, no classic cons cells
23:39blaise.g. in elisp: '(1 . 2)
23:39blaisI see.
23:40mmarczykthere are also setBoolean, setChar etc. methods for primitive types
23:40blaisSo I'd use something like `(~x ~y) instead of a cons cell
23:40blaisWhich makes it tempting to use [x y] instead (but more costly)
23:40mmarczykyou'd use [x y]
23:40mmarczykand it is not costly
23:41blaisWell it creates a vector underneath, no?
23:42blaisI mean, costly in the sense that vectors will pre-allocate a minimum size, vs. a list
23:42mmarczyk'(1 . 2) creates a cons cell underneath
23:42blaisOr maybe it's not idiomatic to worry about such petty things :-)
23:42tomojif it matters, your program is not doing anything else but this
23:43tomojI mean, it doesn't matter
23:43blaisa 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:43mmarczyk32, yes
23:44mmarczykstill, 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:44tomoj(list x y) > `(~x ~y) imo
23:45mmarczykif you could pass those things around as function arguments, say
23:45blaismmarczyk: 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:46mmarczykof course you can make yourself a classic cons in 1.2, btw, (deftype LispCons [car cdr]) :-)
23:46blaisIt's all relative I guess.
23:46blaishahahah
23:46tomojbut isn't your map bound by the number of fields in this object?
23:48seancronHi everyone
23:48seancronI'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:48mmarczykor 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:49mmarczyk(car (set-car! (LispCons. 1 2) 5)) ; => 5
23:51mmarczykblais: anyway, don't optimise your code just yet ;-)
23:52mmarczykseancron: weirdly in what way?
23:53seancronmmarczyk: I get this error "java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$assoc" when I type "data" into the REPL
23:53clojurebotyou mean clojure.main
23:56defnim 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:56defnhowever, i can't seem to load this...
23:56defnive tried all sorts of permutations with no luck
23:58mmarczykseancron: could you see if the (dataset ...) form throws the same exception?
23:59tomojdefn: does (use 'clojure-hadoop.job) work?