#clojure log - Apr 20 2009

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

0:22 AWizzArd: ~ max people

0:22 achso

0:43 Lau_of_DK: Hard-coding it on every route gets the job done, but it defies the documentation of Ring

1:03 AWizzArd: Yes, 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.

1:05 Lau_of_DK: Exactly, but the default seems to be boorked

1:05 Maybe a Ring/Compojure version mismatch

1:14 cgray: hi, how do you reload a jar file from the repl?

1:20 hoeck: cgray: reload the clojure code or the (java) classes inside the jar? For clojure code, a (require 'my-namespace :reload) should do the job.

1:21 cgray: hoeck: the classes from a different jar file (i.e. not the clojure.jar)

1:23 according to google, i need to restart clojure...

1:23 brb

1:23 hoeck: cgray: there are the same limits as to java class reloading, so once loaded, you need to restart the jvm to load the new classes

1:24 cgray: hi again, sorry, my window manager locked up

1:25 i missed the last message i think

1:27 hoeck: you need to restart clojure, thats right

1:27 this is a jvm limitation

1:28 cgray: ok, that shouldn't be a big problem

1:28 hoeck: there is a (commercial) program to allow arbitrary class reloading for the jvm, called javarebel

1:35 Lau_of_DK: ...or Clojures own stub system

1:35 eevar2___: cgray: http://blog.taragana.com/index.php/archive/how-to-unload-java-class/

2:14 kadaver: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3978#a3978 <- exiting swing does work properly after i added that

2:14 any obvious error?

2:14 i added the write-to-file stuff

2:14 System/exit 0 worked before

2:16 Chousuke: does it hang or something?

2:16 kadaver: yes

2:16 i click X but nothing happens

2:16 doesnt hang

2:16 Chousuke: hm

2:17 doesn't that have a misplaced paren?

2:17 ah, no.

2:17 my guess is it throws and exception when writing the file

2:18 and the System/exit never gets called.

2:20 run in from the console and see what it prints.

2:20 anyway, I'm off

2:23 kadaver: yeah

2:23 (defn create-exit [playerstate]

2:23 (proxy [WindowAdapter] []

2:23 (windowClosing [evt]

2:23 should proxy or windowClosing have more args?

2:23 Wrong number of args passed to: guilogic$create-exit--429$fn--4

2:30 ah

2:30 i was not derefing(@)

2:30 but

2:30 (reduce #(str %1 "#" %2) "" (@playerstate :playlist))

2:30 (reduce #(str %1 "#" %2) (@playerstate :playlist))

2:30 the 2nd works in the repl but not when compiled

2:42 wouldn't (nth n coll) be better?

2:42 i find it more natural to write it that way

2:50 cgray: it 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

2:51 jdz: i put an (in-ns 'foo) after that

2:51 seems to work

2:51 AWizzArd: Is there something like (def- x 123) vs (def #^{:private true} x 123)?

2:51 jdz: but should be fixed

2:52 cgray: jdz: even that is not working

2:53 jdz: try re-oponing the file

2:53 re-opening even

2:54 cgray: how about that

2:54 it works

2:55 jdz: the (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

2:55 somebody not-lazy should go and fix clojure mode :/

2:58 AWizzArd: Yes, there were no updates for the clojure-mode and swank-clojure anymore now...

2:59 jdz: huh? i got updates today even

2:59 to swank-clojure

2:59 it uses pprint now

3:01 damn, looks like slime-edit-definition is broken now...

3:03 AWizzArd: ah oki, so clojure-mode was without updates

3:08 Raynes: Oracle bought Sun.

3:08 http://in.sys-con.com/node/925931

3:09 rsynnott: pretending to buy Sun is a traditional activity of large IT companies going through difficult times

3:09 I'll believe it when I see it

3:09 tWip: sun.com has the news also

3:10 jdz: the in.sys-con.com has ads with sound!

3:10 ffs

3:10 it's year 2009

3:16 Raynes: rsynnott: http://www.sun.com/aboutsun/pr/2009-04/sunflash.20090420.1.xml

3:16 You've seen it.

3:16 Might want to believe it now.

3:20 rsynnott: heh

3:28 poor sparc :(

3:35 AWizzArd: Maybe Oracle has better arguments to sell those sparcs.

3:37 rsynnott: There is a lot of talk of Java and Solaris on the press release, I note

3:37 not so much of poor Sparc

3:37 (or MySQL, but Oracle already owned the interesting bits of that)

4:04 AWizzArd: To ask the Oracle about the future of Java now gets a whole new meaning...

4:05 rsynnott: well, they're unlikely to kill it

4:06 (not that they could; IBM is surely at least a big driving force behind modern Java as Sun is)

4:06 bstephenson: I wonder about (fear for?) the future of Sun's open-source apps like Glassfish, OpenOffice and NetBeans, much less MySQL.

4:07 rsynnott: Oracle have owned InnoDB since 2005 anyway

4:07 and they license BDB in much the same way as MySQL is licensed by MySQL AB and Sun

4:07 so it'll probably be fine

4:08 * rsynnott finds it difficult to really care too much about openoffice :)

4:25 AWizzArd: Maybe upcoming JDKs will cost a nice license fee.

4:31 Raynes: I'll blow my head off and have the remains sent to Oracles doorstep.

4:31 :|

4:31 tWip: a bit drastic

4:35 Raynes: "Guess I'd better start learning PostGreSql and F#/Mono instead of Clojure." Now that is a bit drastic.

4:36 bstephenson: I 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.

4:38 p_l: I had seen Oracle downplay a *big*, *important* company bugreports about Oracle server getting OOM-killed. We had highest support levels

4:39 cp2: whats going on?

4:39 oracle bought sun/java/??? ?

4:39 p_l: cp2: yup

4:39 ~$9.60/share

4:39 cp2: lol

4:40 damn

4:40 this is what happens

4:40 when you sleep

4:40 miss out on interesting news

4:40 p_l: god bless them for opensourcing Solaris and lot of other stuff

4:41 Raynes: MySQL is dead. Long live MySQL!

4:41 p_l: Raynes: that's the good part of those news :P

4:41 Raynes: :p

4:42 I hope people don't freak and drop Clojure and run for the hills.

4:42 jdz: what's SUN's market ticker (or whatever it is called)?

4:42 rsynnott: JAVA

4:42 (when it was IBM buying them, I vaguely thought it was because they wanted the ticker)

4:43 when it was Apple buying them (this happened about six times) I just assumed lack-of-Jobs-induced-insanity

4:44 dnolen: is there a function to convert a String to an InputStream in Clojure?

4:45 jdz: some class having StringReader in it?

4:46 gnuvince: Does anyone know a free tool to make *nice* looking charts and plots?

4:46 jdz: google charts?

4:46 gnuvince: Emphasis on the *nice*; I need it for a one-off graph, and it'd be nice if it was a beautiful one.

4:47 jdz: google charts looked very nice last time i saw them

4:47 rsynnott: google's ones are quite nice

4:47 jdz: and don't all presentation apps allow one to create charts?

4:47 stuhood: dnolen: i would use String.getBytes() into a ByteArrayInputStream

4:47 rsynnott: but careful! Confusingly they have two chart apis, which are completely different

4:48 gnuvince: jdz: oh, I didn't think about PowerPoint

4:48 rsynnott: (one is highly AJAXy, and thus confined to Gooogle Labs)

4:48 jdz: well, i had Keynote in mind :)

4:48 while speaking of *nice*

4:49 AWizzArd: The install path for Java 7 will be /u02/app23/sys/ucb/myjdkoraql/1002.{bin,lib,etc,mesg,crs}. The machine will have Load 27 during a Thread/sleep. For finetuning pay 400$ per hour for consultants :)

4:49 dnolen: stuhood: thx

4:49 jdz: Numbers also can make a nice looking charts. too bad the app cannot be used to calculate stuff

4:49 rsynnott: in fairness, sun is quite keen on terrible, terrible paths, itself

4:51 noidi: gnuvince, if you know python, then matplotlib is nice http://matplotlib.sourceforge.net/

4:56 gnuvince: noidi: 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)

4:57 jdz: the matplotlib actually looks very nice for exactly this purpose

4:57 an example: http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo2.html

4:57 gnuvince: Very, very nice

4:58 I think we have a winner

4:58 cp2: oracle did a union query while the sun execs weren't looking

4:58 now they can't split without compromising DB integrity

4:58 hah

5:08 stuhood: its a good thing sun already open sourced java

5:11 cp2: indeed

5:11 even if oracle does close it up, people will just fork

5:11 no worries

6:02 danlarkin: so Oracle buys Sun eh?

6:05 I wonder what that means for mysql

6:05 Raynes: "MySQL is dead. Long live MySQL!"

6:09 for(n <- 1 to 1000 if n % 3 == 0) yield n

6:09 Oops, wrong window. :>

6:11 cgray: does anyone have experience creating a SecurityManager that prevents a library from killing clojure with a call to System.exit() ?

6:16 cemerick: cgray: clojurebot does this. I think hiredman might have blogged about the details at some point?

6:16 hiredman: me? I don't blog

6:16 stuhood: cgray: prolly in here somewheres: http://github.com/hiredman/clojurebot/blob/3cf335c748045fbce0aa92c82289a8df5a81063d/hiredman/sandbox.clj

6:16 cgray: thanks

6:17 cemerick: hiredman: hrm. Then someone else is blogging about clojurebot somewhere :-)

6:18 hiredman: everything I know about jvm sandboxing I cribbed from http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html

6:20 cgray: aha, 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

7:21 hiredman: http://code.google.com/p/clojure-contrib/wiki/DatalogOverview incase anyone hasn't seen it yet

7:24 replaca: that should set the standard for how we documentt our stuff!

7:25 Jeffery set a great example there

7:26 cp2: looks pretty neat hiredman

7:29 danlarkin: makes me want to play with datalog :)

7:36 mattrepl: hiredman: neat!

7:38 peregrine81: Hello everyone. My goal is to learn lisp, using clojure. What is the best place to start

7:38 ?*

7:39 technomancy: peregrine81: the Clojure book from pragprog.com is quite good.

7:39 also: in a couple days my clojure introduction screencast will be available from peepcode.com

7:39 but I'll understand if you don't want to wait for it. =)

7:40 peregrine81: anything freely available?

7:40 technomancy: there's the wiki, but it's kind of messy.

7:40 the book is definitely worth it; I think it's only around $20 if you get just the PDF.

7:41 danlarkin: hey technomancy, want to see my progress on an http library so far?

7:41 technomancy: danlarkin: yeah; let's see it

7:41 peregrine81: Alright, would it be possible to easily follow along with PCL with clojure?

7:41 technomancy: peregrine81: there's some blog posts that port portions of it over

7:42 peregrine81: but the original book will only be marginally helpful

7:42 dliebke: peregrine81: I like Mark Volkman's introduction: http://java.ociweb.com/mark/clojure/article.html

7:43 Raynes: peregrine81: http://ociweb.com/jnb/jnbMar2009.html is a good starting point, but you're going to want the book eventually.

7:43 danlarkin: technomancy: 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

7:43 Raynes: dliebke: Great minds think alike. :)

7:43 dliebke: :)

7:43 zakwilson: peregrine81: do you know Java already?

7:43 peregrine81: Cool

7:43 hiredman: peregrine81: search for CS61A on youtube, it's berkeley's version of structure and interpretation of computer programs

7:43 peregrine81: zakwilson: Yes :)

