#clojure logs

2010-05-13

00:02brweber2what is the current state of creating a Java Enum in clojure?
00:09_brian2_technomancy : whats the right way to use lein and clojars to develop patches for pre-existing libraries do you put [lein-clojars "0.5.0"] in project file and take the original dependenicies out, or leave in, or am I on the wrong track?
00:53Raynestechnomancy: ping
00:54technomancy_brian2_: you don't need the lein-clojars plugin; just scp pom.xml foo.jar clojars@clojars.org:
00:54technomancyRaynes: pongo
00:54technomancy_brian2_: and be sure to change the group-id to org.clojars.brian2
00:54RaynesIs there a way to have global plugins that don't require a project?
00:55RaynesI have a couple of ideas for some plugins, but they wouldn't be very useful if they had to be added to a project's dependency list.
00:55technomancyRaynes: it's on the list for 1.3, but I haven't started it yet
00:55RaynesAlright. :\
00:55technomancyRaynes: however, a guy called "sids" said he might start prototyping it when I told him about my plans
00:55technomancyyou should ping him, see if you can help put something together
00:56_brian2_technomancy : what about the original dependencies, do I leave them in?
00:56technomancy_brian2_: yeah, you should only change the group-id
00:57_brian2_technomancy : ok, so they wont over write the changed files (?)
00:57technomancy_brian2_: you won't have permissions to upload anything that will overwrite the existing one
00:58technomancy_brian2_: that's why you have to change the group-id
00:58_brian2_technomancy : ok
01:02_brian2_technomancy : I'm not sure what this means "scp pom.xml foo.jar clojars@clojars.org:
01:03_brian2_whats foo.jar
01:03_brian2_i know I have pom.xml
02:11vIkSiThello all
02:11vIkSiTanyone know where the code for the sort function is?
02:13vIkSiTah found it (core.clj)
02:24vIkSiThmm, in a function defnition - what exactly does this refer to ? (defn myfn [[a & b]]) - what are a and b?
02:24vIkSiTand the & symbol.
02:26TheBusbyit indicates that the function expects a single argument which should be a list/vector/seq type
02:26TheBusbyand that a will be the first element, and b will be every remaining element
02:26TheBusby,(let [[a & b] [1 2 3 4]] [a b])
02:26clojurebot[1 (2 3 4)]
03:06maxhodakis there a way to round to arbitrary precision in the clj api?
03:06maxhodakor do i need to do it myself?
03:10LauJensenMorning all
03:21MadWombathello
03:22MadWombatI am trying to run a jetty server from a lein target, for this I need to pass it a routes function, so I use a project key for it. But so far I cannot seem to get it working, I get java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
03:23LauJensenMadWombat: M-x gist-region plz
03:23MadWombatLauJensen: ?
03:23LauJensenMadWombat: Are you an Emacs user?
03:23MadWombatLauJensen: yes
03:24MadWombatI don't have gist-region function
03:24LauJensenOk, then get gist.el, mark the code which is causing the problem, hit M-x gist-region and the code will be uploaded to github and the url will be in your kill-ring, then you can paste it here and we can all have a looksie :)
03:24LauJensenhttp://github.com/defunkt/gist.el/blob/master/gist.el
03:25LauJensenMadWombat: And from now on, when you see somebody gisting, you can just hit M-x gist-fetch, and get their code right in a new buffer
03:26MadWombatLauJensen: OK, I will need to clean up the code a bit
03:31MadWombathttp://gist.github.com/399596
03:32MadWombatthere are some extraneous deps, but you can get the idea
03:33MadWombatI got the error when I tried to quote the app method, so I removed the quote and now I don't get any errors, but I don't get the response either
03:36MadWombatand here is my app code http://gist.github.com/399601
03:39LauJensenMadWombat: I haven't deployed on GAE yet, but your 'handler' isn't claiming any route. AFAIK run-jetty's handler is a combination of routes and handlers, ["/"] (fn [r] (println r))
03:41LauJensenhttp://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#LID54
03:41LauJensenHere is how Compojure compiles it routes if your familiar with that. If not, 'app' in Moustache is actually simpler, but its just a pairwise collection
03:42MadWombatthat might explain why I get Problem accessing /. Reason: NOT FOUND
03:42LauJensenyea, and if you want routing - I would recommend checking out Moustache
03:43MadWombatLauJensen: I don't need much routing, that is why I don't even use compojure
03:44LauJensenk
03:44MadWombatstrange thing though, if I miss the gae-app setting entirely, the same handler (default) seems to work
03:44LauJensenSounds like a bug
03:45MadWombatLauJensen: I am trying to implement something similar to what hackers-with-attitude post described, but with leiningen instead of ant and running recent ring instead of old compojure
03:46LauJensenLook forward to seeing it in action
03:47MadWombathmm... readme for ring seems to describe app the same way, it is a function that takes request object and returns response
03:47MadWombathttp://github.com/mmcgrana/ring
03:50LauJensenYou're right
03:50LauJensenTry running with his code, ie. associating to the req
03:53MadWombatinteresting... seems like the app source directory is not on the classpath
03:55MadWombatseems like lein is not including the source in the classpath when running tasks
03:55MadWombatI tried to hardcode the route function and got an error
03:55tomojI don't think that's a bug
03:56MadWombatwell, wonder if I can get around that
03:56tomojdunno.. maybe look into the source for e.g. 'lein test'?
03:56tomojsince that must run some code in the subclasspath
03:57MadWombatgood idea
03:57tomojI shouldn't really be giving advice, I don't actually know much at all about lein's innards
03:57MadWombat:)
03:58MadWombatme neither :)
03:59RaynesLauJensen: You live in Denmark, right?
03:59LauJensenMadWombat: Perhaps if you've too much syntax like #() or named your variables something like 'chunk', technomancy may have put in easter eggs which prevents what he thinks is ugly code - you know, like he does with project names
03:59LauJensenRaynes: Still here, yes
03:59RaynesJust wondering. Oliver Twist comes from Denmark.
04:00LauJensenHere I would counter with someone famous from Alabama, but you're the only one I know Im afraid :|
04:00MadWombatLauJensen: no, I don't much like macro shorthands myself
04:00RaynesLauJensen: Gomer Piles came from Jasper, 22 miles east of my home. But I'm not talking about the book.
04:01LauJensenWhos' Gomer ?
04:01Raynes$wiki Gomer Piles
04:01sexpbotFirst out of 27 results is: Gomer Pyle - Wikipedia, the free encyclopedia
04:01sexpbothttp://en.wikipedia.org/wiki/Gomer_Pyle
04:01Raynes$wiki Oliver Twist tobacco
04:01sexpbotFirst out of 48 results is: Oliver Twist Tobacco - Wikipedia, the free encyclopedia
04:01sexpbothttp://en.wikipedia.org/wiki/Oliver_Twist_Tobacco
04:01LauJensenPyle ?
04:01LauJensenor Piles?
04:02RaynesI thought it was Piles. This is before my time, mind you.
04:04LauJensenNice
04:04RaynesA couple of other, generally famous people have come from Alabama. None recently though. Unless you count that American Idol winner a few years ago.
04:04RaynesGray haired dude.
04:05zmilamaxhodak, you can use (format )
04:05zmila,(format "aaa %10.4f zzz" Math/PI)
04:05clojurebot"aaa 3.1416 zzz"
04:07RaynesDoes clojurebot cut out duplicate whitespace?
04:07Raynes$(format "aaa %10.4f zzz" Math/PI)
04:07sexpbotresult: aaa 3.1416 zzz
04:09zmilano idea about spaces
04:11RaynesYeah.
04:11RaynesHe must, because it comes out the same way in the REPL.
04:13zmila,(str "oaeu" " " "aoeu")
04:13clojurebot"oaeu aoeu"
04:13zmilarepl of CCW inside Eclipse does not cut
04:16TheBusbyhow do you include a quotation mark character in a string?
04:16tomoj,"\""
04:16clojurebot"\""
04:16TheBusby,(str "\" this doesn't work")
04:16clojurebot"\" this doesn't work"
04:16tomoj(println "\" this doesn't work")
04:16tomoj,(println "\" this doesn't work")
04:16clojurebot" this doesn't work
04:16TheBusbyso what's the trick the for str and format then?
04:17tomojstr is the identity on strings
04:17tomojI don't think there is a trick
04:17TheBusbyahh
04:17Chousukeclojurebot prints strings with quotes
04:17Chousuke,"foo"
04:17clojurebot"foo"
04:18Chousuke,(print "foo")
04:18clojurebotfoo
04:18TheBusby,(println "$(println \",(println \\\"haha\\\")\")")
04:18clojurebot$(println ",(println \"haha\")")
04:18sexpbotresult: ,(println "haha")
04:19tomojdoes sexpbot always use "result:" for this reason?
04:20tomojif it didn't, I wonder if you could set up an infinite loop
04:20Raynestomoj: Yes.
04:20Raynestomoj: Whether or not an infinite loop is possible, I don't want to find out. Which is why result: is there.
04:20Raynes:)
04:21TheBusbysome how I can imagine many hours wasted in pursuit of that...
04:23tomojseems like you'd need something quine-like
04:24tomojnever thought about quine-like things with period>1 before
04:26TheBusby,(println ",(println \"No quines here\")")
04:26clojurebot,(println "No quines here")
04:27tomoj(and (= (eval a) b) (= (eval b) a) (not= a b)) -- possible?
04:28Raynes$google rosettacode quine clojure
04:28sexpbotFirst out of 7 results is: Category:Clojure - Rosetta Code
04:28sexpbothttp://rosettacode.org/wiki/Category:Clojure
04:28RaynesThere is a quine example in there somewhere.
04:28tomojI don't think I can work with it, unfortunately :(
04:28tomojI've never understood a quine so it seems unlikely I'll solve my puzzle
04:29TheBusbyahh, that's the same as the old lisp one
04:30tomojhmm http://www.pagiamtzis.com/articles/iterating-quine-with-transient/
04:30sexpbot"Kostas Pagiamtzis: Oscillating (Iterating) Quine with Initial Transient"
04:44Raynescgrand: ping
04:57MadWombatdamn, I hate jetty, you start the server by accident and it keeps running in the background with no way to stop it :(
04:57MadWombatnow I have to restart the swank AGAIN
05:15arbschtMadWombat: a naive solution is to save a reference to your servlet, and call .stop on it
05:59somniumare there any known corner cases where you cant recur out of very deeply nested let/if statements (despite being in tail-position) ?
06:07Chousukenone known to me :P
06:12somniumhmm, the macroexpansion is hard to read, but chaning recur to the function name works
06:12somniumhttp://gist.github.com/399685
06:18somniumah, I am blind, nm ...
07:04RaynesLauJensen: You use, Chrome, don't you?
07:04LauJensenNot anymore Raynes
07:06RaynesI need somebody to confirm that automatic scrolling to the bottom of this div isn't working in Chrome. Not that I give a damn, but it's not working here either. It was working until I put it in the iframe. It works fine in FF.
07:06tcrayfordRaynes: I have chrome installed and stuff (mac though)
07:07RaynesIf anybody who is using Chrome has a moment, please navigate to http://tryclj.licenser.net/ and enter (doseq [x (range 1 100)] (println x)) and tell me whether or not it scrolls all the way to the bottom of the div properly.
07:07RaynesI mean, I've tried three different ways of scrolling, and none of them work in Chrome, so if it doesn't work, it's beyond my abilities to fix it.
07:07tcrayfordscrolls all the way to the bottom here
07:07RaynesI'd just like it confirmed.
07:07tcrayfordon chrome
07:07RaynesOh, good. It must just be my Chrome.
07:08RaynesThanks.
07:08tcrayfordeven on a second run
07:08LauJensenRaynes: Scrolls fine on Linux as well
07:08tcrayfordwhat version fo chrome are you using?
07:08RaynesUh. /me checks
07:08Raynes5.0.375.38 beta
07:08tcrayfordon windows?
07:09RaynesNo.
07:09RaynesLinux.
07:09tcrayford:S
07:09tcrayfordho hum
07:09RaynesWeird.
07:09tcrayfordI can fire up a windows box if you want it tested on there as well
07:09RaynesAt least it's working for everyone else. :)
07:09RaynesI'd definitely appreciate it, but don't go out of your way to do so. :p
07:09tcrayfordit takes like 5 minutes, so meh
07:10Raynes<3
07:10tcrayford*waiting for his very very slow windows box to boot*
07:11sparievheh, Chrome 4.1.249.1045 on Windows 7, doesnt scroll
07:11RaynesNo dice.
07:11RaynesIt works for most people. This is the most I can ask of my budding web development skills.
07:11Raynes:)
07:12tcrayfordturned windows box on, but forgot to plug in ethernet
07:12tcrayfordso synergy timed out
07:12tcrayfordalso spariev just gave you a windows thing
07:12tcrayfordso no need for me now
07:13RaynesIndeed. Windows result: suckage.
07:13tcrayfordsurprise surprise
07:13rsynnottRaynes: are you using the dev version of chrome?
07:13RaynesLuckily, I don't know many Clojure people on Windows, and nobody outside of Clojure people would have a good reason to use tryclojure.
07:13rsynnottthe latest one (5.0.396) is pretty broken
07:13Raynesrsynnott: Whatever came off of the official chrome site.
07:14rsynnottRaynes: there are three channels, though
07:14rsynnott(release, beta and dev)
07:14RaynesI'm on the beta channel.
07:15AWizzArdIs the Java-Plugin working well with Chrome?
07:15AWizzArdNow as we know how to run any applet html+js is no longer required :)
07:20LauJensenRaynes: uhm... scroll actually doesn't work in IE6
07:20RaynesI care so little about IE6 that you can't even see the care if I put it in a clear crystal cup.
07:20LauJensenCareful with that :)
07:21LauJensenI did a client site not 6 months ago, where in the first month 10% of all visitors were IE6 users
07:21LauJensenTo avoid having to redesign I had to ban all of their IPs in iptables
07:21LauJensen(j/k)
07:21RaynesIf a Clojure developer is using IE6 for anything south of testing their websites, they should be shot to death by a firing squad.
07:21Raynes:p
07:21somniumhttp://ajaxian.com/archives/jquery-one-line-plugin-to-crash-ie6
07:21sexpbot"Ajaxian » jQuery one-line plugin to crash IE6"
07:22LauJensensomnium: perfect
07:22somniumRaynes: just add this you'll be all set :)
07:22AWizzArdyes, write Applets or WebStart applications in Clojure, not html+js
07:22RaynesI should add one of those condescending "Get a better browser" popups.
07:22somnium<3 js
07:22AWizzArdI prefer Clojure over js.
07:22RaynesI have a love/hate relationship with js.
07:22AWizzArdhehe (:
07:22AWizzArdwhy?
07:22clojurebotwhy not?
07:22RaynesI love that it works (sometimes), but I hate that it's not Clojure.
07:23LauJensenRaynes: excellent point
07:23AWizzArdThe good news is: we can write small and big apps in Clojure and distribute them with the browser.
07:24AWizzArdSwing can be used, or clj-pivot for example, for the gui. You will have pmap on the client, can connect any host, can use Contrib and all libs you've written yourself.
07:25abrenkAWizzArd: so you fixed your webstart classloader problem?
07:25AWizzArdyes
07:25somniumAWizzArd: its an open standard, things like nodejs and cappucino ..., more reasons to like it than to hate it
07:25abrenkno fun dealing with stuff like that i suppose
07:26LauJensenWe also have both clj-javascript and scripjure - though I dont know how much mileage they give you these days
07:26AWizzArdThe JVM and Clojure are yeears ahead of what can be done with js. That is a pretty good reason for using that technology instead of something that is broken and works differently under each browser.
07:27LauJensenAWizzArd: well, can you do this? http://www.p01.org/releases/512b_jspongy/jspongy.htm
07:27RaynesBut making it an applet would require making it an applet. :(
07:28RaynesI thought the general consensus was that applets are teh dead.
07:28somniumAWizzArd: the browser's each provide a separate api that js can use
07:28AWizzArdLauJensen: yes, anything that can be done with the JVM+Clojure.
07:28AWizzArdRaynes: you can use WebStart then.
07:29LauJensenAWizzArd: I dare you. Make a 512b raytraced menger sponge - and then explain the math to me
07:29LauJensenI only ask the you get 10% of the fps that the js version makes
07:29AWizzArdLauJensen: Java is not able to do it?
07:30LauJensenAWizzArd: No I very much doubt it
07:30AWizzArdLauJensen: how comes that Jake 2 runs with 250 fps? http://bytonic.de/html/jake2.html
07:30sexpbot"Bytonic Software"
07:31LauJensenAWizzArd: Lets try again: Make a _512b_ raytraced menger sponge. Doing that in Clojure require a huge amount of coercing numbers to primitives which in itself will put you over 512b
07:32LauJensenIt might actually be possible with Penumbra now that I think of it
07:32AWizzArdWhy should we try this? Why not compare software in general?
07:32Chousukethe JVM is in some sense ahead of javascript virtual machines
07:32Chousukebut on other areas, it's behind
07:32Chousukethe languages however don't matter.
07:33AWizzArdThis is just a specific usecase. I could also ask for doing Clojure one-liners in JS, which suddenly would require lots of code.
07:34AWizzArdThere are reasons why we are in #Clojure and not in #JavaScript ;)
07:34somniumAWizzArd: thats like comparing clojure to java, there many many languages targeting javascript as a compile target
07:35AWizzArdAlso, what about the billions of man-hours that went into developing libs for the JVM? To use them all we would first need a lot of work to be done in JS.
07:35RaynesThere is always #clojure-casual
07:38Chousukedid someone claim that JS as a platform is even nearly as mature as the JVM? :P
07:38Chousukeit's barely gotten started.
07:39AWizzArdtrue
07:39Chousukethe speed of development is nothing short of astounding but that's another thing :)
07:40AWizzArdYes, in the next decade js can become a major player.
07:40Chousukeyou mean in ten years or within the next ten years?
07:40AWizzArdwithin
07:40Chousukeright. indeed.
07:40Chousukeand it's not a bad language either
07:41Chousukethough I don't like how all the JS engines are pretty much tied to browsers :/
07:41maxhodaki need to voice my frustration that clojure is totally unable to deal with multidimensional primitive arrays in any reasonable way
07:41AWizzArdYes
07:41Chousukemaxhodak: don't worry, so's java as far as I know :P
07:41AWizzArd(the “Yes” was for Chousuke)
07:41maxhodakChousuke: java can do foo[i][j] ...
07:42Chousukemaxhodak: it's easier (and I think faster) to just use a single-dimension array
07:42maxhodakclojure has a confusing amap method which entirely complicated the issue of traversing a 2d array
07:42maxhodaki'm being passed a 2d array from a lib
07:42AWizzArd,(doc aget)
07:42clojurebot"([array idx] [array idx & idxs]); Returns the value at the index/indices. Works on Java arrays of all types."
07:43maxhodak,(doc amap)
07:43clojurebot"([a idx ret expr]); Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each element of ret to the evaluation of expr, returning the new array ret."
07:43maxhodakwhat?
07:43clojurebotwhat is exceptions
07:43Chousukethat's not very nice for 2d arrays, right.
07:43maxhodakanyways
07:43mmarczykaren't Java's 2d arrays just arrays of arrays...?
07:44Chousukeyes.
07:44mmarczykright, so (aget foo i j) = foo[i][j]
07:44Chousukethat is, the type of a[i] is an array type
07:44AWizzArdMaybe it would be indeed easier to make foo one-dimensional as Chousuke suggested?
07:44mmarczykand you can roll your own loop
07:44maxhodak,(count (int-array 2))
07:44clojurebot2
07:45Chousukebut yes, clojure really isn't intended for array processing :P
07:45maxhodakyeah
07:45LauJensenmaxhodak: I did an article on Fluid Dynamics, its basically a long piece on how to get the most out of Java arrays from Clojure
07:45Chousukethe easiest thing to do is probably to copy the array contents into a vector
07:45AWizzArdThough, with a few hours of work you could come up with respective fns :)
07:45maxhodakidk. one of the biggest draws of clojure was the ability to use java libraries
07:45maxhodakbut ive been doing a lot of work with machine learning libraries recently
07:45Chousukemaxhodak: yeah but arrays are not nice from an api perspective
07:45maxhodakand i feel like clojure is *not* making things go faster
07:46RaynesHeresy.
07:46Chousukethere are no interfaces and it's just "raw data"
07:46maxhodakwhich is kind of the normal promise of a more sophisticated language like lisps
07:46AWizzArdWell, this is Lisp. You don't need to wait for anyone to let you work with arrays as you wish. You can implement that yourself.
07:46maxhodaki spend hours just fighting with stuffing things into data structures
07:46Chousukemaxhodak: arrays are about the only thing that clojure doesn't work well with in my experience
07:47ChousukeI wonder if a clojure.contrib.arrays would be useful...
07:47AWizzArdhmm yeah, could be nice
07:47Chousukebut what could it contain?
07:47maxhodakAWizzArd: that works when the abstraction is obvious or something is very repetitive; in this case it still feels like a lot of one-off data structure stuffings
07:47LauJensenhttp://www.bestinclass.dk/index.php/2010/03/functional-fluid-dynamics-in-clojure/
07:47sexpbot"Functional Fluid Dynamics in Clojure | BEST IN CLASS"
07:47LauJensenmaxhodak: those arrays go pretty fast
07:48AWizzArdChousuke: we can ask maxhodak what he needs right now. That is something that could go into such a contrib.
07:48maxhodakChousuke: into-vec, for one
07:48mmarczykmaxhodak: if you need a generalised amap for traversing 2d arrays, then pick your order of traversal and write one
07:48maxhodakwhich would translate a prim array into a vec-of-vec[-of-vec...]
07:48AWizzArdmaxhodak: can you list some more things that you wish you could write?
07:48AWizzArd(my-amap ...)? Something like that?
07:49Chousukehm
07:49maxhodakAWizzArd: i can write that one
07:49maxhodak(into-vec)
07:49AWizzArdso basically what you want is a fn into-vec
07:49maxhodaki'm not a total novice. this has just been frustrating
07:49AWizzArdyes, can be frustrating
07:49AWizzArdI am just asking you which fns you would wish to exist
07:49AWizzArdso that it would not be frustrating
07:50maxhodaki mean, the goal would be to make it so we didn't have to deal with arrays
07:50AWizzArd,(into [] (make-array String 4 10))
07:50clojurebot[#<String[] [Ljava.lang.String;@843189> #<String[] [Ljava.lang.String;@d03e90> #<String[] [Ljava.lang.String;@1bb9091> #<String[] [Ljava.lang.String;@1103d33>]
07:50maxhodakright now there are a bunch of fns in core for clojure.lang.* -> [L
07:50maxhodakbut not the other way around
07:51maxhodak,(into [] (into [] (make-array String 4 10)))
07:51clojurebot[#<String[] [Ljava.lang.String;@114dc12> #<String[] [Ljava.lang.String;@7c297a> #<String[] [Ljava.lang.String;@1871a46> #<String[] [Ljava.lang.String;@cdec7f>]
07:51maxhodaker
07:51raekyou can always (seq) an array...
07:51AWizzArd,(vec (map #(into [] %) (into [] (make-array String 4 10))))
07:51clojurebot[[nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil]]
07:51maxhodak,(map #(into [] %) (into [] (make-array String 4 10)))
07:51clojurebot([nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil])
07:52maxhodakoh -- i remember my biggest problem
07:52maxhodakwhy i had to use nested amaps
07:52maxhodaki needed the indexes
07:52AWizzArddo you have a code example?
07:53maxhodaklike, the indexes mattered
07:53AWizzArdhmm, there is a (map-indexed ...)
07:53maxhodak,(doc map-indexed)
07:53clojurebotGabh mo leithscéal?
07:53AWizzArdin fresh Clojure versions from http://build.clojure.org/
07:53sexpbot"Dashboard [Hudson]"
07:53AWizzArdbut otherwise you can use clojure.contrib.seq/indexed
07:54AWizzArd,(doc indexed)
07:54clojurebot"([s]); Returns a lazy sequence of [index, item] pairs, where items come from 's' and indexes count up from zero. (indexed '(a b c d)) => ([0 a] [1 b] [2 c] [3 d])"
07:54maxhodakis that all in scope here?
07:54maxhodak(indexed (fn [a b] (vector a b)) (int-array 4))
07:55maxhodak,(indexed (fn [a b] (vector a b)) (int-array 4))
07:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: seq-utils$indexed
07:55AWizzArd,(doseq [[i s] (indexed ["a" "b" "c"])] (print i s))
07:55clojurebot0 a1 b2 c
07:55AWizzArd,(doseq [[i s] (indexed ["a" "b" "c"])] (print i s "-----"))
07:55clojurebot0 a -----1 b -----2 c -----
07:55maxhodak,(indexed (fn [a b] (vector a b)) (into [] (int-array 4)))
07:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: seq-utils$indexed
07:55maxhodakoh wait i'm looking at map-indexed
07:55AWizzArdright, here we have indexed for now
07:56maxhodak,(indexed (int-array 4))
07:56clojurebot([0 0] [1 0] [2 0] [3 0])
07:56maxhodakok, that works
07:57AWizzArd(map-indexed vector (into [] (int-array 4))) should work on fresh Clojures.
07:57maxhodakalso, i was wondering if anyone had details on the inner workings of pmap
07:57maxhodaki don't seem to get any speedup from it; it actually makes things run slower
07:57AWizzArddo you want to know something specific?
07:57AWizzArdmaxhodak: this is then because your fn is not expensive
07:57maxhodakso i usually end up using concurrent and an ExecutorService to manually deal with threads
07:58maxhodakAWizzArd: no, they're expensive
07:58AWizzArd(pmap inc (range 100)) is slower, because for each inc work needs to be done
07:58AWizzArdthread scheduling here and there, copying data stackes, etc.
07:58AWizzArdyour inc should take at least 1-2 msecs
07:58maxhodakAWizzArd: each fn takes up a core for a solid 3-5 seconds
07:59AWizzArd,(time (count (map #(Thread/sleep 500) (range 3))))
07:59clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--16172$fn
07:59AWizzArd,(time (count (map (fn [_] (Thread/sleep 500)) (range 3))))
07:59clojurebot3
07:59clojurebot"Elapsed time: 1503.154 msecs"
07:59AWizzArd,(time (count (pmap (fn [_] (Thread/sleep 500)) (range 3))))
07:59clojurebot3
07:59clojurebot"Elapsed time: 504.238 msecs"
08:00maxhodakthat's strange
08:00maxhodakhas it changed significantly in newer clojure?
08:00maxhodaki might be running 1.1 still
08:00AWizzArdnot really
08:00maxhodaki am
08:00AWizzArd,*clojure-version*
08:00clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
08:00AWizzArdThe bot also runs 1.1
08:00maxhodakhmm
08:00AWizzArdtry this map vs pmap thing from above
08:00AWizzArdon your box
08:02maxhodakgot the exact same result as you did here
08:02maxhodakso im running maps and reduces inside the fn
08:02maxhodakmaybe it has to do with laziness and that just appearing slow?
08:03maxhodakalso, how does pmap decide how many threads to run in? does it detect the number of cores and do something intelligent?
08:05AWizzArdpmap uses as many cores as are available + 2
08:05AWizzArdthreads
08:05AWizzArddual core cpu ==> up to 4 threads
08:05AWizzArdnew AMD Magny Cours ==> 14 threads
08:06AWizzArdmaxhodak: http://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L5296
08:06AWizzArd(+ 2 (.. Runtime getRuntime availableProcessors))
08:07AWizzArdpmap guarantees the correct order of the results, but obviously it must not run side-effects.
08:07maxhodakhmm
08:07maxhodakright
08:07AWizzArdAt least not if the order in which those side-effects will be executed matters.
08:08AWizzArdIn fact, I often cheated, as there is no (pdoseq ...) I just used (doall (pmap #(body here) my-seq)), to parallelize side-effect execution.
08:09AWizzArdAlthough, now that futures use the same pool thread pool as agents do, a doseq fireing of futures would also be okay.
08:13chouserpmap uses the 'send' pool and future uses the 'send-off' pool, I believe.
08:13chouserI'd recommend sticking with doall+pmap
08:14cemerickparameterizing the usages of various pools seems like low-hanging fruit for 1.3
08:17caljuniorclojure
08:27zakwilson_Has somebody written a version of pmap optimized for large sequences and fairly fast functions? A naive version should be pretty trivial to write, but I figured I'd ask before starting down that path.
08:27Chousukewell, sequences are not parallelisable.
08:27AWizzArdzakwilson: I am under the impression that vmap will be good for that
08:28Chousukeso you need a slow function to map over in order to get any benefits
08:28zakwilsonChousuke: right. Assume vectors then, which I think ought to be.
08:28AWizzArdthough, this could perhaps also be done on the video card, with the clojure lib "penumbra"
08:28Chousukebut pvmap is rich's experimental function for mapping over vectors (which are not sequences) and it's very fast
08:29AWizzArdVideo cards are extremly good in running cheap functions on vast amounts of data
08:29Chousukeit's in the clojure par branch and depends on the JDK7 forkjoin library
08:29AWizzArdsuch as: make each rgb pixel brither by 10%, and then do this for all pixels or such
08:30Chousukezakwilson: http://paste.lisp.org/display/84027
08:32zakwilsonWhat I actually want to do is run it on a map and return a vector, so I don't think vpmap would work out of the box. How fast is calling vec on a map?
08:32Chousukelinear
08:33AWizzArdAnd do you really need the result to be a vector?
08:33zakwilson1.3 seconds on my data set. That would kill any benefit from parallalization.
08:34zakwilsonNo. I need a sorted collection.
08:34AWizzArda sorted-set-by or sorted-map-by?
08:35AWizzArdWhat I would really really love to have is a way to build up a sorted-set or map veeerry fast, if I can guarantee to insert in already sorted order
08:37zakwilsonA map, sorted by value, which I'm currently getting with (sort-by val (comparator >) (into [] m))
08:37zakwilsonWell, a sequence of key/value pairs. It doesn't need to be a map at this point.
08:38AWizzArdzakwilson: a map, sorted by value?
08:38AWizzArdsorted by key you probably mean?
08:39zakwilsonNo, I mean sorted by value. {:a 2 :b 8 :c 4} is sorted to {:b 8 :c 4 :a 2}
08:39zakwilson,(into {} (sort-by val (comparator >) (into [] {:a 2 :b 8 :c 4}))
08:39clojurebotEOF while reading
08:39zakwilson,(into {} (sort-by val (comparator >) (into [] {:a 2 :b 8 :c 4})))
08:39clojurebot{:b 8, :c 4, :a 2}
08:40AWizzArd,(class (into {} (sort-by val (comparator >) (into [] {:a 2 :b 8 :c 4}))))
08:40clojurebotclojure.lang.PersistentArrayMap
08:40AWizzArdit just happens to look sorted, because it is an ArrayMap
08:40AWizzArd,(doc hash-map)
08:40clojurebot"([] [& keyvals]); keyval => key val Returns a new hash map with supplied mappings."
08:41zakwilsonI know, but what I'm really doing with it is (take n (sort-by val (comparator >) (into [] m)))
08:41AWizzArdMaybe you want to go with a sorted-set
08:42AWizzArdif you have tuples you can sort them by any of their values
08:43zakwilsonOr use the numbers as keys and go with a sorted map, but I'm actually happy with the current implementation of this. What needs work is the generation of the map that I'm taking the top values from.
08:44AWizzArd,(into (sorted-set-by #(compare (second %2) (second %1))) [[:a 2] [:b 8] [:c 4]])
08:44clojurebot#{[:b 8] [:c 4] [:a 2]}
08:44hamza~def pmap
08:44AWizzArdhamza: pmap is at http://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L5296
08:45hamzaAWizzArd: thanks, what was the command to get url to github for clojurebot?
08:45AWizzArdi guess it just is very slow
08:46AWizzArdI happened to have the url still in my history, because I pasted it 40 minutes ago
09:00zakwilsonAWizzArd: the sorted set is marginally faster, though swapping out my sort-by call for that seems to have broken my code. That makes no sense, as the results of calling it on test cases are identical.
09:01AWizzArdok
09:01zakwilsonNot that I expect you to fix that.
09:03zakwilsonI'll try to get it working because it seems like the correct data structure, but what I really want is to speed up generation of the thing I'm sorting: (map a-fast-function a-big-map)
09:07AWizzArdzakwilson: if it were not a-big-map but a-big-vector then you try to cut it into 2 (or more) pieces and put the call to map into a future.
09:09zakwilsonYes, but I need to do fast lookups by key on it.
09:11AWizzArdand only afterwards you want to sort it?
09:12AWizzArdif you had a-big-sorted-set then you can still slice it into pieces with subseq
09:12AWizzArdthough I don't know if this is efficient in the current implementation
09:12zakwilsonI don't want to sort a-big-map. I want to sort the output of (map a-fast-fn a-big-map)
09:13zakwilsonThe sorting part is fast enough (~500ms).
09:17zakwilsonSome speedup with (apply concat (pmap #(map a-fast-fn %) (partition (round (/ (count a-big-map) 4))))
09:19cemerickso, last-var-wins just falls down in some cases -- e.g. defining munge in one's own ns
09:35chousercemerick: :-( I wonder if we're too late to replace that with something better in 1.2
09:35chousercemerick: might be worth continuing to beat that drum on clojure-dev
09:35cemerickchouser: it's really quite bad. I'm willing to do whatever it takes to get last-var-wins eliminated.
09:36cemerickyeah, I'll post a message shortly
09:38AWizzArdcemerick: do you have a minimal example of that problem?
09:39cemerickAWizzArd: looks like: add (defn munge [a b c]) to an ns, AOT-compile.
09:44AWizzArdHmm, and what is the problem there?
09:44AWizzArdSome other ns also has a (defn munge)?
09:44cemerickcore does
09:44cemerickand when you redef it locally, the compiler bonks trying to use your version
09:45cemerickor, that's my reading of it
09:45AWizzArdSo, you may not aot anything that already exists in core?
09:45cemerickthe scope is surely not that large
09:45cemerickperhaps anything that the compiler uses?
09:46AWizzArdic
09:53chouserthis could be fixed in the compiler without losing last-var-wins
09:53chouserunfortunately
09:53chouserbut ... actually, it probably should be.
09:53chousercemerick: did you have your own munge var before last-var-wins?
09:55chouserthe compiler should be using clojure.core/munge, not *ns*/munge. If it's doing the latter, it would fail in the case you're describing, but seems like it would also fail if you excluded clojure.core/munge from your own ns and then def'ed your own munge
09:55chouserhm, actually I think I can test that in a moment here.
10:00cemerickchouser: yeah, it was already there; the compiler error actually is related to munge being a multimethod
10:00cemerickand I get two warnings before the compiler error, with core/munge and my-ns/munge doing a dance
10:10chouseryou were excluding clojure.core/munge from your ns and that was working fine?
10:10mmarczykas far as I can see, munge is a regular function, defined with a defn in core_deftype.clj
10:11cemerickchouser: I was, yes, but then I dropped the exclude. I had a hunch. :-)
10:11chouser:-)
10:12chouserwell then color me surprised. I'd have to dig into it to figure out why last-var-wins is behaving differently from exclude+def
10:13zakwilsonIs there a way to persist a map to disk that's faster to read than (spit "foo" (str a-map))?
10:14chouser(future (spit "foo" (str a-map))) is pretty fast ;-)
10:14chouserthere aren't many options. you could try the Serialization stuff, but I don't know if that's any faster or appropriate for your use-case.
10:15zakwilsonIt's the reading I'm interested in, not the writing.
10:15zakwilsonIt only takes a few seconds to write, but over a minute to read.
10:15npoektophi! how to make smth like (apply (fn [& a] (println "numbers: " a)) [1 2 3]) to print "numbers: 1\n2\n3?
10:15npoektopit prints "numbers: (1 2)"
10:18abrenk,(apply str (interpose "\n" [1 2 3]))
10:18clojurebot"1\n2\n3"
10:18chouserabrenk: you beat me about ~1 second.
10:18chouser,(apply str "numbers: " (interpose "\n" [1 2 3]))
10:18clojurebot"numbers: 1\n2\n3"
10:18abrenkchouser: but your answer's more complete :)
10:20npoektopi mean i need smth like this (find collection spliced-vector-of-params)
10:20npoektophow to splice vector of params here?
10:23zakwilsonAny good reasons not to use -XX:+AggressiveOpts?
10:25chousernpoektop: is 'apply' not what you want?
10:25chouserfind only takes two args though, so I'm not sure why you'd want to splice in more than that.
10:25npoektophow to use it here?
10:27npoektopchouser, (defn find [coll & params] ...) how to splice a vector v? (apply ...(find coll ...) v)
10:27chouser(apply find coll v)
10:28chouserbut note there's a clojure.core/find, so replace that with caution
10:28npoektopchouser, thank you
10:29cemerickchouser: tip o' the iceberg, there :-/
10:40zakwilsonUnder what circumstances could (take n (sort-by val (comparator >) (into [] a-map))) and (take n (into (sorted-set-by #(compare (val %2) (val %1))) a-map)) yield different results?
10:50rdsrHi all, I' m faced with the unfortunate task of extending innumerable wrapper classes from a single parameterized class, so that I'm able to use these with the proxy macro ,
10:51rdsrHas anyone faced a similar problem?
10:51rdsrany pointers, suggestions would be helpful :)
10:51zakwilsonAWizzArd: sorted-set-by excludes items where compare returns 0.
10:58zakwilsonSo I've spent all afternoon on performance tuning that yielded no improvements, but I did learn some things. Win overall.
11:00AWizzArdzakwilson: it does not exclude them
11:00AWizzArdbut instead those are *identical* and only one is kept
11:01zakwilson,(into (sorted-set-by #(compare (val %2) (val %1))) {:a 1 :b 2 :c 3 :d 2})
11:01clojurebot#{[:c 3] [:b 2] [:a 1]}
11:01AWizzArdWhen I want to sort things alphabetically after the first char of a string, then "Zakwilson" is exactly identical to "Zak the Wilsoner".
11:01AWizzArdyes, nothing excluded, the element is already inside
11:01zakwilson[:d 2] is excluded.
11:01AWizzArdno, there it is: [:b 2]
11:01AWizzArdThey are identical, under your comparator.
11:02zakwilsonActually, that's your comparator.
11:02AWizzArdIt was just an example. Write any that you like.
11:02mmarczykAWizzArd: that would likely be what zakwilson is getting at ;-)
11:02Chousukehm
11:03Chousukethe comparator shouldn't affect set membership, only the sorting order
11:03Chousukethat's a bug if you ask me.
11:03AWizzArdChousuke: I mentioned this months ago
11:03mmarczykas with sort-by you'll get both [:b 2] and [:d 2]
11:03zakwilson,(into (sorted-set-by #(if (> (val %2) (val %1)) 1 -1)) {:a 1 :b 2 :c 3 :d 2})
11:03clojurebot#{[:c 3] [:d 2] [:b 2] [:a 1]}
11:03AWizzArdI discussed this with rhickey, but right now that is not a priority
11:03AWizzArdWe were at it when I asked him about persistent sorted multisets
11:04zakwilsonThat's what I want, however, it's slower than this:
11:04AWizzArd,(into (sorted-set-by compare) {:a 1 :b 2 :c 3 :d 2})
11:04clojurebot#{[:a 1] [:b 2] [:c 3] [:d 2]}
11:04AWizzArd,(into (sorted-set-by compare) {:a 4 :b 2 :c 9 :d 2})
11:04clojurebot#{[:a 4] [:b 2] [:c 9] [:d 2]}
11:04zakwilson,(sort-by val (comparator >) (into [] {:a 1 :b 2 :c 3 :d 2}))
11:04clojurebot([:c 3] [:b 2] [:d 2] [:a 1])
11:04mmarczykso you'd be fine with nondeterministic ordering for sorted-set-by if the comparator happens to "glue together" some elements?
11:04AWizzArduhm no, reverse the keys
11:04AWizzArdmmarczyk: first wins
11:05AWizzArdorder can be like conj on vectors
11:05AWizzArdThis is how Google implemented their Multisets
11:05AWizzArdBut they are not fully persistent, so, not interesting (to me).
11:05cemerickwell, there that goes. I wonder how badly I'm going to get spanked. ;-)
11:05mmarczykAWizzArd: I don't know, I tend to expect tree sets to have an ordering independent of insertion order
11:06AWizzArdAnyway, I tend to say that if things are not (identical? a b) they should both go into the set.
11:07mmarczykAWizzArd: that's contrary to my intuition, but I'll just say I need to think about it, thanks for the food for thought :-)
11:07AWizzArdzakwilson: you can use (identical? %1 %2) in your comparator if (zero? (compare %1 %2))
11:07mmarczykAWizzArd: not really
11:07mmarczyk,(identical? [1] [1])
11:07clojurebotfalse
11:08AWizzArdwhy not? Can make sense for some applications
11:08mmarczyk=, maybe, though it's still a bit strange to me
11:08AWizzArdanyway, it was just a suggestion
11:08mmarczykor .equals
11:08zakwilsonAWizzArd: I just used (if (> a b) 1 -1) - the items are guaranteed not to be identical.
11:08AWizzArd,(identical? [:b 2] [:d 2])
11:08clojurebotfalse
11:08AWizzArdthat could be fine for zakwilsons case
11:08mmarczykand also
11:09mmarczyk,(identical? [:b 2] [:d 2])
11:09clojurebotfalse
11:09AWizzArdyou probably meant 2x [:b 2]
11:09mmarczyk,(identical? [:b 2] [:b 2])
11:09clojurebotfalse
11:09mmarczykyeah
11:09AWizzArdanyway, depending on the situation this can make sense
11:09AWizzArdfor zakwilson perhaps = would be better
11:10AWizzArd,(compare (second [:b 2]) (second [:d 2]))
11:10clojurebot0
11:10AWizzArd,(zero? (compare (second [:b 2]) (second [:d 2])))
11:10clojurebottrue
11:10AWizzArdif this yields true just try (= [:b 2] [:b 2])
11:10AWizzArduhm, one of those ought to be a :d :-)
11:11AWizzArdoh great :)
11:12mmarczykif seqs where comparable, we could use rseq for reverse lexical ordering of vectors
11:12AWizzArdzakwilson_: (zero? (compare (second [:b 2]) (second [:d 2]))) ... if this yields true just try (= [:b 2] [:d 2])
11:13zakwilson_I don't care about the case where the items actually are identical: it can't happen.
11:14mmarczykzakwilson_: right, so your solution with 1 -1 is ok, although I guess it leads to nondeterministic ordering on the set
11:14zakwilson_I'm ok with nondeterministic ordering when the values are equal.
11:15zakwilson_The problem is, it's slower than (take n (sort-by val (comparator >) (into [] a-map)))
11:16zakwilson_(which I'm calling some 30,000 times)
11:16sparievhow would you guys rewrite this scheme code - http://gist.github.com/261189 ?
11:16mmarczykI've never looked into the tree set implementation, but I'd expect it to perform some rebalancing etc.
11:16sparievhere's my [nonworking because of wrong recur position] take - http://gist.github.com/399923
11:16mmarczykno surprise here
11:18Danmakuspariev: why occurs-naive1?
11:18AWizzArdzakwilson_: perhaps you can use some of the mutable Java collections to speed it up?
11:18mmarczykDanmaku: note string->list
11:19zakwilson_AWizzArd: I don't think this is actually the part that's slow. I'm using transients for the parts that previously profiled as being slow.
11:19Danmaku(let ((pat (string->list pat) (str (string->list str))) ... ?
11:20mmarczykDanmaku: actually (let loop ((pat ...) ...) ...), which is basically the same
11:20mmarczykDanmaku: otherwise you'd have to do list->string before the recursive calls
11:21DanmakuYes, i suposse depending on the implementation in turns the internal define into a letrec anyway.
11:21mmarczykspariev: you could just use regular self-calls instead of recur; the Scheme version isn't tail-recursive either
11:22mmarczykDanmaku: the impls which don't do this turn letrecs into internal defines ;-)
11:22Danmakuheh
11:23mmarczykbbl, there's a pizza waiting for me
11:23zakwilson_http://clojure.pastebin.com/K6zwG99h <-- what I *would* like is to make this work. Initial testing shows a brief spike in both cores no improvement on a dual-core system.
11:23AWizzArdmmarczyk: enjoy :)
11:24sparievDanmaku: the first gist called occurs-naive in contract with the same thing using memoize - http://gist.github.com/261193
11:24mmarczykAWizzArd: thanks :-)
11:26sparievmmarczyk: thanks, I'll look into it
11:26Danmakuspariev: you can define "occurs" without memoization
11:26Danmakuand then define a "memoize" procedure.
11:27savanniSo, I have a newbie macro problem that I put into a code snippet on http://pastebin.org/229880
11:27savanniAnd, if you are willing to attack that, my question is, why does my hex-replace macro get reported as a function? Or, how can I get hex-replace to expand into the other function?
11:28Danmakuspariev: for the memoization part there is an example here: http://clojure.org/atoms
11:28sparievDanmaku: thanks, I know about memoize, it was recur stuff I wasn't sure about
11:29sparievdidn't notice that scheme code isnt tale-recursive
11:29DanmakuI don't think you need recur here
11:29chousersavanni: I think you just want -> instead of .. in both places
11:31savanniHmm... well that changes the error message to "Wrong number of args passed to: pages$hex-replace (NO_SOURCE_FILE:0)". I thought my hex-replace macro only required one arg.
11:32chouserif this isn't just for learning macros, you might also be interested in:
11:32chouser,(java.net.URLEncoder/encode "this has/did-have &strang chars!")
11:32clojurebot"this+has%2Fdid-have+%26strang+chars%21"
11:33chouseroh
11:33savanniWell, one day I will need to learn macros, but the URLEncoder is probably more correct than what I have written.
11:33savanni(I really do not know much of the Java library)
11:33chouserok, I see some of what's going on.
11:34chousersavanni: me neither -- just learned (re-learned?) about URLEncoder yesterday.
11:35chousersavanni: you were expecting the inner hex-replace calls to be expanded first, and then .. to nest the resulting forms inside each other?
11:36savanniUmm... I think so. I was expected escape-uri-param to have a body of (.. param (replace ":" "%whatever") (replace "/" "%whatever") and so on
11:36savanniModeling after a function in either compojure or ring that escapes HTML entities.
11:39savanniAh, actualyl, a function in hiccup.
11:41chousersavanni: ok, that's the conceptual problem. An outer macro is expanded first, and only then are parts of what it returns expanded.
11:42savanniAH! Because .. itself is a macro!
11:42chousersavanni: so -> goes first, producing something like (replace (replace param \: "%..") \/ "%..")
11:42chouserright
11:42savanniOkay, I can restructure that!
11:48ArkRostHi! I've taken a look into clojure source. There is a thing I don't understand. Why do we in method lookupVar(src/jvm/clojure/lang/Compiler.java line 5633) have to handle a situation when sym equals NS handle separatelly from others?
11:52chouserArkRost: the symbols ns and in-ns are handled specially so that they always mean the same thing
11:53chouserwhen you're in namespace A and load B (perhaps via (ns A (:require B))), when B.clj first starts to load *ns* is still A
11:54chouserSo if A has done something screwy with the 'ns' or 'in-ns' symbols, or failed it refer them from clojure.core, it could cause B to fail in some hard-to-understand way.
11:54sparievis it ok/idiomatic to mix recur with usual self-class like this - http://gist.github.com/399923 ?
11:55chouserInstead, ns and in-ns always mean clojure.core/ns and clojure.core/in-ns so that you can use their short names even in unknown circumstances or in new/empty namespaces.
11:56ArkRostYou're right. Thanks
11:56sparievoops, s/self-class/self-calls
11:57chouserspariev: It's certinaly ok. I think it's sufficiently idiomatic as well -- using recur when you can (for speed, stack-depth, etc.) and not when you can't.
11:57sparievchouser: thanks, just wanted to be sure :)
12:03alexykI manually implemented pmap with 8 agents and achieved 800% load on an 8-core box. pmap did 400% max. Is there a way to tell pmap to work smarter, not harder?
12:04technomancyalexyk: pmap never gets too far ahead of the consumer since it's semi-lazy
12:05alexykah! will it get to work inside doall?
12:05alexykI meant harder, not smarter :)
12:06technomancynot really, because one element that takes longer can block the consumer from the successive elements
12:06technomancythough it might work if the amount of work for each element was relatively homogeneous.
12:07alexykthat's the case. I loath to reimplement the same map/reduce myself with my N agents, await for them, conj...
12:12hugodalexyk: out of interest, does (.. Runtime getRuntime availableProcessors) report 8?
12:13alexykhugod: yep
12:14joshua-choiI'd like to know if there's a function similar to clojure.contrib.string/split that includes the characters between the spitted string: (split* #"\s+" "ab c de") -> ("ab" " " "c" " " "de").
12:16arkahnnoob help - I want to read lines from a file, process each, until the call to readline returns 'nil'. I'm trying to decide what is the best branching and/or looping construct. Here's some sample code ;;; (with-open [r (BufferedReader. (FileReader. "./filename.txt"))] .readLine r)
12:17arkahnI eventually want to tail the file, so I'll read until 'nil', sleep, then try reading again until some test condition is false
12:17joshua-choiIf it weren't for that last part, you could simply use clojure.contrib.io/read-lines.
12:17arkahntrue! : )
12:18joshua-choiTake a look at that function's source, though: http://github.com/richhickey/clojure-contrib/blob/9cd7b155149c6e20b799528c6d5bf2f0e553e9f3/src/main/clojure/clojure/contrib/io.clj#L308
12:19cemerickcgrand: it'd probably be more convenient if String's get-resource returned nil if there's no available stream for the given name. The NPE isn't so useful.
12:19joshua-choiarkahn: If you replaced the (.close rdr) part with (do ... (.close rdr)), you should be able to do what you want
12:20arkahnjoshua-choi: thank you ... I should have looked at the cc code again : /
12:20joshua-choiNo problem.
13:16ninjuddtechnomancy: is there a way to use "lein compile" when some code is java and some is clojure? (src/jvm and src/clj)
13:17hiredmanthere is a lein-java plugin
13:18ninjuddhiredman: lein-javac?
13:19hiredmansomething like that
13:20ninjuddthat looks like the one... so here is what i don't get about lein. you have to run "lein compile-java". there is no easy way to make the standard "lein compile" be smart and do what you mean
13:21ninjuddwhich means that running "lein jar" is broken, because it depends on compile, but not on compile-java
13:23ninjuddit seems to me that the problem is that lein misses the difference between what would be tasks and targets in ant
13:23ninjuddmaking them the same thing, which put much more burden on the user
13:24hamzalein will allow your tasks to hook into other tasks, it is on technomancy's todo list but with a lower priority. for now you can use a custom task that calls the tasks in the correct order.
13:24abrenkninjudd: take maven... ;-)
13:24abrenk*duck*
13:26ninjuddhamza: can the custom task be called something that makes sense, like 'lein jar', or will it have to be something ridiculous, like 'lein myjar'
13:26technomancyninjudd: there's going to be a hooks system in 1.3 to support that
13:27ninjuddtechnomancy: great!
13:27technomancyI'm waiting for a Clojure release candidate to release Lein 1.2
13:28ninjuddtechnomancy: what about jars you depend on. will there be a way to run tasks for them after they are installed?
13:30giaceccoHello all! Anybody has some time for a newbie question and some Eclipse background?
13:30ninjuddtechnomancy: or is there already through maven?
13:32abrenkgiacecco: I use Eclipse for Clojure development at the moment...
13:33giaceccoabrenk: I am struggling getting Eclipse to add a simple .class file to the build path
13:33ninjuddalso, if i use lein-javac, there still doesn't seem to be a way to compile stuff in src/clj
13:33giaceccoabrenk: I have a stupid package-less class in a .class file
13:34giaceccoabrenk: that I want to instanciate in my clojure code e.g. (def foo (LineRedirecter.))
13:35giaceccoabrenk: I tried everything but I can't get Clojure to recognise that the .class file is there and the class LineRedirecter is available
13:35abrenkgiacecco: I vaguely remember that classes in the default package do not play well with Clojure...
13:35giaceccoabrenk: what do you mean?
13:35abrenkgiacecco: I don't think that it's an Eclipse problem.
13:36abrenkCould somebody else answer how to import a class from the default package?
13:37abrenkgiacecco: did you try to (import 'LineRedirecter) ?
13:37giaceccoy
13:37giaceccoat the moment LineRedirecter.class is in the 'classes' folder of the structure that Eclipse builds
13:38giacecco but Eclipse does not list it under (default package) in the package explorer
13:38alexykhow can I destructure [1 2 3 4 5] to capture 1, [2 3], and [4 5]?
13:39ninjuddtechnomancy: should i just move all my clojure code out of src/clj and directly into src? isn't src/clj and src/jvm the accepted way to structure source code that is clojure and java
13:39abrenkgiacecco: you don't have the source? just copied the .class file?
13:40giaceccoabrenk: I also have the source
13:40giaceccoabrenk: but I wouldn't like to translate everything in Clojure
13:40alexykninjudd: lein should understand :source-path IIRC
13:41abrenkgiacecco: is the source in the same eclipse project as your clojure code?
13:41giaceccoalexyk: do you mean something like #((nth 0 %) [(nth 1 %) (nth 2 %)] [(nth 3 %) (nth 4 %)]] ?
13:42ninjuddalexyk: looks like it does, thanks!
13:42giaceccoabrenk: y
13:42abrenkgiacecco: then it should work using (import 'LineRedirecter) (LineRedirecter.)
13:42alexykgiacecco: no, [x & [y z : mid2] & [u v :as last2]] or something that actually works
13:46giaceccoabrenk: when I added the .java file, package explorer showed a new (default package) folder under 'src', and the .java file is there: is that correct?
13:47abrenkgiacecco: yes
13:48abrenkgiacecco: the target folder is normally hidden in the package explorer
13:49ninjuddalexyk: i think you're best off using subvec
13:50giaceccoalexyk: (defn foo [x] [(nth x 0) [(nth x 1) (nth x 2)] [(nth x 3) (nth x 4)]])
13:50alexykninjudd: yeah
13:50giaceccoalexyk: I know it's ugly but I'm a newbie
13:50alexykgiacecco: a determined newbie! :)
13:51giaceccoalexyk: you have to start somewhere :-(
13:51alexyktrue
13:51Hodappsigh, if only when I was back in high school I had spent all that time during the summer actually learning Lisp instead of going to cross country practice and flirting with girls
13:51HodappI wouldn't be such a n00b now
13:52giaceccoalexyk: you may also invent something using 'partition'
13:53giaceccoabrenk: still no joy here
13:55abrenkgiacecco: could you paste your .classpath somewhere?
13:55turbofailHodapp: the two are (were?) not mutually exclusive
13:56alexykgiacecco: well. it's ok, I simply restructured the params. One way to do it is to say:
13:56alexyk,(let [[x & xs] (range 5) [y z & lala] xs yz [y z]] (print x yz lala))
13:56clojurebot0 [1 2] (3 4)
13:56abrenkgiacecco: when doesn't Clojure find your class? in a ccw repl?
13:56alexykI'd rather fetch yz at once with imaginary [y z :as yz & lala] but that seems to cut off lala, even though it parses
13:58giaceccoabrenk: even before that, the editor already says "No matching ctor found"
13:58giaceccoabrenk: actually, the error has changed, the one I just told you about does not say that the class does not exist
13:58clojurebothmm… sounds like your out of heap space
14:00giaceccoabrenk: hold on...
14:00abrenkgiacecco: does the class have a no-arg ctor?
14:01abrenkgiacecco: otherwise (LineRedirecter. :my :args :here) should work
14:02giaceccoabrenk: so there were two problems, and one is fixed
14:03giaceccoabrenk: the first was putting the .class in the right place, and that should be solved
14:03giaceccoabrenk: the second is that I was calling the ctor in the wrong way, but that is still broken, I am working on it now
14:04LauJensendumping a file with a Writer isnt atomic on the fs right? what is? shelling out to 'mv' perhaps?
14:07stuartsierraLauJensen: http://rcrowley.org/2010/01/06/things-unix-can-do-atomically.html
14:07sexpbot"Things UNIX can do atomically — Crowley Code!"
14:08LauJensenstuartsierra: Thanks!
14:09stuartsierranp
14:18arohner_ato: is there a way to grab the pom file for a jar on clojars?
14:19giaceccoabrenk: update: whatever signature I use, I always get the "No matching ctor found for class LineRedirecter" error
14:20giaceccoabrenk: the ctor is actually very simple: LineRedirecter(InputStream in, OutputStream out)
14:20giaceccoabrenk: and I am invoking with something that looks like (LineRedirecter. (. my-proc getInputStream) writeTo)
14:27abrenkgiacecco: and you're sure that those expressions evaluate to InputStream and OutputStream respectively?
14:28abrenkgiacecco: does (LineRedirecter. nil nil) work?
14:30giacecco(LineRedirecter. nil nil) does not work
14:30abrenkgiacecco: same error?
14:30giaceccoabrenk: I also tried explicitly casting the parameters to the expected types
14:30giaceccosame error
14:30giaceccothat's odd isn't it
14:31abrenkyeah
14:31abrenkI fear I'm out of ideas
14:32giaceccoabrenk: the source for LineRedirecter if you're curious is at http://bit.ly/bttA9N
14:32sexpbot"JMPlayer – Embedding MPlayer in Java « adrian's blog"
14:32giaceccoabrenk: don't worry, you've helped me a lot already, and thank you!
14:36dpritchettI've just spent a few hours trying to get vimclojure + lein-nailgun to work with the latest labrepl to no avail. I'm not really sure where to go next.
14:36dpritchettI have lein-nailgun working fine with vimclojure in a sample clojure 1.1.0 project but since labrepl usees 1.2.0-snapshot it seems to be causing some issues
14:36lancepantzdpritchett: i've tried 3 times over the last 6 months with little success
14:36abrenkgiacecco: as long as it's not just a typo regarding ...ter and ...tor
14:37lancepantzi was actually just trying lein ng + vimclojure
14:37abrenkha!
14:37abrenkgiacecco: the ctor is not public!
14:37dpritchettI think I've gotten that much working at least, lancepantz
14:37abrenkgiacecco: so I guess there's a problem as long as soons as you're in a namespace
14:37lancepantzdpritchett: i just decided it was time to learn emacs :)
14:38dpritchettI can start up the repl from within vim and *clojure-version* is showing 1.1.0
14:38lancepantzdpritchett: does omnicompletion work, that was always the problem i had
14:38dpritchettI had originally resolved to learn emacs along with clojure but I switched to vim when I grew tired of emacs and the 8 second start time
14:38giaceccoabrenk yeah!!! :-)
14:39dpritchettOmnicomplete is bringing up a box full of suggestions and automatically picking the right one. I have never actually used omnicomplete in vim before so I don't know if that's the expected behavior.
14:39lancepantzi'm pretty impressed with viper and vimpulse in emacs
14:39lancepantzi'm not using them though inorder to learn though
14:39dpritchettC-x C-o in insert mode autocompletes the word at the cursor
14:39giaceccoabrenk: thanks! I did not notice that!
14:39lancepantzdpritchett: it is, i would get a java exception from ng everytime
14:39abrenkgiacecco: that's stuff you definately need a second pair of eyes
14:41s450r1I only start emacs once just after my computer starts. After that I just open files from within emacs or use emacsclient, which is very fast.
14:42dpritchettSo how much am I missing working against 1.1.0? I mostly just want to explore Clojure but since labrepl is broken that's offputting.
14:43dpritchettI believe the next release of vimclojure will solve my problems but I don't know when to expect it.
14:43mmarczykbroken? how?
14:43mmarczykoh, and I'd say you're missing quite a lot
14:44mmarczykand if you're not (yet) using Clojure in production, why not explore *all* the cool stuff that's available
14:45dpritchettmmarczyk: Labrepl itself isn't broken I just can't get it to play well with the latest stable version of vimclojure and I haven't figured out how to make the dev version of vimclojure work at all.
14:45mmarczykdpritchett: ah, I see
14:46dpritchettAnd I've just gotten comfortable with vim, was hoping to avoid having to learn emacs along with the latest clojure
14:46mmarczykI regret to say that I can't bring myself to figure out how to start a Gradle build to try the latest vc :-(
14:47mmarczykyou wouldn't want to become bieditorial?
14:47mmarczykI always thought it was fun to go both ways :-)
14:49dpritchettI suppose learning emacs will be more beneficial than learning how to resolve this particularly dependency problem
14:54LauJensenchouser: Why both shell.clj and shell_out.clj ?
14:57stuartsierraLauJensen: renaming for 1.2
14:57stuartsierraLauJensen: renaming for 1.2
15:05LauJensenok, thanks
15:05LauJensenbtw stuartsierra, did you know that mv x y, where x and y are on the same fs, calls rename in stdio, which is atomic, but if they are not on the same fs, it calls cp, then rm :)
15:09stuartsierraLauJensen: I think I did know that
15:27bsderNewb question: I'm trying out the labrepl stuff in Enclojure on NetBeans in OS X.
15:27bsderAfter pulling the latest via git, it compiles and runs.
15:27bsderHowever, I get:
15:28bsderuser=> (source "println")
15:28bsder#<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol (NO_SOURCE_FILE:10)>
15:28bsderPresumably, somthing still needs to be installed. Any suggestions?
15:28dakronebsder: try (source println)
15:29bsder*smacks forehead*
15:29dakrone:)
15:29bsderdakrone: Thanks.
15:30dakroneno problem :)
15:43scodeIs there a more idiomatic way of converting a set of things to a map, than (apply conj {} (map (fn [p] [(:key p) p]) set-of-ps))?
15:49ataggartwhat's the element of the set look like?
15:49ataggartiow, how does one element become a key/value tuple
15:50ataggart(guessing form the code that the element has a :key property)
15:50scodeataggart: In this particular case, blog pages that will have an :fname key.
15:50scode(I just used :key in my question to generalize)
15:50chouser(zipmap (map :key set-of-ps) ps)
15:50ataggartcool
15:50ataggartdammit chris stop answering questions while I'm trying to understand them
15:51chouser(zipmap (map :key set-of-ps) set-of-ps)
15:51chouser:-) sorry
15:51ataggartlol
15:51scodechouser: Thanks! That's exactly as short and nice as I would have expected ;)
15:51dakroneis there a way to get protocol methods to follow :use's :as option? http://gist.github.com/400369
15:52ataggartdoesn't it just go into the ns around the defprotocol?
15:52ataggartah nvm
15:52ataggartread the comment
15:53dakrone2 completely different protocols
15:53dakronejust same method names
15:53ataggartya, you need to pick
15:53ataggartthough...
15:53dakroneyea, I just don't want to have to name everything <prefix>-score and <prefix>-rank
15:53dakroneit'd be nicer to do (scs/score _) and (cs/score _)
15:54ataggartor they should be *one* protocol
15:54ataggarta type can only implement one of them anyway
15:54dakroneI thought about that, but the 2 different protocols have differing other methods that I don't want them all to implement
15:55ataggartbreak up the protocls
15:55ataggarthave the type pick the n protocls it nees to implement
15:55dakronethey are broken up already?
15:55ataggartI mean, move score and rank to its own protocol
15:56ataggartif score and rank are the "same" in both protocols
15:56kotarakthis is normal use behaviour
15:56dakronethey aren't the same though, they have different arguments too
15:56dakronewould that be a problem?
15:56ataggartah very well then
15:56kotarakuse (require '[name.space :as space] [space.name :as name])
15:56ataggartyes, so they are truly not the same fn
15:56ataggartwhat kotarak said
15:57kotarakor (use [.. :as .. :only ()])
15:57ataggartrequire+as or use+only
15:57ataggartgood form
15:58kotarakuse should be used only with only, anyway. %)
15:58dakrone (:use [clomoios.contextsearcher :as cs] [cs.score :as cs-score]) doesn't seem to work
15:58dakroneoh wait, you said require, not use
15:58kotarakdakrone: as I said: this is normal use behaviour
15:58kotarakyup , exactly
15:59dakrone (:require [clomoios.contextsearcher :as cs] [cs.score :as cs-score]) doesn't work either though
15:59kotarakDid you reload your Repl?
16:00kotarakIf yes, what is the error. I would be surprised if it didn't work.
16:00dakronenot using a REPL, just running the file with clj to make sure it doesn't except like crazy when reading it
16:00dakroneah wait, fixed it
16:01ataggartscience!
16:01dakroneme being silly, thanks kotarak
16:01dakrone& ataggart
16:01kotarakdakrone: np :)
16:01ataggartyeah, I was approaching the problem from the protocol design side
16:02dakronethis highlights the need for Need
16:03dakronedid you just (load _) everything?
16:03kotarakbasically, yes.
16:04kotarakThen Stephen G. wrote things as a library in contrib.
16:05dakronevery helpful :)
16:19mmarczykis there a readable literal for the null character?
16:19mmarczyk,\a
16:19mmarczykI mean \^@ doesn't work
16:19clojurebot\a
16:19kotarak,\000
16:19clojurebotUnsupported character: \000
16:19kotarak,\u000
16:19clojurebotInvalid unicode character: \u000
16:19kotarak,(char 0)
16:19clojurebot\
16:20kotarakhmm, bug?
16:20mmarczyk,\u0000
16:20clojurebot\
16:20mmarczykthanks :-)
16:23arkahn,conj \u0000 \u0000
16:23clojurebot#<core$conj__4242 clojure.core$conj__4242@996e4>
16:25dpritchett If I've completely boffed my clojure install (mostly leiningen) and I'd like to wipe it and start over using lein deps what should I delete?
16:26tcrayfordlib
16:26tcrayfordwell are you installing lein?
16:26mmarczykif you have lein-stable set up
16:26mmarczyklein-stable clean
16:26tomoj~/.m2 ?
16:26clojurebotNo entiendo
16:37ataggartyeah rm -rf ~/.m2 should do it
17:01dpritchettFinally got everything the way I need it with emacs+starterkit+lein swank and labrepl. Tomorrow I'll start relearning emacs!
17:15mmarczykdpritchett: great, have fun :-)
17:53ninjuddthis makes no sense: i have 3 projects, A, B, and C where A depends on B and B depends on C. when i do "lein deps" in A, it doesn't pull down C
17:56ninjuddam i crazy?
17:57ninjuddseems like that is the whole point of a dependency management system, right?
17:59technomancyninjudd: somebody must not be declaring their dependencies correctly. either that, or one of the dependencies is a dev-dependency, and those are not transitive.
17:59arohneris there a place in lein to specify java options?
18:00ninjuddtechnomancy: does lein do something strange when one of those dependencies is clojure?
18:01technomancyninjudd: the only special-case for clojure is allowing you to omit the "org.clojure" group-id.
18:02ninjuddtechnomancy: so if B depends on clojure 1.2 and A depends on 1.1, there should be an error, right?
18:03technomancyninjudd: no, maven allows varying versions of the same dependency. the rules for determining which wins are very complicated though. you can use :exclusions to manually get rid of the one you don't want if it picks wrongly (in the faq in the readme)
18:06ninjuddtechnomancy: ok thanks. i just got transitive deps to work. it was a caching problem
18:09ninjuddhmm.. it chose clojure 1.1 though. seems like it would make more sense to choose 1.2 since it should be backwards-compatible
18:09DuneManexcept its not backwards compatible
18:10ninjuddbut it should be if it used semantive versioning
18:10ninjuddsemantic
18:10DuneManbut its not, so.
18:10DuneMan(hash-map ...) in 1.1 accepts duplicate keys, and in 1.2 throws duplicatekeyerror
18:10DuneManI'm sure there are others.
18:11ninjuddtechnomancy: does maven take advantage of semantic versioning? or do you just prefer that people use it?
18:12technomancyit's impossible to enforce semantic versioning.
18:12savanniAt least, in a fully automated way.
18:12ninjuddnot enforce
18:13ninjuddi mean, does maven infer semantic meaning from version numbers?
18:15ninjuddfor example, it could assume that if i require 2.1.0, then 2.2.0 is ok since it should be backwards compatible, but 3.0.0 is not ok
18:16boredomistHey, I was wondering how I could do some Java casting from Clojure. Specifically, Graphics => Graphics2D
18:16Chousukeboredomist: you shouldn't need to do any
18:16boredomistGraphics2D is a subclass of Graphics if you didn't know
18:16savanniThat kind of casting should be automatic as part of the subclassing system.
18:17boredomistOkay, that's convenient. Thanks :)
18:17kotarak(doc cast)
18:17clojurebot"([c x]); Throws a ClassCastException if x is not a c, else returns x."
18:17Chousukecast is useless :P
18:17savanniWell, sorta. Actually, I'm not sure what would happen if the system thinks you have a Graphics and you call a Graphics2D method on it.
18:17Chousukeyou'd get an exception.
18:18Chousukeor hm, not in clojure
18:19savanniI know I'm probably getting confused in here, but I'm thinking that if an object gets instantiated as a Graphics2D, there's nothing that would ever cause it to get upcast to Graphics.
18:19kotarakChousuke: cast is an assertion
18:19ChousukeIf you need to differentiate between Graphics and Graphics2d when making a method call or something you might need to add a type hint (I don't know if it's possible to overload in such a way though)
18:19lancepantz technomancy: do you have any idea what's up with the execute call in deps?
18:20Chousukekotarak: yeah, and it seems like no-one uses it ;P
18:20lancepantztechnomancy: i noticed the comment about the rogue thread
18:20kotarakChousuke: hehe, there several such functions, eg. sequence
18:20boredomistChousuke: yeah I tried a type hint, and it seemed to do the trick
18:25alexyksay I need to have 4 defn's differing only in 2-3 lines of a deep inner guts. Each defn takes parameters a and b. How can I make a macro which will produce each function -- how should I package the 2-3 lines of the "body"?
18:28savanniWhat if those 2-3 lines that are different are themselves functions that your big functions called?
18:28savanniYou could then pass the function you want into the single big function.
18:28tomojdeftemplate maybe?
18:29tomojdo-template, rather
18:29tomojor whatever the hell it is
18:30ninjuddalexy:
18:30ninjudd(defmacro foo [name & body]
18:30ninjudd `(defn ~name [~'a ~'b]
18:30ninjudd (do ~@body)))
18:30kotarakalexyk: depends on your macro: (defmacro fasten-seatbelt [clean-up & body] `(try ~@body (~'finally ~clean-up)))
18:30ninjuddjust throw your other logic around the do-body
18:31kotarakdo is not necessary, since defn does an implicit do anyway
18:31ivankhow do i get access to deftrace?
18:31ivankfrom a repl in emacs?
18:31ninjuddkotarak: it may be depending on what is around it
18:32alexykkotarak: say my body looks like: (let [x (f blah)] (assoc stats user x)) ; where stats and user come from the macro, i.e. common for all defns. Can I just apss it in quoted, '(let ...) ?
18:32alexykpass
18:32ninjuddyou don't have to quote it
18:33kotarakalexyk: just call it as (foo (let ...))
18:33alexykninjudd: do you mean I can avoid the macro with a do, saying do-body?
18:33ninjuddno
18:33alexykok :)
18:33ivankah, got it (use ...
18:34kotarakalexyk: (foo my-fn (let [x (f blah)] (assoc stats user x))
18:34alexyklooks like macros are cheaper ways to stick varying guts into things inside of typed languages' generics, where you'd painfully typify the said guts
18:34alexykkotarak: yep, cool
18:34kotarakalexyk: with ninjudd's foo from above
18:34alexykninjudd's foos rock! :)
18:35alexykabove: s/inside/instead/
18:35kotarakalexyk: the better design is probably putting your things into a driver function and expand into a macro, which calls the driver and passes it a function.
18:36alexykkotarak: brainknot ^^! :)
18:36kotarakalexyk: (defn driver [guts] (.... (guts stats user) ...)) (defmacro foo [& guts] `(driver (fn [~'stats ~'user] ~@guts)))
18:37kotarakalexyk: this has the added benefit, that you don't bar# all over the place and changing driver effects all callsites without recompilation.
18:37alexykkotarak: how can driver be defined if stats and user are in foo?
18:37alexykguts only use them, not define them
18:38alexykthat's why they're not self-contained, spilled guts
18:38ninjudddriver would be a function that takes stats and user
18:38alexykor driver is teh new foo?
18:38ninjuddi mean, guts would be a function that takes stats and user
18:39kotarakalexyk: ok more explicit: (defn driver [guts] (let [user (get-user) stats (retrieve-stats)] (do-other-boilerplate) (guts stats user)))
18:39kotarakalexyk: does this make sense?
18:39alexyklemme think
18:40alexykso how do I declare one real defn from foo -- is the defn's name implicit first parameter?
18:41kotarakOh, you need a defn? Then you need a macro and go with the first foo from ninjudd
18:41alexykyeah, my macro takes guts, produces a defn which must have a name and takes args [a b]
18:42alexykso that then I can call it at will
18:42alexykok, ninjudd's from above indeed
18:47alexykwhat's the difference between ~@x and ~'x?
18:48turbofail,(let [x '(a b c)] `(foo ~'x bar ~@x baz ~x))
18:48clojurebot(sandbox/foo x sandbox/bar a b c sandbox/baz (a b c))
18:49turbofail~'x is kind of a no-op
18:49clojurebot'Sea, mhuise.
18:52ninjudd~'x does symbol capture
18:52clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
18:52kotarak~'x should be used only after very careful thought. Very, very careful thought.
18:52clojurebot'x is kind of a no-op
18:53ninjuddquiet, clojurebot
18:53turbofaildoh... i've miseducated it
18:54alexykclojurebot: you will be reeducated in the rice fields
18:54clojurebotHuh?
18:54alexykclojurebot: too late to ask why
18:54ninjuddhttp://blog.danieljanus.pl/clojure/symbol-capture.html
18:54sexpbot"musings of a Lispnik — Daniel Janus's blog"
18:54clojurebotHuh?
18:54ninjuddmore explanation on symbol-capture: http://blog.danieljanus.pl/clojure/symbol-capture.html
18:54sexpbot"musings of a Lispnik — Daniel Janus's blog"
18:55alexykthx
18:57ninjuddthere's a section in stuart's book about it too
18:58ivanksince '() evals true, how should i do (or '() '(something else)) in closure?
18:58ivank*clojure?
19:00ivanki want to avoid doing a (reduce max '())
19:00wlangstrothivank: do you just want a test for emptiness?
19:00wlangstroth,(empty? '())
19:00clojurebottrue
19:00wlangstrothoh, I misunderstood
19:01ivankwlangstroth: test for emptiness but return the list if not empty
19:01ivankactually hacked around it
19:01somniumlike (when (seq xs) (reduce max xs))
19:01ivank(reduce max (cons 0 '()))
19:01Raynes"A group of us from the office went to see the movie Iron Man 2 (it just debuted in the United States), and it reminded us of Java, the Java community, and JavaOne." - Oracle
19:02savanni... eh?
19:02wlangstrothRaynes: ba-what?
19:02RaynesIndeed.
19:02ivanksomnium: i don't want to have to assign it to anything
19:02ivank(let [x 999] (reduce max (cons 0 (filter is-palindromic (map (fn [y] (* x y)) (range x 100 -1))))))
19:04somniumivank: ah, thats not really possible pointfree afaik, a common idiom is (when-let [x (seq ...)] (... x))
19:05somniumwell, you could make a (fn [x] (when (seq x) x ...)) and use it point-free I guess
19:07ivanki don't quite understand
19:07ivankwould you replace the (let with that?
19:07somniumwow, they werent kidding
19:07somniumhttp://www.oracle.com/marvel/index.html
19:07sexpbot"Oracle is co-promoting Ironman | Oracle, The World's Largest Enterprise Software Company"
19:08MadWombatthe damn clj-gae-datastore is missing a file :(
19:08wlangstrothRaynes: maybe they mean Java is a huge, barely-controlled explosion of mechanized teenage fantasy
19:11DuneManTeenage fantasy wouldn't have chosen such a repressive and unimpressive type system
19:13DuneManalthough the fixation on OO as the sole design paradigm does remind of certain young male obsessions gone awry.
19:13wlangstrothDuneMan: My point exactly.
19:13somniumivank: my half-baked idea was (let [decide (fn [xs full-> empty->] (when (seq xs) (full-> xs) (empty-> xs)))] (decide (filter f (map g ...)) (partial reduce max) 0))
19:17somnium,(let [decide (fn [xs a b] (if (seq xs) (a xs) b))] [(decide (range 1 6) (partial apply *) 42) (decide '() (partial apply *) 42)])
19:17clojurebot[120 42]
19:18somniumhalf-baked was probably too kind...
19:42_atoarohner: sure http://clojars.org/repo/autodoc/autodoc/0.7.1/autodoc-0.7.1.pom browse from http://clojars.org/repo/
19:43arohner_ato: thanks, found it
19:50rshdoes anyone have a recommendation for an html parser?
19:51tcrayfordenlive
19:55rshthanks
19:55cemerickenlive isn't an html parser, but OK :-)
20:23StartsWithKhttp://is.gd/c84Zu <- you have to load clojure in your own class loader (i can't post to -dev) or extract the native libs in tmp dir from jar (jline style)
20:32dysingerI heard there was an emacs vs ??? war going on in here
20:32dysingercan I get in a punch ?
20:32RaynesWHERE?
20:32clojurebotwhere is log
20:33dysinger:)
20:33dysingeroh it was on twitter nm
20:33dysingerand punches the nearest vim and/or IDE user
20:33hiredmanouch
20:35DuneManyour punches don't hurt me
20:35DuneManVIM PROTECTS ME
20:35technomancyhe must have forgotten to enable M-x punch-through-vim-protection-mode
20:35DuneMan*holds a a shield with the Bram Molenjaar crest on it*
20:35technomancyI have it activated in an erc hook.
20:40tomojtechnomancy: keyboard pants... awesome
20:40technomancytomoj: wearable computing is the future!
20:41tomojthen I'll never have an excuse not to be working :/
20:45cemerickdysinger: you'd be after me, probably :-P
20:46cemerickthough "war" is surely overstating it
20:47turbofailyes... this is more of a "polite expenditure of munitions"
20:48trptcolinwhoa looks like i picked a good evening for irc :)
20:52turbofailspeaking of which, clojure-on-cruise-missiles sounds like a great name for a framework of sorts
20:54chouserdysinger: you're involved in ClojureConj 2010, right? What's up with that?
20:55dysingerAmit and I both got too busy
20:55dysingerboth of us are working insane hours
20:55dysingerat the moment
20:56dysingerI want to see it happen though
20:56dysingerOh BTW speaking of crazy hours - I have room for 3 more on my team
20:56chouserheh
20:56chouserThat's good to hear, but I'm afraid I'm not qualified.
20:56dysingerhalp
20:56tomojif it happened, it would surely be the first conference I didn't have to pay to attend
21:16hiredmananyone know how to .property stuff in scriptjure?
21:39hugodanyone interested in maven plugins written in clojure?
21:42drewrhugod: of course
21:43hugoddrewr: so how does this look http://github.com/hugoduncan/clojure-mojo-example/blob/master/src/main/clojure/maven/clojure/example/plugin.clj
21:44drewrit's certainly terse
21:45drewrI haven't written a mvn plugin before, so I'll take your word on the correctness
21:45hugodwell, it looks pretty similar to the corresponding java
21:46wlangstrothanyone know if there's a haskell *words* equivalent in clojure? It's not like it would be hard to do, but it doesn't seem to exist in contrib.
21:48drewrwlangstroth: what does *words* do?
21:49wlangstrothdrewr: tokenizes words. Super simple, I just didn't want to make my own if one was already there.
21:49wlangstrothtokenizes words, throws them into a collection, I should say
21:50drewr*googles* you mean tokenizes a string of words into a list?
21:51drewr,(split #"\s+" "the quick brown fox yada yada")
21:51clojurebotjava.lang.Exception: Unable to resolve symbol: split in this context
21:51drewr,(clojure.contrib.string/split #"\s+" "the quick brown fox yada yada")
21:51clojurebotjava.lang.ClassNotFoundException: clojure.contrib.string
21:51drewr,(require 'clojure.contrib.string)
21:51clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
21:51drewrgrrr
21:51drewranyway, try that
21:51TheBusby,(use '[clojure.contrib.str-utils :only (re-split)])
21:51clojurebotnil
21:51rhudson,(.split #"\s+" "a b cdd e")
21:51clojurebot#<String[] [Ljava.lang.String;@1906e1d>
21:54TheBusby,(re-split #"\s+" "the quick brown fox yada yada")
21:54clojurebot("the" "quick" "brown" "fox" "yada" "yada")
21:54wlangstrothokay, re-split works. It seems like overkill when I know I'm always splitting on whitespace
21:55wlangstrothbut I'll check out the code - thanks
22:01wahzhow do you send an expression to the repl window in emacs using slime?
22:02dnolenwahz: C-x C-e from the last paren of the sexpr you want to send
22:03wahzthanks, but the result of the evaluation is shown in the minibuffer, but the expression itself is not sent to the repl
22:04wahzi.e. I would like it to be in the repl input history
22:23wahzI guess copy and paste will have to do for now :)
22:50vIkSiThm, (defn qsort [[pivot & xs]] .. ) - exactly what are the arguments to this function?
22:50qbgA sequence
22:50vIkSiTa vector of vectors?
22:50qbgIt does destructuring
22:50vIkSiTqbg, hmm, so a sequence how exactly? a pivot sequence, and an xs sequence?
22:50qbgNo, the first item becomes pivot, and the rest becomes xs
22:50vIkSiTqbg, could you explain a bit about th destructuring process (and how it works/gets invoked)?
22:51vIkSiTaah
22:51vIkSiTso basically, its like the head and tail
22:51qbgYes
22:52qbgSee http://clojure.org/special_forms#Special%20Forms--%28let%20[bindings*%20]%20exprs*%29
22:52vIkSiTso, if I were to declare a function like (defn myfn [[v1 v2 v3 & restelem]] ..)
22:52vIkSiTthen the first 3 elements of the seq are v1, v2 and v3..
22:52vIkSiTand restelem is the remaining sequence.
22:52qbgCorrect
22:52vIkSiTah great. thanks for the link as well
22:56tomojthat would be bad for google, I think
22:56tomojthough maybe "clojure cake" would be enough
22:56TheBusbyhave fun googling "clojure ->"
22:58ninjuddrake gets by ok
22:58ninjuddthough there are not as many search results for rake
22:59ninjuddfirst result for "clojure cake": You are what makes Clojure great - find some cake and celebrate! ...
23:02ninjuddTheBusby: that's google's fault, they need advanced options for searching for symbols
23:02TheBusbythat's certainly true, but it doesn't make it less frustrating
23:03ninjudd"clojure threading operator" returns some results
23:04TheBusbyI just wish we could add a few simple examples in the doc strings, and hence eliminate the need to google for examples
23:05tomojseen cljex?
23:05tomojand/or walton?
23:05tomojI think both of those are trying to address your concern
23:06TheBusbynot yet, but I'm excited to hear that and am googling them now
23:07tomojboth by defn
23:07TheBusbygreat work, I still wish the examples could be appended to the current doc strings though.
23:08tomojI think I like them outside the source where people can contribute/modify/interact without needing to commit into clojure
23:09TheBusbyhow much updating do you image would happen though for things like "concat" ?
23:10wlangstrothTheBusby: I'm working on it (more examples) but it's slow going
23:11TheBusbyunderstandably and I commend you for it.
23:11TheBusbyI'd volunteer my time as well but not until we finally decide upon where they fit in clojure
23:12TheBusbynot two months ago I expressed similars concerns and the consensus was to add examples to the wiki
23:13wlangstrothI'm just collecting them myself - sometimes off walton, but usually just doing the simplest thing possible with the function
23:13wlangstrotheventually, I'll get people to tell me which ones aren't helpful
23:13TheBusbyyeah, I have my own little cheat buffer I keep with examples for various calls
23:14TheBusbyI just wish the doc string looked more like a man page and less like a javadoc
23:14ninjuddwow! checking out walton. what a great idea
23:15lancepantzi use walton all the time
23:15lancepantzthought i had told you about it
23:15ninjuddbe nice if each example had the result too
23:15ninjuddlancepantz: maybe
23:16ninjuddi've never seen it in action though
23:16lancepantzthat would enforce all of them to be independently valid though
23:16lancepantzhe just scrapes the logs for inputs to the repl bot
23:16ninjuddseems invalid examples wouldn't be very useful
23:17ninjuddoh, you mean they may depend on other commands
23:17lancepantzyeah
23:17lancepantzi guess the repl bot would have the same problem though
23:17ninjudddoes it keep state?
23:17clojurebotmutable state is bad
23:18lancepantzhahaha
23:18ninjudd,(def foo 1)
23:18clojurebotDENIED
23:18ninjuddi see
23:19RaynesI'm fairly certain that walton scrapes the examples and runs each one of them to see if they are valid.
23:20lancepantzi thought he also had the book example in there
23:20lancepantzbut maybe thats just a planned thing
23:21wlangstrothTheBusby: are you keeping any of those examples in a public place?
23:21TheBusbywlangstroth: unfortunately not yet
23:21TheBusbyI'd be happy to give them out after I've cleaned them up a bit
23:24wlangstrothcool, thanks
23:28TheBusbyI've actually had the best luck so far just grepping through contrib
23:29TheBusbyI created a simple bash script that just does the following, "find ${CLOJURE_HOME}/clojure-contrib/src/clojure/contrib/ | grep clj$ | xargs -i grep --color=auto -inH $1 {}"
23:29TheBusbyfor more complex items like zipmap though, I've relied on google
23:37arohnerclojure needs a *warn-on-slow-math*