#clojure logs

2009-04-20

00:22AWizzArd~ max people
00:22AWizzArdachso
00:43Lau_of_DKHard-coding it on every route gets the job done, but it defies the documentation of Ring
01:03AWizzArdYes, it would be good to be able to give a default header, and if needed, a specific one inside the GET, which overrides the default one.
01:05Lau_of_DKExactly, but the default seems to be boorked
01:05Lau_of_DKMaybe a Ring/Compojure version mismatch
01:14cgrayhi, how do you reload a jar file from the repl?
01:20hoeckcgray: reload the clojure code or the (java) classes inside the jar? For clojure code, a (require 'my-namespace :reload) should do the job.
01:21cgrayhoeck: the classes from a different jar file (i.e. not the clojure.jar)
01:23cgrayaccording to google, i need to restart clojure...
01:23cgraybrb
01:23hoeckcgray: there are the same limits as to java class reloading, so once loaded, you need to restart the jvm to load the new classes
01:24cgrayhi again, sorry, my window manager locked up
01:25cgrayi missed the last message i think
01:27hoeckyou need to restart clojure, thats right
01:27hoeckthis is a jvm limitation
01:28cgrayok, that shouldn't be a big problem
01:28hoeckthere is a (commercial) program to allow arbitrary class reloading for the jvm, called javarebel
01:35Lau_of_DK...or Clojures own stub system
01:35eevar2___cgray: http://blog.taragana.com/index.php/archive/how-to-unload-java-class/
02:14kadaverhttp://hpaste.org/fastcgi/hpaste.fcgi/view?id=3978#a3978 <- exiting swing does work properly after i added that
02:14kadaverany obvious error?
02:14kadaveri added the write-to-file stuff
02:14kadaverSystem/exit 0 worked before
02:16Chousukedoes it hang or something?
02:16kadaveryes
02:16kadaveri click X but nothing happens
02:16kadaverdoesnt hang
02:16Chousukehm
02:17Chousukedoesn't that have a misplaced paren?
02:17Chousukeah, no.
02:17Chousukemy guess is it throws and exception when writing the file
02:18Chousukeand the System/exit never gets called.
02:20Chousukerun in from the console and see what it prints.
02:20Chousukeanyway, I'm off
02:23kadaveryeah
02:23kadaver(defn create-exit [playerstate]
02:23kadaver (proxy [WindowAdapter] []
02:23kadaver (windowClosing [evt]
02:23kadavershould proxy or windowClosing have more args?
02:23kadaver Wrong number of args passed to: guilogic$create-exit--429$fn--4
02:30kadaverah
02:30kadaveri was not derefing(@)
02:30kadaverbut
02:30kadaver(reduce #(str %1 "#" %2) "" (@playerstate :playlist))
02:30kadaver(reduce #(str %1 "#" %2) (@playerstate :playlist))
02:30kadaverthe 2nd works in the repl but not when compiled
02:42kadaverwouldn't (nth n coll) be better?
02:42kadaveri find it more natural to write it that way
02:50cgrayit seems like i'm having some trouble. i'm doing (ns foo (:import (bar) (baz))), and trying to evaluate that within a file using slime. but if i evaluate *ns* in the file, it tells me user
02:51jdzi put an (in-ns 'foo) after that
02:51jdzseems to work
02:51AWizzArdIs there something like (def- x 123) vs (def #^{:private true} x 123)?
02:51jdzbut should be fixed
02:52cgrayjdz: even that is not working
02:53jdztry re-oponing the file
02:53jdzre-opening even
02:54cgrayhow about that
02:54cgrayit works
02:55jdzthe (in-ns ...) form should be at column 0. so i put a #_ on the previous line. that's because the (ns ...) form automatically switches to the declared ns
02:55jdzsomebody not-lazy should go and fix clojure mode :/
02:58AWizzArdYes, there were no updates for the clojure-mode and swank-clojure anymore now...
02:59jdzhuh? i got updates today even
02:59jdzto swank-clojure
02:59jdzit uses pprint now
03:01jdzdamn, looks like slime-edit-definition is broken now...
03:03AWizzArdah oki, so clojure-mode was without updates
03:08RaynesOracle bought Sun.
03:08Rayneshttp://in.sys-con.com/node/925931
03:09rsynnottpretending to buy Sun is a traditional activity of large IT companies going through difficult times
03:09rsynnottI'll believe it when I see it
03:09tWipsun.com has the news also
03:10jdzthe in.sys-con.com has ads with sound!
03:10jdzffs
03:10jdzit's year 2009
03:16Raynesrsynnott: http://www.sun.com/aboutsun/pr/2009-04/sunflash.20090420.1.xml
03:16RaynesYou've seen it.
03:16RaynesMight want to believe it now.
03:20rsynnottheh
03:28rsynnottpoor sparc :(
03:35AWizzArdMaybe Oracle has better arguments to sell those sparcs.
03:37rsynnottThere is a lot of talk of Java and Solaris on the press release, I note
03:37rsynnottnot so much of poor Sparc
03:37rsynnott(or MySQL, but Oracle already owned the interesting bits of that)
04:04AWizzArdTo ask the Oracle about the future of Java now gets a whole new meaning...
04:05rsynnottwell, they're unlikely to kill it
04:06rsynnott(not that they could; IBM is surely at least a big driving force behind modern Java as Sun is)
04:06bstephensonI wonder about (fear for?) the future of Sun's open-source apps like Glassfish, OpenOffice and NetBeans, much less MySQL.
04:07rsynnottOracle have owned InnoDB since 2005 anyway
04:07rsynnottand they license BDB in much the same way as MySQL is licensed by MySQL AB and Sun
04:07rsynnottso it'll probably be fine
04:25AWizzArdMaybe upcoming JDKs will cost a nice license fee.
04:31RaynesI'll blow my head off and have the remains sent to Oracles doorstep.
04:31Raynes:|
04:31tWipa bit drastic
04:35Raynes"Guess I'd better start learning PostGreSql and F#/Mono instead of Clojure." Now that is a bit drastic.
04:36bstephensonI agree about OpenOffice, more a comment on philosophy than the specific product. I (or really the company I worked for) have been the victim of Oracle's CRAZY seat licensing in the past, so I always view Oracle with a somewhat jaundiced eye.
04:38p_lI had seen Oracle downplay a *big*, *important* company bugreports about Oracle server getting OOM-killed. We had highest support levels
04:39cp2whats going on?
04:39cp2oracle bought sun/java/??? ?
04:39p_lcp2: yup
04:39p_l~$9.60/share
04:39cp2lol
04:40cp2damn
04:40cp2this is what happens
04:40cp2when you sleep
04:40cp2miss out on interesting news
04:40p_lgod bless them for opensourcing Solaris and lot of other stuff
04:41RaynesMySQL is dead. Long live MySQL!
04:41p_lRaynes: that's the good part of those news :P
04:41Raynes:p
04:42RaynesI hope people don't freak and drop Clojure and run for the hills.
04:42jdzwhat's SUN's market ticker (or whatever it is called)?
04:42rsynnottJAVA
04:42rsynnott(when it was IBM buying them, I vaguely thought it was because they wanted the ticker)
04:43rsynnottwhen it was Apple buying them (this happened about six times) I just assumed lack-of-Jobs-induced-insanity
04:44dnolenis there a function to convert a String to an InputStream in Clojure?
04:45jdzsome class having StringReader in it?
04:46gnuvinceDoes anyone know a free tool to make *nice* looking charts and plots?
04:46jdzgoogle charts?
04:46gnuvinceEmphasis on the *nice*; I need it for a one-off graph, and it'd be nice if it was a beautiful one.
04:47jdzgoogle charts looked very nice last time i saw them
04:47rsynnottgoogle's ones are quite nice
04:47jdzand don't all presentation apps allow one to create charts?
04:47stuhooddnolen: i would use String.getBytes() into a ByteArrayInputStream
04:47rsynnottbut careful! Confusingly they have two chart apis, which are completely different
04:48gnuvincejdz: oh, I didn't think about PowerPoint
04:48rsynnott(one is highly AJAXy, and thus confined to Gooogle Labs)
04:48jdzwell, i had Keynote in mind :)
04:48jdzwhile speaking of *nice*
04:49AWizzArdThe install path for Java 7 will be /u02/app23/sys/ucb/myjdkoraql/1002.12.3.45.2.2.3/vm_42/{bin,lib,etc,mesg,crs}. The machine will have Load 27 during a Thread/sleep. For finetuning pay 400$ per hour for consultants :)
04:49dnolenstuhood: thx
04:49jdzNumbers also can make a nice looking charts. too bad the app cannot be used to calculate stuff
04:49rsynnottin fairness, sun is quite keen on terrible, terrible paths, itself
04:51noidignuvince, if you know python, then matplotlib is nice http://matplotlib.sourceforge.net/
04:56gnuvincenoidi: I could try that as well... I need the first quadrant of a f(x) = 1/x curve and I want to tag some points (although I can do that with Photoshop if I need to)
04:57jdzthe matplotlib actually looks very nice for exactly this purpose
04:57jdzan example: http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo2.html
04:57gnuvinceVery, very nice
04:58gnuvinceI think we have a winner
04:58cp2oracle did a union query while the sun execs weren't looking
04:58cp2now they can't split without compromising DB integrity
04:58cp2hah
05:08stuhoodits a good thing sun already open sourced java
05:11cp2indeed
05:11cp2even if oracle does close it up, people will just fork
05:11cp2no worries
06:02danlarkinso Oracle buys Sun eh?
06:05danlarkinI wonder what that means for mysql
06:05Raynes"MySQL is dead. Long live MySQL!"
06:09Raynesfor(n <- 1 to 1000 if n % 3 == 0) yield n
06:09RaynesOops, wrong window. :>
06:11cgraydoes anyone have experience creating a SecurityManager that prevents a library from killing clojure with a call to System.exit() ?
06:16cemerickcgray: clojurebot does this. I think hiredman might have blogged about the details at some point?
06:16hiredmanme? I don't blog
06:16stuhoodcgray: prolly in here somewheres: http://github.com/hiredman/clojurebot/blob/3cf335c748045fbce0aa92c82289a8df5a81063d/hiredman/sandbox.clj
06:16cgraythanks
06:17cemerickhiredman: hrm. Then someone else is blogging about clojurebot somewhere :-)
06:18hiredmaneverything I know about jvm sandboxing I cribbed from http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
06:20cgrayaha, thanks. i was just going to complain that the policy is too strict, but i see that you can change that with a .java.policy file
07:21hiredmanhttp://code.google.com/p/clojure-contrib/wiki/DatalogOverview incase anyone hasn't seen it yet
07:24replacathat should set the standard for how we documentt our stuff!
07:25replacaJeffery set a great example there
07:26cp2looks pretty neat hiredman
07:29danlarkinmakes me want to play with datalog :)
07:36mattreplhiredman: neat!
07:38peregrine81Hello everyone. My goal is to learn lisp, using clojure. What is the best place to start
07:38peregrine81?*
07:39technomancyperegrine81: the Clojure book from pragprog.com is quite good.
07:39technomancyalso: in a couple days my clojure introduction screencast will be available from peepcode.com
07:39technomancybut I'll understand if you don't want to wait for it. =)
07:40peregrine81anything freely available?
07:40technomancythere's the wiki, but it's kind of messy.
07:40technomancythe book is definitely worth it; I think it's only around $20 if you get just the PDF.
07:41danlarkinhey technomancy, want to see my progress on an http library so far?
07:41technomancydanlarkin: yeah; let's see it
07:41peregrine81Alright, would it be possible to easily follow along with PCL with clojure?
07:41technomancyperegrine81: there's some blog posts that port portions of it over
07:42technomancyperegrine81: but the original book will only be marginally helpful
07:42dliebkeperegrine81: I like Mark Volkman's introduction: http://java.ociweb.com/mark/clojure/article.html
07:43Raynesperegrine81: http://ociweb.com/jnb/jnbMar2009.html is a good starting point, but you're going to want the book eventually.
07:43danlarkintechnomancy: ok I'll gist it... it's not done... I'm not positive I like the way I'm doing it yet... I think I made it too high level and it's missing some features, but it's almost there
07:43Raynesdliebke: Great minds think alike. :)
07:43dliebke:)
07:43zakwilsonperegrine81: do you know Java already?
07:43peregrine81Cool
07:43hiredmanperegrine81: search for CS61A on youtube, it's berkeley's version of structure and interpretation of computer programs
07:43peregrine81zakwilson: Yes :)
07:44peregrine81Unfortunately
07:44danlarkintechnomancy: http://gist.github.com/98612
07:44technomancydanlarkin: do you have any tests for it yet?
07:44zakwilsonGood - it helps with actually getting stuff done in Clojure because it's easier to read the documentation for various libraries.
07:44danlarkintechnomancy: no :-o *gasp*
07:45technomancydanlarkin: I was wondering how you'd go about that; is there any way to serve HTTP from just the stock JDK?
07:45zakwilsonIs it possible to stick a native executable inside an executable jar and call it from your code?
07:45cp2Runtime.exec
07:46cp2but thats messy
07:46cp2and discouraged
07:46danlarkintechnomancy: oh... mmm... easily? I'm not sure, but you can always call something like example.com
07:46technomancydanlarkin: yeah, but having tests that don't work when the network is down is not so hot
07:46technomancydanlarkin: plus you'd need the response to vary based on headers etc.
07:47Lau_of_DKtechnomancy: "the book from pragprog" , is that Stuarts book ?
07:47technomancyLau_of_DK: yeah
07:47technomancydanlarkin: it'd be a shame to make the test suite require (for instance) having jetty on the classpath, but that's better than nothing
07:47technomancyhmmm
07:47technomancyanyway this looks good
07:47Lau_of_DKI'd be careful giving such pricey advice to new-comers, as the first option
07:47Lau_of_DKMost people here have learnt Clojure, through the free resources scattered across the web
07:48technomancyLau_of_DK: well my $9 peepcode isn't out yet. =)
07:48technomancyI guess it depends on how interested you are. =)
07:48Lau_of_DKAnd the signal we want to send
07:49Lau_of_DKIts your call, but it stuck out :)
07:49cp2technomancy: torrent now, pay later? :)
07:49technomancyperegrine81: the "Clojure for (Java|Lisp) programmers" presentations are very good too. They won't teach you the practical aspects of clojure, but they'll show you the philosophy and motivation.
07:51hiredmanI was looking at berkeley's cs61a videos on youtube, and they seem a very gentle intro to lisp
07:51hiredmanusing scheme
07:53hiredmancs61a (the java course) is the most boring thing ever btw
08:36unlinkIs there any way of annotating a string with metadata?
08:36technomancyvalues don't have metadata, vars do
08:37unlinkok
08:38stuhoodso you could add the metadata to a def statement for a var containing the string, I think
08:38rhickeytechnomancy: no - map/set/vector/symbol values can have metadata, just not string/numbers etc
08:38hiredman:(
08:39technomancyah, gotcha. so it's just that the built-in types aren't extensible.
08:39unlinkso why does this evaluate to nil? (meta (let [x "hi"] #^:a x))
08:41taggart,(let [x "hi"] #^:a x)
08:41stuhoodbecause you are trying to attach the metadata directly to the string: isn't a 'var' in that case, its a local, right?
08:42unlinkSo it's impossible to return metadata-annotated strings from a function?
08:42hiredmanyes
08:43hiredmanstrings are java.lang.String
08:43hiredmanwhich is a final class
08:43hiredmanso not extensible
08:43unlinkok. I was trying to mark strings as "escaped" or "not-to-be-escaped"
08:43technomancyeven if it were subclassable, having a clojure-specific string type floating around and having to figure out which is which would be pretty confusing
08:44technomancyfor java interop work at least
08:44taggartit would make interop a nightmare
08:45stuhoodespecially since java.lang.String is final
08:45technomancyI can understand the motivation for not allowing classes to be modified after they're defined, but I can't imagine a good reason for keeping people from subclassing classes.
08:45technomancyis there one? or is it just one of Those Crazy Java things?
08:45taggartsecurity iirc
08:45hiredmanvoodoo
08:46unlinkOK, so what would be the idiomatic way of achieving this? pass around an application-defined datastructure which has a string and escape status?
08:46taggartmaybe oracle will fix it for you ;)
08:47technomancyunlink: you sure you can't just escape it immediately upon receiving it from whatever source? then you'd never have to deal with unescaped strings.
08:47unlinkI'm writing a library. I'd like to provide a "secure-by-default" option.
08:48unlinkUnfortunately it's unidiomatic in virtually every programming language.
08:50unlinkIt's even awkward in Python, which is not exactly famous for its rigid type system.
08:51stuhoodunlink: yea, i think you'll need a wrapper around the string
08:52taggartif symbols support metadata, then why doesn't the following work?
08:52taggart(def #^{:a "test"} mystr "hi")
08:52hiredmanthe CharSequence final?
08:53hiredmanunlink: you could use CharSequence instead of Strings
08:53hiredmanhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/CharSequence.html
08:53hiredmanproxy that and add metadata support
08:54stuhoodhiredman: or perhaps StringBuffer/Builder, since CharSequence is an interface
08:54hiredmanI think there is a String constructor that takes a CharSequence so the conversion would be easy
08:54stuhoodack, both are final...
08:54hiredmanstuhood: but Buffer and Builder are mutable :(
08:55hiredmanyeah, better stick with CharSequence
08:55hiredmanugh
08:55unlinkClojure's greatest strength is also its greatest weakness!
08:55hiredmanI hate this, I want clojurebot and I want my server online so I have a clojure repl and vim and etc
08:56stuhood /mourn clojurebot
08:57unlinkWhat happened to it? Server melted?
08:58hiredman(defn make-char-sequence [string]
08:58hiredman (proxy [java.lang.CharSequence]
08:58hiredman (charAt [i] (.charAt string i))
08:58hiredman (length [] (.length string))))
08:58hiredmanetc
08:58hiredmanactually adding metadata support is an exercise for the reader
08:58hiredmanunlink: reports are sketchy
08:59hiredmanthe server already had a hard drive die over christmas
09:00hiredmanthe machine right next to it (I presume, I haven't actually been to the physical location in a few years) as an uptime pushing 320 days
09:02scottjI'm trying to get a collection of all the numerical values in an html table with the condition that they have decimal places and there are 28 cells that match that condition. my regex is matching a section larger than one table and re-seq only gives the values in the last cell and I wonder if the problem is something obvious. The re looks like #"\<table.+?(\<td.*?\>(\d+\.\d+)\</td\>.*?){28}.*?\</table\>"
09:05rhickeyunlink: you definitely don't want to derive from String even if you could - there's no way to control the provenance of every string in a system, and you'd be checking if this was a String or a MyString everywhere, doing lots of conversions etc - ad hoc concrete derivation is bad
09:07unlinkrhickey: There would essentially be a single consumer of these objects, a function which prepares an HTTP response, and it would be the only method which cares whether it's a String or MyString.
09:07rhickeyunlink: then just use a map {:escaped true :val "foo"}
09:08unlinkWhat I meant is, everything in between would want to see something String-y, not caring whether it's a String or MyString.
09:09hiredmanunlink: if you use something that implements CharSequence and IMeta (I think it's IMeta) you get something that is basically a String, but with metadata
09:09rhickeywhat hiredman said
09:10hiredmanideally most things would not specify String but CharSequence in their interface
09:10hiredmanbut somehow I doubt that is case
09:10unlinkok.
09:10unlinkGood to know.
09:10rhickeyhiredman: unfortunately that's not true of some of Clojure - could you enter an issue for it please - use CharSequence when possible?
09:11hiredmanuh
09:11hiredmanok
09:11stuhoodsoo, ((partial + 1 2)) returns 3, but ((partial constantly true)) returns a function... hmm
09:11hiredmanmy first issue!
09:11unlinkHow does unicode work in clojure?
09:12rhickeyunlink: same as Java
09:14unlinkHow do I get bytes?
09:14hiredmanunlink: String has .getBytes
09:14hiredmanwhich returns an array of bytes
09:14stuhood(.getBytes "blah")
09:15taggartmore of that at the interop page: http://clojure.org/java_interop
09:15unlinkwhoops, I broke my clojure
09:15hiredmanand the String javadoc
09:16unlinkhttp://dpaste.com/35980/
09:16Chousukestuhood: isn't that what it's supposed to do. (constantly true) returns a function
09:17hiredmanunlink: I would try again
09:17unlinkI'm starting clojure via rlwrap --remember -c -b "(){}[],^%$#@\"\";:''|\\" java -cp clojure.jar:clojure-contrib.jar:. clojure.lang.Repl
09:17hiredmanunlink: is it repeatable?
09:17taggartChousuke: I think his point was that (partial + 1 2) should also return a function
09:17Chousuketaggart: it
09:17Chousukeer
09:17taggartoh, nvm, missed the double parns
09:17Chousukeit does
09:18unlinkI can't repeat it.
09:18hiredmanghosts in the machine
09:19hiredmanevidence of the underlying procedural nature of the machine
09:19unlinkhaha
09:19albinoI hope that's ghosts in the jvm and not ghosts in the physical cpu
09:19unlinkThat works in #haskell.
09:21unlinkI love the comically long stack traces produced by compojre.
09:21hiredmanbreaking news: I have been informed that the latest theory put forth by the man charged with bringing the machine that runs clojurebot back online is: bad ram
09:24unlinkAh, as it turns out, clojure requires RAM to operate.
09:27stuhoodChousuke, taggart: one executes the returned function, and the other doesn't... that is the weird part
09:28Chousukestuhood: it does execute it.
09:28Chousukestuhood: it's just that in the latter case it runs a function that returns a function
09:28Chousukewhile in the former it runs a function that returns an integer.
09:28taggartstuhood: a successful invocation of + returns a number, a successful invocation of constantly is a function
09:29stuhoodagh... indeed
09:30unlinkHow low-level is the bytecode generated by clojure?
09:30Chousukelow-level?
09:30Chousukeit's JVM bytecode.
09:30unlinkIt does emit JVM bytecode, correct?
09:31technomancyis there a nicer way to browse the JDK documentation than just googling for javadoc?
09:32unlink:W
09:32taggarthttp://java.sun.com/javase/6/docs/api/ ?
09:32unlink...
09:33technomancypackage
09:34technomancyoh are you kidding me? it makes you download it manually.
09:35dliebkeI also like to use clojure.contrib.repl-utils/javadoc
09:36unlinklol @technomancy
09:36unlinkI ran into that last night.
09:37technomancydliebke: that works. Wonder if it could be adapted to a local copy of the documentation.
09:38dliebkegood question, I haven't looked at the source
09:38technomancyunlink: it makes the debian DFSG problems look like nothing.
09:39unlinkI'm sure all these problems will change with the new management.
09:40unlinkDon't forget to chown root:root.
09:41technomancyunlink: hah. no.
09:42technomancyif I'm going to download it manually, why would I use the package manager?
09:42unlinkTo unpack it in the correct directory, of course.
09:42unlinkAnd don't forget the debian changelog.
09:43technomancygood stuff
10:15HAppyKAmikazesay i'm totally new to this language, where i can find good documentation apart from clojure.org?
10:16gnuvinceHAppyKAmikaze: there's a book: http://www.pragprog.com/titles/shcloj/programming-clojure
10:16hiredmanHAppyKAmikaze: prior lisp experience?
10:16HAppyKAmikazeis still a beta book
10:16hiredmanprior java?
10:16HAppyKAmikazeisn't it?
10:16arohner_HAppyKAmikaze: it's still a beta language :-)
10:16HAppyKAmikazesay java
10:16hiredmanit is like | | close to publishing
10:16gnuvinceHAppyKAmikaze: yes, but it's practically done, and it's been useful for a long time.
10:16RaynesHAppyKAmikaze: The book is complete, just maybe a few typos. And a little content could be added before now and when it's published.
10:16RaynesWell, before it's printed.
10:16hiredmanHAppyKAmikaze: there is a blip.tv into video "clojure for java programers"
10:16RaynesIt's already published.
10:17HAppyKAmikazesay ok book and tv! thanks
10:17hiredmanall the docs on the api webpage are availble from the repl using the doc command
10:17Raynes,(doc println)
10:18hiredmanall the javadocs on the internet have some relevence
10:22RaynesWhere is clojurebot. :(
10:23hiredmanhttp://delicious.com/clojurebot has some urls to might be useful for clojure
10:23hiredmanRaynes: current theory is bad ram
10:55technomancyhas anyone used any of the javadoc Emacs mode?
10:55technomancy*modes
11:01technomancylooks like javadoc-help does the trick; it's just got a not-so-hot interface
16:44unlinkHow is "\a\b\c" read?
16:44Chouseras an error
16:45Chouserjava.lang.Exception: Unsupported escape character: \a
16:45unlinkThe quotes were intended to delineate the input
16:45Chouseroh
16:45Chouserthree literal Characters
16:45kotarakAs three chacters: a b and c.
16:46unlinkWhat is the type of "three characters"?
16:46kotarak,(class \a)
16:46kotarakHmm.. no bot..
16:46Chouser(nth [\a\b\c] 1) --> \b
16:46dliebkejava.lang.Character
16:46unlinkOh, I got it
16:46kotarak1:1 user=> (class \a)
16:46kotarakjava.lang.Character
16:47unlinkI didn't realize that you could just throw a bunch of whitespace-separated values at the repl
16:47stuhoodand apparently non-whitespace separated in this case
16:47unlinkright
16:47unlinkbut I guess that's just the imperative construct in clojure
16:47stuhooder, non-separated
16:49Chouserstuhood: hah
16:56zakwilsonIf I want to find out if an executable is in my path from Clojure (the equivilent of running 'which foo' in a shell), is there an easy way to do that?
16:56arohner_the path is a construct created by the shell
16:57cemerickRuntime.exec("which foo")? :-P
16:57arohner_zakwilson: I'm not aware of a good clojure wrapper yet, but it sounds like it would be useful
16:58cemerickI'll bet there's a handy OS-process lib that will do that, maybe in apache-land.
16:58zakwilsoncemerick: can't count on which being available.
16:58cemerickzakwilson: thus the :-P ;-)
16:58zakwilsonI'll just do it by hand for now. This doesn't need to be production quality code.
17:00cemerickzakwilson: there's http://commons.apache.org/exec/ -- never even downloaded it, but it's ripped from ant, so that's something.
17:11arohner_anyone know what this means?
17:11arohner_Clojure
17:11arohner_java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V (start.clj:0)
17:11arohner_user=>
17:15kotarakarohner_: make sure you do an "ant clean" in your Clojure and/or contrib build.
17:15kotaraksome AOT compiled code wants to call the MultiFn constructor replace some revisions ago.
17:18arohner_kotarak: thanks
17:25arohner_ah, compojure was a culprit as well
17:26arohner_that was trickier because it wanted a copy of clojure.jar in compojure/deps
17:26unlinkIt doesn't seem that compojure works too well with clojure-svn
17:40unlinkWhere can I read "A Friendly Introduction To Lisp Macros, Clojure Edition"?
17:47technomancythere's a macros chapter in the book, isn't there?
17:49unlinkOh, there's a book?
17:49kotarak"Programming Clojure"
17:50unlinkOh, that kind of book.
17:50technomancyThe Book
17:50technomancyis that better? =)
17:51unlinkIs it worth it? Will I save more than half an hour by reading the book versus figuring it out the long way?
17:52technomancydepends on what you're trying to do
17:52alviviIf you're a programming guru, of course yes ;)
17:52technomancybut in the long run the answer is yes.
17:52unlinkBooks were unhelpful in mastering Python.
17:53unlinkBut Python is better documented than Clojure.
17:53technomancyyou might not need the book if you already know a significant amount of CL or Scheme, but I still found it helpful.
17:53technomancymacros are a really tricky topic, too
17:53unlinkOh no, now I want Programming Scala and Programming Groovy.
17:54technomancybuying books is dangerous
17:54unlinkI should probably limit myself to one new JVM language after the events of this morning.
17:54unlinkBut...the Java libraries...they call...
17:55technomancyone language per year is a good baseline
17:55unlinkWell I haven't learned a new language since 2007.
17:55unlinkWait, I learned a new on this yera.
17:55unlinkIf you can call PHP a language.
17:56unlinkDon't worry, we ended up rewriting the project in Django.
17:57unlinkAll right, you guys better be right about this book, I'm plunging $21 into it :-)
17:57unlinkIs one of you the author? >_>
17:57technomancyhe's online sometimes, but not right now
17:59unlinkOK.
18:01unlinkHmm, is EPL standard practice in Clojure-land?
18:02kotarakMostly, I use mostly MIT, I think I saw also GPL somewhere, but EPL seems very widespread.
18:02unlinkOK, people aren't going to shun me if I MIT then
18:05unlinkI like it when people bill me and deny me access to the product I paid for. What am I talking about, I *love* when that happens.
18:06sohailunlink, which product?
18:06sohailare you supposed to get a license in the mail?
18:06sohailemail that is
18:06unlinkProgramming Clojure
18:07sohailah
18:07sohaildunno how they do that one
18:07unlinkVery crafty of them.
18:07sohailI make sure that my licenses get sent out immediately and email them manually when I get a chance to make sure they have it
18:07sohails/immediately/automatically/
18:08unlink You must log in as the owner to download that file.
18:08technomancytrying to fetch it with wget or something?
18:10unlinkno
18:10unlinkI'm trying to do /exactly what the email instructions tell me to do/
18:10unlinkOK, my transaction costs have already totaled 10 minutes of effing around with this. I'm not happy.
18:12unlinka HA!
18:12unlinkThey associated my order with paypal email address, not with the one I used to register with the site.
18:12unlinkOf course, why didn't I think of that.
19:44technomancycgrand-rec: hey, I'm trying out the new enlive code
19:44technomancyI'm wondering if it's worth renaming "empty" so it doesn't conflict with clojure core
20:33kadaverhttp://code.google.com/p/clojure-contrib/wiki/DatalogOverview who made it?
20:33kadavercool stuff
21:34eeehello
21:34eeei was looking at the cookbook
21:35eeebut lost on a simple thing
21:35eeesort of rusty
21:35eeei made a set: (def a (sorted-set))
21:35eeeand now I want to loop, redefining set
21:36eeeone item at a time
21:36eeeinserting into the set
21:36eeei tried this
21:36eee(dotimes [q 40] (def a (conj a 2)))
21:36eeei am sure that's a hack
21:37eeeultimately I will time it
21:38dnolen_eee: data structures in clojure are immutable, you're just redefining a 40 times
21:38eeeyup
21:38eeei want to see how long it takes to do inserts
21:38eeeto compare to my own immutable datastructure
21:38eeeoh, you mean a doesn't
21:38eeeaccumulate
21:39eeeeven though I redefine it
21:39eeebased on old value
21:39eeeso I have to loop recur
21:39dnolen_have you created you're own sorted set java class?
21:39eeeodd that it doesn't take on the new value each time through the dotimes
21:40eeeI have a different datastructure that I will time next
21:40eeebut for now trying with sorted set
21:40dnolen_eee: because a is immutable, nothing takes a new value in clojure without using one of the mutation constructs.
21:40eeefrom clojure
21:40eeeok
21:40eeeso I'll rewrite with loop-recur
21:40eeeis conj the right way to add to a set?
21:41eeei didn't find insert, add, or append
21:44dnolen_conj works yes.
21:45dnolen_,(+ 1 2)
21:45dnolen_hmm no clojurebot.
21:46eeeoh, I know why now
21:46eeemy orig question
21:46eeebecause a set
21:46eeeuniquifies
21:46dnolen_yup
21:46eeeany object like a sorted vector?
21:48eeeyes
21:48eee(def a (vector)) (dotimes [q 40] (def a (conj a 2)))
21:48eeethat works like I'd think
21:48eeewas the dedup
21:48eeeso I need to replace 2 with a rand
21:50dnolen_eee: so what exactly are trying to accomplish again?
21:50eeei made a new thing for clojure
21:50eeeand someone suggested
21:50eeethat I profile it
21:50eeeagainst sorted set
21:50eeeso I will
21:50eeealready one diff
21:50eeemine needn't be unique
21:51eeebut also
21:51eeemy sort is semi-lazy
21:51eeeand does other things
22:14eeeanyone here use clojure-dev?
22:14eeeeclipse
22:15eeerepl isn't starting, at any rate
22:19eeeworked around it
22:47eeewow. looks like I'm trumping sorted-set right now
22:47eeeexciting
22:47eeepurely functional too
22:48eeeprobably my bad clojure
22:48eeewhat would be the best way to pop things off the front of a sorted set one by one, returning a new sorted set?
22:49eeei'm just calling (rest)
22:49Carkthat's how i would do it
22:49Carkbut then you get a lazy seq i guess
22:49Carkthat's not a sorted set anymore
22:50eee(time (def aa (loop [ret a] (if ret (recur (rest a)) ret))))
22:50eeethat look fair?
22:50eeeagainst my heap:
22:50eee(time (def bb (loop [ret b] (if (not (.isEmpty ret)) (recur (.deleteMin ret)) ret))))
22:51Carkhum what if you have a nil value in your set ?
22:51eeesee here's what's bogus. for that "rest" one, it took like five minutes real time
22:51eeei only have random values for this test
22:51eeeints
22:52eeegood thing to note though
22:52eeethanks
22:52Carkright but you shoudl do this instead
22:52eeebut why does it report 10 seconds even though I waited ten minutes
22:52Carkerr wait what do you want to achieve anyways ?
22:52eeemine actually took the 5 seconds
22:52eeeok
22:52eeeI wrote a heap
22:53eeeand someone suggested
22:53eeecompare it to sorted set
22:53eeeyou know I wrote a priority queue
22:53eeepurely functional
22:53eeepersistent
22:53Carkright
22:53eeelike Rich would like
22:53eee(time (def b (loop [ret (new PersistentHeap) i 0] (if (< i 2000000) (recur (.insert ret (rand-int 100000)) (+ i 1)) ret))))
22:53Carkhum if you have that implementation already, why don't you make an iseq out of it and use it directly from clojure ?
22:54eeewhere is that edit window
22:54eeewell, before jumping the gun on that, I wanted to test against something already there
22:54eeeto make sure not wasting my time
22:55eeeit needs to support heap stuff, besides seq stuff, anyway.
22:55Carkok then ... but your test is only poping stuff ... if you only pop a couple items, you'll end up with a seq instead of a set
22:55eeei popped the whole thing
22:55eeewhile not nil
22:55eeeas you pointed out
22:55Carkyou need to dissoc the first item
22:55eeei do?
22:56eeewe need that handy clip web page
22:56Carkby using dissoc, you keep using a set
22:56Carki mean the return value of it will be your set instead of a seq
22:57eeei can't pasre that
22:57eeewhich set
22:57eeethe sorted set
22:57eeeor the heap
22:57Carkthe sorted set
22:57eeeI did this
22:57Carkyou said you wanted to test a sorted set as a heap
22:57eee(time (def a (loop [ret (sorted-set) i 0] (if (< i 2000000) (recur (conj ret (rand-int 100000)) (+ i 1)) ret))))
22:57eeeis that wrong?
22:57eeeyeah
22:58Carkthat's building it, seems ok to me at first glance yes
22:58eeeok
22:58eeebut then i should dissoc?
22:58eeei need to look that up
22:58eeenot really good at clojure yet
22:59Carkby doing (rest a) you make a seq
22:59Cark,(doc rest)
22:59Carkdamn clojurebot still dead ...
22:59eeeso it looks like a seq, but isn't that just an upcast?
23:00eeeor OH
23:00eeeI see
23:00Carknope .... most probably some kind of a lazy sequence that looks into the original set
23:00eeeit could explain why I wait ten minutes
23:00Carkso
23:00eeeso how do I do rest on the sorted-set?
23:00eeei get it
23:00eeedissoc
23:00eeemust remove elements
23:01Carkif you have a lazyseq, the time form will return before the end of processing (if i'm not mistaken about the lazy stuff)
23:01eeebut now I need to switch to a ummmmm sorted map
23:01Carknope
23:01eeeso my keys can start with 1
23:01eeeso that I can remove the '1'
23:02Carkyou can dissoc from a set
23:02eeebut you need to know the element
23:02eeeso
23:02eeeI gotta ask for the first element
23:02Cark(first my-set) will give you the first element
23:02eeeright?
23:02eeeyeah
23:02Carkso you know it =)
23:02eeeis there a multi-map in clj?
23:03eeesomething that allows multiple same keys?
23:03eeecause that's anoter difference
23:03eeemy heap can have dups
23:03Carknope there isn't
23:03eeeok
23:03Carkyou could build one out of clojure maps and lists (or vectors)
23:04eeei see
23:04eeeso I can do (dissoc myset (first myset))
23:04Carkright
23:05eeetrying it out
23:06eeehaving a prob
23:06eeemust have typod
23:06eeeclass cast exception
23:07eeeline zero?
23:07eee(recur ((dissoc ret (first ret))))
23:07eeethat's what I have
23:07Carkerrr looks like you're right
23:07cp2you are trying to invoke the return value of (dissoc ...)
23:08Carkdissoc isn't the right one, it's for map only
23:08cp2(recur (dissoc ret (first ret)))
23:08Carkhum there's a functuion for that though
23:08cp2o yeah
23:08cp2it is only for map
23:08cp2and anyway
23:08eeeahhh
23:08cp2if you want to remove the first
23:08cp2(recur (rest ret))
23:08Carknoooo
23:08eeewe just covered that
23:08eeedon't want to turn into a seq
23:09eeeit's a sorted set
23:09cp2sorry, not paying much attention
23:09cp2oh ok
23:09Carkah there it is : use disj for sets
23:09eeeok
23:09cp2my bad :)
23:09Cark=)
23:10eeethink I'm in for a hurtin now
23:10eeethe timing was offset
23:11eeetiming in clj always messes people up
23:11eeeuntil they are experts, I think
23:11eeecause of the lazy stuff
23:11eeeeven doall doesn't always fix
23:12eeeworking now
23:12eeeor
23:12eeeso far not complaining
23:12eeethanks for the help
23:12eeebrb. gonna let it churn
23:21eeewow, still churning. disj may be slower than turning to a seq
23:21eeebrb some more
23:26eeesomething wrong with that approach. infinite loop
23:26eeeit turns out
23:29eeeor somewhere else
23:29eeehmmmmm
23:36eeei'm back to something I thought was working. anyone see anything wrong with this?
23:36eee(time (def aa (loop [ret a] (if ret (recur (rest ret)) ret))))
23:37stuhoodi think you need to do (if (seq ret) ...) but i can
23:37stuhoodcan't remember why.
23:37cmvkkyeah, because (rest ret) will never return nil.
23:37eeeno?
23:37stuhoodnot since the laziness changes
23:37eeethat must have changed
23:37cmvkkor you can use (next ret) instead.
23:37eeeyeah
23:37eeeoh
23:37eeecrap
23:38eeethat was it
23:38eeedang
23:39eeeworks
23:40eeenow my stuff not trumping anymore
23:40eeeas predicted, faster on insert, slower on pop
23:40eeebut inserts + pops is slower than just sorting ahead of time
23:41eeeso only useful if you want to pop a handful of things
23:41eeeor I improve algorithms :)
23:42eeethanks for the help
23:42eeesux that you can't ask for nil ananymore
23:43stuhoodeee: like cmvkk said, you can just use (next) everywhere for the old behaviour
23:44eeeok. ret is fewer chars than (next ret) . . . but I suppose the latter is more descriptive anyway
23:45stuhoodi mean, (next) instead of (rest)
23:46eeeoh
23:46eeei see