7:44 Unfortunately

7:44 danlarkin: technomancy: http://gist.github.com/98612

7:44 technomancy: danlarkin: do you have any tests for it yet?

7:44 zakwilson: Good - it helps with actually getting stuff done in Clojure because it's easier to read the documentation for various libraries.

7:44 danlarkin: technomancy: no :-o *gasp*

7:45 technomancy: danlarkin: I was wondering how you'd go about that; is there any way to serve HTTP from just the stock JDK?

7:45 zakwilson: Is it possible to stick a native executable inside an executable jar and call it from your code?

7:45 cp2: Runtime.exec

7:46 but thats messy

7:46 and discouraged

7:46 danlarkin: technomancy: oh... mmm... easily? I'm not sure, but you can always call something like example.com

7:46 technomancy: danlarkin: yeah, but having tests that don't work when the network is down is not so hot

7:46 danlarkin: plus you'd need the response to vary based on headers etc.

7:47 Lau_of_DK: technomancy: "the book from pragprog" , is that Stuarts book ?

7:47 technomancy: Lau_of_DK: yeah

7:47 danlarkin: it'd be a shame to make the test suite require (for instance) having jetty on the classpath, but that's better than nothing

7:47 hmmm

7:47 anyway this looks good

7:47 Lau_of_DK: I'd be careful giving such pricey advice to new-comers, as the first option

7:47 Most people here have learnt Clojure, through the free resources scattered across the web

7:48 technomancy: Lau_of_DK: well my $9 peepcode isn't out yet. =)

7:48 I guess it depends on how interested you are. =)

7:48 Lau_of_DK: And the signal we want to send

7:49 Its your call, but it stuck out :)

7:49 cp2: technomancy: torrent now, pay later? :)

7:49 * Raynes mutters another complaint about Stuart not open sourcing his book.

7:49 technomancy: peregrine81: 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.

7:51 hiredman: I was looking at berkeley's cs61a videos on youtube, and they seem a very gentle intro to lisp

7:51 using scheme

7:53 cs61a (the java course) is the most boring thing ever btw

8:36 unlink: Is there any way of annotating a string with metadata?

8:36 technomancy: values don't have metadata, vars do

8:37 unlink: ok

8:38 stuhood: so you could add the metadata to a def statement for a var containing the string, I think

8:38 rhickey: technomancy: no - map/set/vector/symbol values can have metadata, just not string/numbers etc

8:38 hiredman: :(

8:39 technomancy: ah, gotcha. so it's just that the built-in types aren't extensible.

8:39 unlink: so why does this evaluate to nil? (meta (let [x "hi"] #^:a x))

8:41 taggart: ,(let [x "hi"] #^:a x)

8:41 stuhood: because you are trying to attach the metadata directly to the string: isn't a 'var' in that case, its a local, right?

8:42 unlink: So it's impossible to return metadata-annotated strings from a function?

8:42 hiredman: yes

8:43 strings are java.lang.String

8:43 which is a final class

8:43 so not extensible

8:43 unlink: ok. I was trying to mark strings as "escaped" or "not-to-be-escaped"

8:43 technomancy: even if it were subclassable, having a clojure-specific string type floating around and having to figure out which is which would be pretty confusing

8:44 for java interop work at least

8:44 taggart: it would make interop a nightmare

8:45 stuhood: especially since java.lang.String is final

8:45 technomancy: I 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.

8:45 is there one? or is it just one of Those Crazy Java things?

8:45 taggart: security iirc

8:45 hiredman: voodoo

8:46 unlink: OK, so what would be the idiomatic way of achieving this? pass around an application-defined datastructure which has a string and escape status?

8:46 taggart: maybe oracle will fix it for you ;)

8:47 technomancy: unlink: 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.

8:47 unlink: I'm writing a library. I'd like to provide a "secure-by-default" option.

8:48 Unfortunately it's unidiomatic in virtually every programming language.

8:50 It's even awkward in Python, which is not exactly famous for its rigid type system.

8:51 stuhood: unlink: yea, i think you'll need a wrapper around the string

8:52 taggart: if symbols support metadata, then why doesn't the following work?

8:52 (def #^{:a "test"} mystr "hi")

8:52 hiredman: the CharSequence final?

8:53 unlink: you could use CharSequence instead of Strings

8:53 http://java.sun.com/j2se/1.5.0/docs/api/java/lang/CharSequence.html

8:53 proxy that and add metadata support

8:54 stuhood: hiredman: or perhaps StringBuffer/Builder, since CharSequence is an interface

8:54 hiredman: I think there is a String constructor that takes a CharSequence so the conversion would be easy

8:54 stuhood: ack, both are final...

8:54 hiredman: stuhood: but Buffer and Builder are mutable :(

8:55 yeah, better stick with CharSequence

8:55 ugh

8:55 unlink: Clojure's greatest strength is also its greatest weakness!

8:55 hiredman: I hate this, I want clojurebot and I want my server online so I have a clojure repl and vim and etc

8:56 stuhood: /mourn clojurebot

8:57 unlink: What happened to it? Server melted?

8:58 hiredman: (defn make-char-sequence [string]

8:58 (proxy [java.lang.CharSequence]

8:58 (charAt [i] (.charAt string i))

8:58 (length [] (.length string))))

8:58 etc

8:58 actually adding metadata support is an exercise for the reader

8:58 unlink: reports are sketchy

8:59 the server already had a hard drive die over christmas

9:00 the 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

9:02 scottj: I'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\>"

9:05 rhickey: unlink: 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

9:07 unlink: rhickey: 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.

9:07 rhickey: unlink: then just use a map {:escaped true :val "foo"}

9:08 unlink: What I meant is, everything in between would want to see something String-y, not caring whether it's a String or MyString.

9:09 hiredman: unlink: 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

9:09 rhickey: what hiredman said

9:10 hiredman: ideally most things would not specify String but CharSequence in their interface

9:10 but somehow I doubt that is case

9:10 unlink: ok.

9:10 Good to know.

9:10 rhickey: hiredman: unfortunately that's not true of some of Clojure - could you enter an issue for it please - use CharSequence when possible?

9:11 hiredman: uh

9:11 ok

9:11 stuhood: soo, ((partial + 1 2)) returns 3, but ((partial constantly true)) returns a function... hmm

9:11 hiredman: my first issue!

9:11 unlink: How does unicode work in clojure?

9:12 rhickey: unlink: same as Java

9:14 unlink: How do I get bytes?

9:14 hiredman: unlink: String has .getBytes

9:14 which returns an array of bytes

9:14 stuhood: (.getBytes "blah")

9:15 taggart: more of that at the interop page: http://clojure.org/java_interop

9:15 unlink: whoops, I broke my clojure

9:15 hiredman: and the String javadoc

9:16 unlink: http://dpaste.com/35980/

9:16 Chousuke: stuhood: isn't that what it's supposed to do. (constantly true) returns a function

9:17 hiredman: unlink: I would try again

9:17 unlink: I'm starting clojure via rlwrap --remember -c -b "(){}[],^%$#@\"\";:''|\\" java -cp clojure.jar:clojure-contrib.jar:. clojure.lang.Repl

9:17 hiredman: unlink: is it repeatable?

9:17 taggart: Chousuke: I think his point was that (partial + 1 2) should also return a function

9:17 Chousuke: taggart: it

9:17 er

9:17 taggart: oh, nvm, missed the double parns

9:17 Chousuke: it does

9:18 unlink: I can't repeat it.

9:18 hiredman: ghosts in the machine

9:19 evidence of the underlying procedural nature of the machine

9:19 unlink: haha

9:19 albino: I hope that's ghosts in the jvm and not ghosts in the physical cpu

9:19 unlink: That works in #haskell.

9:21 I love the comically long stack traces produced by compojre.

9:21 hiredman: breaking 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

9:24 unlink: Ah, as it turns out, clojure requires RAM to operate.

9:27 stuhood: Chousuke, taggart: one executes the returned function, and the other doesn't... that is the weird part

9:28 Chousuke: stuhood: it does execute it.

9:28 stuhood: it's just that in the latter case it runs a function that returns a function

9:28 while in the former it runs a function that returns an integer.

9:28 taggart: stuhood: a successful invocation of + returns a number, a successful invocation of constantly is a function

9:29 stuhood: agh... indeed

9:30 unlink: How low-level is the bytecode generated by clojure?

9:30 Chousuke: low-level?

9:30 it's JVM bytecode.

9:30 unlink: It does emit JVM bytecode, correct?

9:31 technomancy: is there a nicer way to browse the JDK documentation than just googling for javadoc?

9:32 unlink: :W

9:32 taggart: http://java.sun.com/javase/6/docs/api/ ?

9:32 unlink: ...

9:33 * technomancy installs the sun-java6-doc

9:33 technomancy: package

9:34 oh are you kidding me? it makes you download it manually.

9:35 dliebke: I also like to use clojure.contrib.repl-utils/javadoc

9:36 unlink: lol @technomancy

9:36 I ran into that last night.

9:37 technomancy: dliebke: that works. Wonder if it could be adapted to a local copy of the documentation.

9:38 dliebke: good question, I haven't looked at the source

9:38 technomancy: unlink: it makes the debian DFSG problems look like nothing.

9:39 unlink: I'm sure all these problems will change with the new management.

9:40 Don't forget to chown root:root.

9:41 technomancy: unlink: hah. no.

9:42 if I'm going to download it manually, why would I use the package manager?

9:42 unlink: To unpack it in the correct directory, of course.

9:42 And don't forget the debian changelog.

9:43 technomancy: good stuff

10:15 HAppyKAmikaze: say i'm totally new to this language, where i can find good documentation apart from clojure.org?

10:16 gnuvince: HAppyKAmikaze: there's a book: http://www.pragprog.com/titles/shcloj/programming-clojure

10:16 hiredman: HAppyKAmikaze: prior lisp experience?

10:16 HAppyKAmikaze: is still a beta book

10:16 hiredman: prior java?

10:16 HAppyKAmikaze: isn't it?

10:16 arohner_: HAppyKAmikaze: it's still a beta language :-)

10:16 HAppyKAmikaze: say java

10:16 hiredman: it is like | | close to publishing

10:16 gnuvince: HAppyKAmikaze: yes, but it's practically done, and it's been useful for a long time.

10:16 Raynes: HAppyKAmikaze: The book is complete, just maybe a few typos. And a little content could be added before now and when it's published.

10:16 Well, before it's printed.

10:16 hiredman: HAppyKAmikaze: there is a blip.tv into video "clojure for java programers"

10:16 Raynes: It's already published.

10:17 HAppyKAmikaze: say ok book and tv! thanks

10:17 hiredman: all the docs on the api webpage are availble from the repl using the doc command

10:17 Raynes: ,(doc println)

10:18 hiredman: all the javadocs on the internet have some relevence

10:22 Raynes: Where is clojurebot. :(

10:23 hiredman: http://delicious.com/clojurebot has some urls to might be useful for clojure

10:23 Raynes: current theory is bad ram

10:55 technomancy: has anyone used any of the javadoc Emacs mode?

10:55 *modes

11:01 looks like javadoc-help does the trick; it's just got a not-so-hot interface

16:44 unlink: How is "\a\b\c" read?

16:44 Chouser: as an error

16:45 java.lang.Exception: Unsupported escape character: \a

16:45 unlink: The quotes were intended to delineate the input

16:45 Chouser: oh

16:45 three literal Characters

16:45 kotarak: As three chacters: a b and c.

16:46 unlink: What is the type of "three characters"?

16:46 kotarak: ,(class \a)

16:46 Hmm.. no bot..

16:46 Chouser: (nth [\a\b\c] 1) --> \b

16:46 dliebke: java.lang.Character

16:46 unlink: Oh, I got it

16:46 kotarak: 1:1 user=> (class \a)

16:46 java.lang.Character

16:47 unlink: I didn't realize that you could just throw a bunch of whitespace-separated values at the repl

16:47 stuhood: and apparently non-whitespace separated in this case

16:47 unlink: right

16:47 but I guess that's just the imperative construct in clojure

16:47 stuhood: er, non-separated

16:49 Chouser: stuhood: hah

16:56 zakwilson: If 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:56 arohner_: the path is a construct created by the shell

16:57 cemerick: Runtime.exec("which foo")? :-P

16:57 arohner_: zakwilson: I'm not aware of a good clojure wrapper yet, but it sounds like it would be useful

16:58 cemerick: I'll bet there's a handy OS-process lib that will do that, maybe in apache-land.

16:58 zakwilson: cemerick: can't count on which being available.

16:58 cemerick: zakwilson: thus the :-P ;-)

16:58 zakwilson: I'll just do it by hand for now. This doesn't need to be production quality code.

17:00 cemerick: zakwilson: there's http://commons.apache.org/exec/ -- never even downloaded it, but it's ripped from ant, so that's something.

17:11 arohner_: anyone know what this means?

17:11 Clojure

17:11 java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V (start.clj:0)

17:11 user=>

17:15 kotarak: arohner_: make sure you do an "ant clean" in your Clojure and/or contrib build.

17:15 some AOT compiled code wants to call the MultiFn constructor replace some revisions ago.

17:18 arohner_: kotarak: thanks

17:25 ah, compojure was a culprit as well

17:26 that was trickier because it wanted a copy of clojure.jar in compojure/deps

17:26 unlink: It doesn't seem that compojure works too well with clojure-svn

17:40 Where can I read "A Friendly Introduction To Lisp Macros, Clojure Edition"?

17:47 technomancy: there's a macros chapter in the book, isn't there?

17:49 unlink: Oh, there's a book?

17:49 kotarak: "Programming Clojure"

17:50 unlink: Oh, that kind of book.

17:50 technomancy: The Book

17:50 is that better? =)

17:51 unlink: Is it worth it? Will I save more than half an hour by reading the book versus figuring it out the long way?

17:52 technomancy: depends on what you're trying to do

17:52 alvivi: If you're a programming guru, of course yes ;)

17:52 technomancy: but in the long run the answer is yes.

17:52 unlink: Books were unhelpful in mastering Python.

17:53 But Python is better documented than Clojure.

17:53 technomancy: you might not need the book if you already know a significant amount of CL or Scheme, but I still found it helpful.

17:53 macros are a really tricky topic, too

17:53 unlink: Oh no, now I want Programming Scala and Programming Groovy.

17:54 technomancy: buying books is dangerous

17:54 unlink: I should probably limit myself to one new JVM language after the events of this morning.

17:54 But...the Java libraries...they call...

17:55 technomancy: one language per year is a good baseline

17:55 unlink: Well I haven't learned a new language since 2007.

17:55 Wait, I learned a new on this yera.

17:55 If you can call PHP a language.

17:55 * technomancy pretends you didn't say that

17:56 unlink: Don't worry, we ended up rewriting the project in Django.

17:57 All right, you guys better be right about this book, I'm plunging $21 into it :-)

17:57 Is one of you the author? >_>

17:57 technomancy: he's online sometimes, but not right now

17:59 unlink: OK.

18:01 Hmm, is EPL standard practice in Clojure-land?

18:02 kotarak: Mostly, I use mostly MIT, I think I saw also GPL somewhere, but EPL seems very widespread.

18:02 unlink: OK, people aren't going to shun me if I MIT then

18:05 I 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:06 sohail: unlink, which product?

18:06 are you supposed to get a license in the mail?

18:06 email that is

18:06 unlink: Programming Clojure

18:07 sohail: ah

18:07 dunno how they do that one

18:07 unlink: Very crafty of them.

18:07 sohail: I 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:07 s/immediately/automatically/

18:08 unlink: You must log in as the owner to download that file.

18:08 technomancy: trying to fetch it with wget or something?

18:10 unlink: no

18:10 I'm trying to do /exactly what the email instructions tell me to do/

18:10 OK, my transaction costs have already totaled 10 minutes of effing around with this. I'm not happy.

18:12 a HA!

18:12 They associated my order with paypal email address, not with the one I used to register with the site.

18:12 Of course, why didn't I think of that.

19:44 technomancy: cgrand-rec: hey, I'm trying out the new enlive code

19:44 I'm wondering if it's worth renaming "empty" so it doesn't conflict with clojure core

20:33 kadaver: http://code.google.com/p/clojure-contrib/wiki/DatalogOverview who made it?

20:33 cool stuff

21:34 eee: hello

21:34 i was looking at the cookbook

21:35 but lost on a simple thing

21:35 sort of rusty

21:35 i made a set: (def a (sorted-set))

21:35 and now I want to loop, redefining set

21:36 one item at a time

21:36 inserting into the set

21:36 i tried this

21:36 (dotimes [q 40] (def a (conj a 2)))

21:36 i am sure that's a hack

21:37 ultimately I will time it

21:38 dnolen_: eee: data structures in clojure are immutable, you're just redefining a 40 times

21:38 eee: yup

21:38 i want to see how long it takes to do inserts

21:38 to compare to my own immutable datastructure

21:38 oh, you mean a doesn't

21:38 accumulate

21:39 even though I redefine it

21:39 based on old value

21:39 so I have to loop recur

21:39 dnolen_: have you created you're own sorted set java class?

21:39 eee: odd that it doesn't take on the new value each time through the dotimes

21:40 I have a different datastructure that I will time next

21:40 but for now trying with sorted set

21:40 dnolen_: eee: because a is immutable, nothing takes a new value in clojure without using one of the mutation constructs.

21:40 eee: from clojure

21:40 ok

21:40 so I'll rewrite with loop-recur

21:40 is conj the right way to add to a set?

21:41 i didn't find insert, add, or append

21:44 dnolen_: conj works yes.

21:45 ,(+ 1 2)

21:45 hmm no clojurebot.

21:46 eee: oh, I know why now

21:46 my orig question

21:46 because a set

21:46 uniquifies

21:46 dnolen_: yup

21:46 eee: any object like a sorted vector?

21:48 yes

21:48 (def a (vector)) (dotimes [q 40] (def a (conj a 2)))

21:48 that works like I'd think

21:48 was the dedup

21:48 so I need to replace 2 with a rand

21:50 dnolen_: eee: so what exactly are trying to accomplish again?

21:50 eee: i made a new thing for clojure

21:50 and someone suggested

21:50 that I profile it

21:50 against sorted set

21:50 so I will

21:50 already one diff

21:50 mine needn't be unique

21:51 but also

21:51 my sort is semi-lazy

21:51 and does other things

22:14 anyone here use clojure-dev?

22:14 eclipse

22:15 repl isn't starting, at any rate

22:19 worked around it

22:47 wow. looks like I'm trumping sorted-set right now

22:47 exciting

22:47 purely functional too

22:48 probably my bad clojure

22:48 what would be the best way to pop things off the front of a sorted set one by one, returning a new sorted set?

22:49 i'm just calling (rest)

22:49 Cark: that's how i would do it

22:49 but then you get a lazy seq i guess

22:49 that's not a sorted set anymore

22:50 eee: (time (def aa (loop [ret a] (if ret (recur (rest a)) ret))))

22:50 that look fair?

22:50 against my heap:

22:50 (time (def bb (loop [ret b] (if (not (.isEmpty ret)) (recur (.deleteMin ret)) ret))))

22:51 Cark: hum what if you have a nil value in your set ?

22:51 eee: see here's what's bogus. for that "rest" one, it took like five minutes real time

22:51 i only have random values for this test

22:51 ints

22:52 good thing to note though

22:52 thanks

22:52 Cark: right but you shoudl do this instead

22:52 eee: but why does it report 10 seconds even though I waited ten minutes

22:52 Cark: err wait what do you want to achieve anyways ?

22:52 eee: mine actually took the 5 seconds

22:52 ok

22:52 I wrote a heap

22:53 and someone suggested

22:53 compare it to sorted set

22:53 you know I wrote a priority queue

22:53 purely functional

22:53 persistent

22:53 Cark: right

22:53 eee: like Rich would like

22:53 (time (def b (loop [ret (new PersistentHeap) i 0] (if (< i 2000000) (recur (.insert ret (rand-int 100000)) (+ i 1)) ret))))

22:53 Cark: hum if you have that implementation already, why don't you make an iseq out of it and use it directly from clojure ?

22:54 eee: where is that edit window

22:54 well, before jumping the gun on that, I wanted to test against something already there

22:54 to make sure not wasting my time

22:55 it needs to support heap stuff, besides seq stuff, anyway.

22:55 Cark: ok 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:55 eee: i popped the whole thing

22:55 while not nil

22:55 as you pointed out

22:55 Cark: you need to dissoc the first item

22:55 eee: i do?

22:56 we need that handy clip web page

22:56 Cark: by using dissoc, you keep using a set

22:56 i mean the return value of it will be your set instead of a seq

22:57 eee: i can't pasre that

22:57 which set

22:57 the sorted set

22:57 or the heap

22:57 Cark: the sorted set

22:57 eee: I did this

22:57 Cark: you said you wanted to test a sorted set as a heap

22:57 eee: (time (def a (loop [ret (sorted-set) i 0] (if (< i 2000000) (recur (conj ret (rand-int 100000)) (+ i 1)) ret))))

22:57 is that wrong?

22:57 yeah

22:58 Cark: that's building it, seems ok to me at first glance yes

22:58 eee: ok

22:58 but then i should dissoc?

22:58 i need to look that up

22:58 not really good at clojure yet

22:59 Cark: by doing (rest a) you make a seq

22:59 ,(doc rest)

22:59 damn clojurebot still dead ...

22:59 eee: so it looks like a seq, but isn't that just an upcast?

23:00 or OH

23:00 I see

23:00 Cark: nope .... most probably some kind of a lazy sequence that looks into the original set

23:00 eee: it could explain why I wait ten minutes

23:00 Cark: so

23:00 eee: so how do I do rest on the sorted-set?

23:00 i get it

23:00 dissoc

23:00 must remove elements

23:01 Cark: if you have a lazyseq, the time form will return before the end of processing (if i'm not mistaken about the lazy stuff)

23:01 eee: but now I need to switch to a ummmmm sorted map

23:01 Cark: nope

23:01 eee: so my keys can start with 1

23:01 so that I can remove the '1'

23:02 Cark: you can dissoc from a set

23:02 eee: but you need to know the element

23:02 so

23:02 I gotta ask for the first element

23:02 Cark: (first my-set) will give you the first element

23:02 eee: right?

23:02 yeah

23:02 Cark: so you know it =)

23:02 eee: is there a multi-map in clj?

23:03 something that allows multiple same keys?

23:03 cause that's anoter difference

23:03 my heap can have dups

23:03 Cark: nope there isn't

23:03 eee: ok

23:03 Cark: you could build one out of clojure maps and lists (or vectors)

23:04 eee: i see

23:04 so I can do (dissoc myset (first myset))

23:04 Cark: right

23:05 eee: trying it out

23:06 having a prob

23:06 must have typod

23:06 class cast exception

23:07 line zero?

23:07 (recur ((dissoc ret (first ret))))

23:07 that's what I have

23:07 Cark: errr looks like you're right

23:07 cp2: you are trying to invoke the return value of (dissoc ...)

23:08 Cark: dissoc isn't the right one, it's for map only

23:08 cp2: (recur (dissoc ret (first ret)))

23:08 Cark: hum there's a functuion for that though

23:08 cp2: o yeah

23:08 it is only for map

23:08 and anyway

23:08 eee: ahhh

23:08 cp2: if you want to remove the first

23:08 (recur (rest ret))

23:08 Cark: noooo

23:08 eee: we just covered that

23:08 don't want to turn into a seq

23:09 it's a sorted set

23:09 cp2: sorry, not paying much attention

23:09 oh ok

23:09 Cark: ah there it is : use disj for sets

23:09 eee: ok

23:09 cp2: my bad :)

23:09 Cark: =)

23:10 eee: think I'm in for a hurtin now

23:10 the timing was offset

23:11 timing in clj always messes people up

23:11 until they are experts, I think

23:11 cause of the lazy stuff

23:11 even doall doesn't always fix

23:12 working now

23:12 or

23:12 so far not complaining

23:12 thanks for the help

23:12 brb. gonna let it churn

23:21 wow, still churning. disj may be slower than turning to a seq

23:21 brb some more

23:26 something wrong with that approach. infinite loop

23:26 it turns out

23:29 or somewhere else

23:29 hmmmmm

23:36 i'm back to something I thought was working. anyone see anything wrong with this?

23:36 (time (def aa (loop [ret a] (if ret (recur (rest ret)) ret))))

23:37 stuhood: i think you need to do (if (seq ret) ...) but i can

23:37 can't remember why.

23:37 cmvkk: yeah, because (rest ret) will never return nil.

23:37 eee: no?

23:37 stuhood: not since the laziness changes

23:37 eee: that must have changed

23:37 cmvkk: or you can use (next ret) instead.

23:37 eee: yeah

23:37 oh

23:37 crap

23:38 that was it

23:38 dang

23:39 works

23:40 now my stuff not trumping anymore

23:40 as predicted, faster on insert, slower on pop

23:40 but inserts + pops is slower than just sorting ahead of time

23:41 so only useful if you want to pop a handful of things

23:41 or I improve algorithms :)

23:42 thanks for the help

23:42 sux that you can't ask for nil ananymore

23:43 stuhood: eee: like cmvkk said, you can just use (next) everywhere for the old behaviour

23:44 eee: ok. ret is fewer chars than (next ret) . . . but I suppose the latter is more descriptive anyway

23:45 stuhood: i mean, (next) instead of (rest)

23:46 eee: oh

23:46 i see

Logging service provided by n01se.net