#clojure log - Mar 04 2009

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

0:26 slashus2: durka42: If the first is a symbol should it give an error?

0:26 durka42: i mean, would you ever use a symbol as doc

0:26 that seems strange

0:27 is doc required to be a literal string?

0:27 slashus2: It appears so.

0:27 (def testing2 "test doc") and used testing2 and it didn't work.

0:31 hiredman: uh

0:31 that is because you just def'ed resting2 to a string

0:31 testing2

0:31 if you want to add a docstring with def you have to use #^

0:33 ayrnieu: you can also add documentation after the fact, with .setMeta

0:34 arohner: so struct-map takes the name of a defstruct, and key value pairs. i.e. (defstruct foo :a 1, :b 2)

0:34 slashus2: I was talking about doing something like (defn testing testing2 [x y] y)

0:34 arohner: if I have a map of key value pairs, how do I call struct-map?

0:34 hiredman: ,(doc defstruct)

0:34 clojurebot: "([name & keys]); Same as (def name (create-struct keys...))"

0:34 hiredman: ,(doc create-struct)

0:34 clojurebot: "([& keys]); Returns a structure basis object."

0:34 hiredman: doesn't say anything about values

0:35 arohner: ,(doc struct-map)

0:35 clojurebot: "([s & inits]); Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none of the basis keys - where values are not supplied they will default to nil. keyvals can also contain keys not in the basis."

0:35 arohner: struct-map wants a list of key value pairs, rather than a map

0:36 lisppaste8: slashus2 pasted "sigs" at http://paste.lisp.org/display/76450

0:36 slashus2: durka42: How does this look?

0:37 durka42: seems to make sense...

0:37 but i'm not an authority on these things

0:40 slashus2: hiredman: Do you think that this is acceptable?

0:40 ayrnieu: arohner, (apply struct-map some-struct (interleave (keys some-hash) (vals some-hash)))

0:41 arohner: ayrnieu: thanks

0:50 is there a built in function to replace the name of a key in a map, keeping the value intact?

0:51 i.e. (dissoc (assoc my-map new-name (my-map old-name)) old-name))

0:51 durka42: i think you just wrote said function :)

0:51 cp2: heh

0:51 arohner: :-) yeah, I was just wondering if I needed to write it

0:52 Raynes: Someone said "Oh Clojure is Scheme for the JVM." I replied "Bite your tongue." Started a whole uproar as they thought I was dissing Scheme.

0:54 arohner: Raynes: where was that conversation?

0:55 Raynes: #Haskell-Blah Nice guys <3 the uproar only lasted until I said "I would never dis Scheme".

0:55 cp2: lol

0:56 ayrnieu: "I would never diss Scheme, but I do think it so shameful for Clojure to be called 'Scheme for the JVM' that I demanded you harm yourself after saying that."

0:56 but it's a silly thing to say, anyway. There are already several schemes for the JVM.

0:58 Raynes: ayrnieu: You took that completely out of context.

0:58 I never meant it as being shameful. Clojure is a world-a-way from being "Scheme for the JVM" that's all I meant.

1:00 ayrnieu: world-a-way meaning 'world-a-better': if it had been asserted that Clojure was "Forth for the JVM", you'd react differently. This assertion is simply wrong.

1:01 Raynes: ayrnieu: What are you even talking about?

1:01 Had he have said "Fourth for the JVM" I would have asked him was he out of his mind.

1:01 Of course I would of reacted differently.

1:01 It doesn't take a genius to realize I'm not putting Scheme down.

1:02 There is around 10 different ways one could take what I said.

1:02 Not just "Scheme is shameful"

1:02 Anyways, I need sleep.

1:02 Good night.

1:03 ayrnieu: I suppose that it's conversations like this that led people to come up with 'EQ'.

1:04 cmvkk: EQ?

1:04 ayrnieu: Emotional Quotient. Like IQ.

1:04 cmvkk: ohh.

1:22 slashus2: durka42: I will have to change that a little bit. cond isn't defined by that point, nor is symbol.

1:24 redalastor: If I have a vector that that contain cartesian coordinates (something like [[3 17] [24 62] [21 99]]), how can I find the right-most or left-most value? If two values are right-most or left-most, any is fine.

1:25 In Python I'd use min and max but in clojure this would not work.

1:26 cmvkk: (reduce (fn [x y] (min x (first y)) myvec) ?

1:26 redalastor: I could always sort it but that seems wasteful.

1:27 cmvkk: wait that wouldn't work

1:27 redalastor: cmvkk: Thanks!

1:27 Why not?

1:27 cmvkk: well i think that might be slightly broken, hold on.

1:27 ayrnieu: sort it by the dimension of interest or else fold over it.

1:27 cmvkk: (reduce (fn [x y] (min (if (coll? x) (first x) x) (first y)) myvec)

1:28 otherwise when reduce calls it with the first two values it will choke on the first coordinate.

1:28 redalastor: thanks

1:29 cmvkk: oh and that will only return the left value, not the whole coordinate...

1:29 hmm...

1:30 (reduce (fn [x y] (if (< (first x) (first y)) x y)) myvec)

1:31 Chouser: (reduce (fn [x y] (if (pos? (compare x y)) x y)) coll)

1:32 cmvkk: ooh compare does things i didn't realize it did.

1:34 redalastor: Yes, interesting. I didn't know vectors were comparables.

1:34 cmvkk: if 'compare' can do that, i think 'min' ought to be able to do it too.

1:35 redalastor: min insists on comparing numbers

1:35 cmvkk: yeah. but clearly it would be trivial to write a min that works anywhere compare does

1:36 redalastor: Yeah, that's what Python and Ruby (I think?) do.

1:36 cmvkk: same with max, <, >, etc...

1:36 could be an efficiency thing I guess

1:37 redalastor: Probably. But they could be diffrently named.

1:37 I kinda expect someone will tell us it already exists in contrib :)

1:42 cmvkk: man. defn is so much harder to write a macro over than defun was.

1:45 ayrnieu: yep. Clojure doesn't have some points of macro-hostility that Scheme has, but then it has superfluous syntax that must be checked and reconstructed properly.

1:47 cmvkk: i have a bad habit of doing things like this: (defn get-filter-stuff [thing & stuff] ...)

1:47 "poor variable naming habits"

1:48 ayrnieu: names are hard.

1:48 cmvkk: names are hard, let's go shopping!

1:49 in this case, though, [thing & stuff] is everything in a defn but the name. so "thing" could be a string, an arglist, a function body...

3:21 eevar2: (conj 10 [1 2 3])

3:22 ayrnieu: ,[(conj [1 2 3] 10) (cons 10 [1 2 3])]

3:22 clojurebot: [[1 2 3 10] (10 1 2 3)]

3:41 eevar2: ,(doc conj)

3:41 clojurebot: "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."

3:41 eevar2: ,(conj [1 2 3] 10)

3:41 clojurebot: [1 2 3 10]

3:41 eevar2: ,(conj 10 [1 2 3])

3:41 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection

3:42 eevar2: (conj [1 2 3] 10)

4:13 BigTom: Hi

4:14 does anyone have an example of reading a file, tweaking it, and writing it, using duck streams?

4:18 I can do something with reading the whole file in processing it and writing it out but I was hoping to do it a line at a time

4:26 Other question, can 'doseq' be considered a "strict" 'for'

4:26 ?

4:26 hiredman: nope

4:26 kotarak: BigTom: no. doseq returns nil and is purely for side-effects. for returns a seq

4:26 hiredman: for is not a loop

4:27 kotarak: clojurebot: for

4:27 clojurebot: for is not used often enough

4:27 kotarak: clojurebot: for

4:27 clojurebot: for is not a loop

4:28 ayrnieu: clojure doesn't need separate 'strict' procedures, anyway; you can dorun or doall a lazy one.

4:29 hiredman: eager is the term

4:30 kotarak: doall is so ugly....

4:30 ayrnieu: it turns out that people have many terms.

4:31 kotarak - (def work doall) ?

4:31 maybe (def WORK! doall)

4:32 kotarak: ayrnieu: I mean the concept itself. Not the name. I understand that for resource management, doall makes sense, but (dorun (map #(println ..) ..)) or (doall (map #(println ..) ..)) is *ugly*.

4:33 ayrnieu: oh, sure.

4:39 kotarak: (defmacro dolist [[v list] & body] `(loop [~v ~list] (when ~v (let [~v (first ~v)] ~@body) (recur (next ~v)))))

4:41 kotarak: ayrnieu: what is the difference to doseq?

4:43 ayrnieu: if you mean to ask why anyone would use this instead of doseq: *shrug*.

4:44 kotarak: ayrnieu: I'm a bit confused, what you want to tell me with this macro.

4:46 ayrnieu: that's OK. I'm going to bed.

4:51 Lau_of_DK: ,(int (* 100 (/ 1966 2864)))

4:51 clojurebot: 68

4:51 Lau_of_DK: According to my head, that should give 69, why dont it ?

4:52 Holcxjo: Lau_of_DK: It doesn't to rounding

4:52 ,(/ 1966.0 2864.0)

4:52 clojurebot: 0.6864525139664804

4:52 cmvkk: yep, the real result is 68.64, which int just chops off the decimal part of.

4:52 Lau_of_DK: Thats cheap

4:53 Do we have a func for ceiling it ?

4:53 cmvkk: Math/ceil?

4:53 Lau_of_DK: or roudinging

4:53 thanks

4:53 cmvkk: you still have to call int if you want an int though; that always tripped me up.

4:53 for some reason, (Math/ceil 68.64) will return 69.0 rather than 69.

4:54 Lau_of_DK: A little odd, but quickly fixed :)

4:54 Thanks for the help guys

4:55 Holcxjo: ,(int (+ 1/2 (* 100 (/ 1966 2864))))

4:55 clojurebot: 69

4:55 cmvkk: heh, that's one way of doing it.

4:55 Holcxjo: truncation becomes rounding if you add 1/2 (or subtract for negative numbers)

4:56 Math/round is the other option

5:01 kotarak: ,(.split "c.c" ".")

5:01 clojurebot: #<String[] [Ljava.lang.String;@adb24>

5:01 kotarak: ,(seq (.split "c.c" "."))

5:01 clojurebot: nil

5:01 leafw: Holcxjo: that (int (+ 0.5 x)) is the best way to round in java/c/c++, AFAIK, all errors considered

5:01 kotarak: Am I missing something=

5:02 ?

5:02 hiredman: ,(count (.split "c.c" "."))

5:02 clojurebot: 0

5:02 hiredman: ,(count (.split "c.c" "\."))

5:02 clojurebot: Unsupported escape character: \.

5:02 hiredman: ,(count (.split "c.c" "\\."))

5:02 clojurebot: 2

5:02 kotarak: argh.

5:02 hiredman: thanks

5:50 lenst: I don't like the new repl_utils. It seems to start some GUI junk.

5:51 cgrand: lenst: to start?

5:52 can you be more precise?

5:54 lenst: I'm running Mac OS 10.4 and when I load repl_utils I get a clojure.main process in my dock.

5:54 cgrand: and no actual window?

5:55 lenst: No window. It probably loads some swing classes, and that makes the java process into a GUI process.

5:57 A

5:57 oops. And when it starts it becomes forground process and steals focus.

6:00 cgrand: lenst: can you try to evaluate javax.swing.JEditorPane in a fresh REPL to see if the simple loading of a gui class causes the process to appear in the dock?

6:01 lenst: It does.

6:03 clojure.contrib.javadoc.browse/open-url-in-swing might be the problem

6:05 cgrand: lenst: ok, can you open an issue, I'll look at it.

6:11 BigTom: Thanks for the correction on doseq and for

6:11 * BigTom shouldn't ask a question then start a conf call

6:16 AWizzArd: clojurebot: max people

6:16 clojurebot: max people is 149

6:52 timothypratley: macro question:

6:53 I want to do something like this:

6:53 (defmacro fun [ & body]

6:53 `(let [name (javax.swing.JLabel. "hi")]

6:53 ~@body)

6:53 (fun (.getText name))

6:53 <- contrived example

6:54 is that possible?

6:55 Lau_of_DK: sure is

6:56 kotarak: (defmacro fun [& body] `(let [~'name (javax.swing.JLabel. "hi")] ~@body))

6:56 timothypratley: but you should clearly document the capture

6:56 timothypratley: :)

6:57 great!

6:58 kotarak: I hope I don't go to Hell for giving such tips. ;)

6:58 timothypratley: how does it work? ~' is clearly unquote quote ---- does that avoid the namespacing --- or something else?

6:59 kotarak: ~'name is the same as ~(quote name)

6:59 clojurebot: 'Sea, mhuise.

6:59 kotarak: You just have to remember, that ~ means "do the following in the context where the macro is defined".

7:00 Where everything else is done in the context the macro is called.

7:00 (rough, but as a general guideline)

7:01 So ~'name means: "fill in (~) the quoted (') symbol 'name'"

7:01 One could as well say: ~(symbol "name")

7:02 timothypratley: oooo

7:03 I almost understand that :)

7:03 kotarak: timothypratley: writing macros is actually simple. (I know, I know, ... let me explain)

7:04 (defmacro foo [] `(bla blub))

7:04 This means simply: replace (foo) with (bla blub) and continue compilation.

7:05 Now first step: ~

7:05 `(bla ~blub)

7:05 This basically means: expand to a call to bla with the second argument replaced by blub from the enclosing context.

7:06 blub could eg. be a macro argument.

7:06 (defmacro foo [blub] `(bla ~blub))

7:06 This can also be any computation: ~(symbol blub)

7:06 Second step: ~@

7:07 This is a bit more complicated, because it "removes" an outer set of parens. So the unquoted thing must be a sequence.

7:08 `(bla ~@[1 2 3]) => (bla 1 2 3)

7:08 This is maybe a simplified view, but I got me very far, when writing a macro.

7:08 timothypratley: so far so good

7:09 papermachine: Is there a mirror for the blip.tv screencast?

7:13 timothypratley: user=> (macroexpand-1 '(foo))

7:13 (user/bla user/blub)

7:13 user=> (defmacro foo [] `(bla ~'blub))

7:13 user=> (macroexpand-1 '(foo))

7:13 (user/bla blub)

7:15 we removed the name space qualifier, but presumably being in the current namespace blub and user/blub are the same?

7:15 (evidently not)

7:24 Oh I think I'm starting to see the light...

7:24 user=> (let [user/blub 2] blub)

7:24 java.lang.Exception: Can't let qualified name: user/blub (NO_SOURCE_FILE:12)

7:24 So I understand your solution better now kotarak thanks

7:28 djpowell: What are the recent checkins related to constants all about?

7:31 rhickey: representing constants as bytecode yields big startup improvement on lowly hardware (like Android phones)

7:31 Chouser: djpowell: they appear to be mostly about altering the indentation of else-if blocks

7:32 or what rhickey said. :-)

7:34 djpowell: cool

7:34 rhickey: I was hoping for a size reduction too, but no joy there

7:36 djpowell: does it help startup time a lot then?

7:38 kotarak: timothypratley: ~'blub basically resolves blub in the context the macro is called, while simply blub is resolved in the context the macro is defined and then replaced by the fully qualified name. So when the macro is expanded, it references the same blub, that the macro knows about.

7:40 djpowell: just tried it, it does seem faster

7:42 timothypratley: kotarak: thanks for the help :)

7:42 kotarak: timothypratley: np :)

8:08 Lau_of_DK: Anyone here who has some experience with AXIS?

8:10 banisterfiend: Lau_of_DK: my grandfather was a nazi

8:11 Lau_of_DK: Im talking about the Apache servlet system

8:11 banisterfiend: oh

8:13 p_l: ...

8:13 timothypratley1: Kotarak: I have another macro question :) From your explanation I understand why this doesn't work:

8:13 (defmacro my-set!

8:13 [obj constraint]

8:13 `(set! (. ~obj ~(symbol (name (first constraint)))) ~(second constraint)))

8:15 because constraint can only have first/second taken if it is a form at macro compile time

8:16 so (my-set! obj (:gridx 1)) works fine, but (my-set! obj c) where c is '(:gridx 1) doesn't

8:16 but how can I get around that constraint?

8:19 I suspect I must mix a function and a macro in some clever way... I can't make it just a function because set! is a special form hence why I'm trying to trick it.

8:23 Holcxjo: Don't use the tilde in front of (symbol and (second if you don't want it evaluated at macro-expansion time

8:26 timothypratley1: Holcxjo: but then (set! does not work at all because it expects a symbol, not a form).... I guess what I'm trying to do is an impossible chicken/egg scenario.

8:33 Holcxjo: timothypratley1: set! does not evaluated the symbol expression to see what it is?!?

8:33 timothypratley1: nope :(

9:00 cemerick: Building my first multimethod hierarchy. It's a joy so far.

9:00 Didn't isa? imply instance? at one point, though?

9:01 kotarak: timothypratley1: I'm afraid you can't. Macro cannot depend on such runtime information.

9:03 cemerick: yes, instance? should also imply isa? (instance? String foo) <=> (isa? String (class foo)) (I'm not sure about the order for isa?, though)

9:04 rhickey: ,(doc isa?)

9:04 clojurebot: "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"

9:05 kotarak: so it probably should be (isa? (class foo) String). I always confuse the order.... :|

9:06 cemerick: ah-ha, I was being thrown off by the same classname floating around in my ns, but from a different package.

9:10 kotarak: timothypratley: that's a common mistake in macro development by the way. You correctly recognised the limits of a macro. Don't make the mistake of trying to hard to push this limit, eg. coming up with some eval using idea. This just gives more problems. See the limits of macros and you just improved your macro-fu by an order of magnitude. :)

9:12 timothypratley: :)

9:13 cemerick: is there a builtin that will return two colls given one coll and a predicate (where one of the returned colls is the result of filtering the input coll using the pred, the other is the result of removing)?

9:15 timothypratley1: cemerick: split-with

9:15 cemerick: timothypratley1: well, almost -- that uses take-while and drop-while

9:16 kotarak: recursive split-with until the seq is consumed.

9:17 hmmm... maybe not. Why not simply (defn unzip-with [pred coll] [(filter pred coll) (remove pred coll)])

9:18 cemerick: yeah, I already wrote that, but I figured there'd be a builtin.

9:18 also, I'm not so hot on pred being invoked 2n with approaches like that

9:18 picky, picky :-)

9:19 kotarak: hmmm... How would this be done lazily w/o calling pred 2n times?

9:19 * cemerick has an idea

9:19 kotarak: You would need some kind of Queue, no?

9:20 When I ask one seq and it finds an item, which doesn't belong there, it stuffs it into the Queue of the other.

9:20 Holcxjo: First create a (lazy) sequence of ((filter pref elem) elem) tuples and then split them?

9:23 Something like this? (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))]))

9:27 lisppaste8: cemerick pasted "split without 2n pred invocations (sloppy first cut)" at http://paste.lisp.org/display/76458

9:28 cemerick: that's super-sloppy, but I gotta run for a bit

9:28 kotarak: Well, it's not lazy?

9:28 cemerick: right, not lazy, but I don't care about that in this case

9:30 my predicate in this case is pretty expensive and all of the results will be consumed anyway

9:41 pjstadig: I got past the classloader issue

9:41 now i (when starting a second repl) i get an arity exception

9:42 wrong number of args passed to: core$map

9:42 it happens in clojure/main.java when it tries to require the clojure.main namespace on line 38

9:43 i can connect JSwat and step through the code, bouncing between the java code and code in core.clj

9:43 mind blowing

9:49 timothypratley1: wohooo I solved by set! woes: (clojure.lang.Reflector/setInstanceField gbc (name (first c)) (second c))

9:49 who needs stinking special forms?

9:53 pjstadig are you able to debug exceptions with JSwat or is it too late by then?

9:56 pjstadig: i can step through until the exception happens

9:56 and when an uncaught exception happens i can see the call stack

9:56 and poke around

9:56 timothypratley1: great!

9:57 * danlarkin wishes he could get JSwat working on his machine

9:57 pjstadig: this is weird

9:57 the problem appears to be in the 'spread function

9:57 actually 'nil?

9:58 danlarkin: well spread is private to core.clj

9:58 Hooke: hello

9:58 pjstadig: 'nil? is returning true for (nil? ArraySeq instance)

10:00 danlarkin: (doc nil?)

10:00 clojurebot: Returns true if x is nil, false otherwise.; arglists ([x])

10:00 pjstadig: hehe

10:00 oh good point

10:01 so apply is calling (. f (applyTo (spread args)))

10:01 Hooke: I'm trying technomancy's emacs clojure-mode. The clojure-install command gives me the error "(Shell command failed with error)" can anyone help, plz

10:03 pjstadig: spread returns nil

10:04 so it tries to apply f (which is loadlibs) to null

10:04 which is where i'm getting my exception

10:05 danlarkin: spread returns nil because the collection you pass is nill

10:05 I'm assuming

10:07 shoover: danlarkin: what's the problem with jswat? are you on JDK 1.6?

10:08 pjstadig: no the collection is not nil

10:08 the collection is [:require 'clojure.main]

10:09 danlarkin: shoover: java 1.5.0_16-133 on osx 10.5, when I launch it crashes with an NPE

10:10 shoover: danlarkin: I think it needs 1.6

10:11 danlarkin: pjstadig: spread "expands" to as many args as the function accepts, what's the arglist on the function you're trying to call?

10:12 shoover: that would explain it, then, thanks

10:12 cooldude127: does swank-clojure allow using jswat for debugging without writing a shell script to start clojure?

10:13 shoover: danlarkin: you'll need to wipe jswat and reinstall, taking pains to associate it with jdk 1.6. unfortunately I can't remember exactly how I did that

10:13 cooldude127: yes, it has a variable for extra jvm args

10:13 cooldude127: shoover: great

10:32 jswat is cool

10:47 pjstadig: nope it's not a problem with 'nil?

10:47 nil? is returning RT.F

10:48 for some reason it is not thinking that Boolean.FALSE == Boolean.FALSE across VMs

10:48 rhickey: pjstadig: ouch

10:48 Holcxjo: A very philosophical POV

10:48 rhickey: that will be a problem

10:49 pjstadig: it is probably something i'm doing wrong

11:14 kotarak: cemerick: how about this unzip-with? http://paste.pocoo.org/show/106457/

11:15 general comments welcome

11:25 cgrand: kotarak: I think you don't need to use PersistentQueue: vectors can suffice

11:27 in make-seq, replace the cons with a concat and the alter by a ref-set []

11:28 kotarak: cgrand: ah, ok. :) Hadn't thought of that.

11:28 Just a sec.

11:30 http://paste.pocoo.org/show/106463

11:50 rhickey: (defn unzip-with [pred coll]

11:50 (let [pvs (map #(vector (pred %) %) coll)]

11:50 [(remove nil? (map (fn [[p v]] (when p v)) pvs))

11:50 (remove nil? (map (fn [[p v]] (when-not p v)) pvs))]))

11:54 kotarak: rhickey: yes. Holcxjo proposed something similar.

11:55 Holcxjo: rhickey: Can't the "(remove nil? (map ..." be done with some for ?

11:56 rhickey: kotarak: sorry, didn't see that

11:56 Holcxjo: Also: What if any element *is* nil ? It'll appear on neiher of the output lists

11:57 kotarak: rhickey: np :)

11:59 rhickey: Holcxjo: heh, just doing that, did you already post it?

12:01 lisppaste8: rhickey annotated #76458 "unzip-with" at http://paste.lisp.org/display/76458#1

12:01 Holcxjo: My solution was an ugly (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))]))

12:01 Sorry for lack of formatting

12:02 You version on pastebin is certainly nicer

12:02 Hadn't thought of for until I saw your solution

12:04 BTW: why "#(vector (pred %) %)" and not "#([(pred %) %])" ? Would you consider the latter too terse for readability?

12:04 kotarak: Holcxjo: #([]) is (fn [] ([]))

12:05 Note the "call" to the vector.

12:05 Holcxjo: Bah -- the #() syntax is a bit too brittle for my brain

12:07 replaca: That is the one annoying thing to me about #(). It seems like about half the time I'm using it to create a quick vector. Well, that and the lack of nesting. :-)

12:07 kotarak: replaca: then simply use #(vector ....)

12:15 cemerick: kotarak, rhickey: thanks for the impls, I'll keep those under my belt for when I need laziness

12:18 replaca: kotarak: yeah, I do, it's just not as purty

12:26 te: rhickey: I just discovered your podcast on iTunes -- thanks!

12:27 rhickey: one other note -- you are a remarkably good speaker for a compsci guy

12:29 rhickey: te: thanks, although I'm not really a compsci guy

12:30 te: rhickey: you fooled me :)

12:30 rhickey: did i hear right that you're just a professional developer that got an itch one day?

12:30 mtz: :)

12:31 rhickey: te: yes, I'm just a developer

12:31 te: a good speaker AND humble

12:31 i'm beginning to like you more and more

12:31 :)

12:32 cemerick: wait, wait, wait -- a podcast, you say? :-D

12:32 te: indeed.

12:32 rhickey: cemerick: I think all the blip things end up as podcasts

12:33 te: It's just his video of clojre for lisp programmers

12:33 cemerick: ah, OK

12:33 te: or at least that's the one im watching right now

12:33 it would be cool to have someone comment weekly on the state of clojure, cool projects, etc.

12:33 community = win

12:34 err sorry: (= (community win))

12:35 mtz: (profit community)

12:36 pjstadig: te: i would listen to your postcast

12:36 *podcast

12:40 zakwilson: "I'm not really a compsci guy" -- rhickey

12:40 And that's why you can get stuff done in Clojure.

12:41 gnuvince: For a non-compsci guy, you sure are knowledgeable about it

12:42 Raynes: "I should probably learn LISP, but it seems so foreign..." - Paul Graham

12:42 zakwilson: I keep saying that about Haskell.

12:43 rhickey: gnuvince: I mean I'm not a researcher or anything, just a practitioner

12:43 gnuvince: ok

12:43 BigTom: is rhickey one of Zed Shaw's Coming Professional Masters ?

12:43 http://www.zedshaw.com/essays/master_and_expert.html

12:43 zakwilson: Though I think I may finally do it just to purify my mind after working on an especially bad PHP project (http://paste.lisp.org/display/76132).

12:43 Raynes: zakwilson: Haskell is fun.

12:45 zakwilson: Raynes: I keep hearing that, but I haven't quite figured out why monads work. I almost get it, but not quite.

12:45 Raynes: zakwilson: When they say it's a mindfuck - They mean it.

12:46 zakwilson: But I need to do *something* to purge the evil from my mind (look at the paste, really).

12:46 Raynes: However, I never got to the monads chapter. Haskell gains and loses my interest several times over time.

12:46 Clojure stole my interest.

12:46 My god.

12:46 That's some nasty PHP.

12:47 zakwilson: I get FP. Really strong static typing makes sense, though I'm not good at using it. Monads are the part I really need to get.

12:47 Raynes: that printf call appered in three different files, slightly modified. The rest of the code is about as bad.

12:47 danlarkin: you can write bad code in any language

12:48 Raynes: danlarkin: But it's less hard to write it in Haskell.

12:48 In Haskell you either write good code or don't write it at all. There aren't many options.

12:48 zakwilson: danlarkin: yes you can, and I'm not blaming PHP for the above badness. You could, in fact write essentially the same thing in Haskell.

12:48 danlarkin: or clojure for that matter

12:49 Raynes: Clojure is a different story.

12:49 zakwilson: Anything with printf or something like it... which is pretty much every general-purpose language.

12:49 Raynes: It's easier to write bad code in Clojure than Haskell I feel, because you aren't held back by Haskell's strongness.

12:49 gnuvince: I agree

12:49 Raynes: Clojure will pat you on the back, Haskell will smack your face.

12:49 Lau_of_DK: Rich might smack you aswell Raynes - Good evening all =)

12:50 gnuvince: Haskell is like Gunnery Sergeant Hartman from Full Metal Jacket

12:50 Raynes: You didn't see the context, it wasn't anything bad about Clojure.

12:50 gnuvince: It's gonna yell at you until all your shit is nice and square

12:50 Lau_of_DK: I know Raynes , I was just making a funny

12:50 Raynes: :p

12:51 Good evening Lau_of_DK

12:51 zakwilson: Yes... Haskell will refuse to compile many common errors and warn you about a host of others.

12:52 BigTom: Hi

12:52 kotarak: gnuvince: and finally it gets shot?

12:52 BigTom: I am processing a log file with for, which is nice and simple and works

12:52 Lau_of_DK: leafw or someone today, mentioned that (int (+ 1/2 x)) is the best way of rounding in c and java - Why is that?

12:52 BigTom: now I want to sometimes generate a couple of lines for each log line

12:52 is there a neat way of doing that?

12:53 cmvkk: hmm, so the for returns a list of lines?

12:53 BigTom: yup

12:53 gnuvince: kotarak: don't push analogies too far

12:53 Lau_of_DK: gnuvince: he always does that :)

12:53 cmvkk: i guess you could wrap each output in an extra list, then do (map concat ...) on the result

12:53 leafw: Lau_of_DK: (int (+ 0.5 x)) -- AFAIK, involves the least assembly instructions and does the right thing.

12:54 Lau_of_DK: isnt that a mapcat cmvkk ? :)

12:54 ah ok

12:54 kotarak: BigTom: (mapcat (fn [one-line] [one-line1 one-line2 one-line3]) log-lines)

12:54 BigTom: cmvkk: that's a thought

12:54 Hi kotarak :-)

12:54 leafw: Lau_of_DK: I guess the clojure version would be (int (+ (float 0.5) x))

12:55 BigTom: Thanks, that'll get me going again

12:55 Lau_of_DK: leafw: no 1/2 works fine

12:55 leafw: Lau_of_DK: but 1/2 is not a primitive.

12:55 Lau_of_DK: ,(+ 1/2 (* 100 (/ 68 20)))

12:55 clojurebot: 681/2

12:55 Lau_of_DK: oops, forgot int

12:56 But yea, true, its not a primitive

13:11 Gents - Ive made a little webservice using compojure and I want the result to be an image which contains 1 colored bar and a pie-chart - i which direction should I be looking to accomplish this?

13:12 danlarkin: definitely an image? or will you use a javascript api for charting?

13:12 kotarak: Lau_of_DK: dejcartes?

13:12 Lau_of_DK: dejcartes is for swing apps I believe

13:12 Chouser: google charts

13:12 Lau_of_DK: danlarkin: I think I need to supply and image, which another sige can just incorporate ala <img src="myservice?arg=1"/>

13:12 kotarak: Lau_of_DK: it uses JFreeCharts, which can export images

13:13 Lau_of_DK: oh ok - I'll look into it

13:13 Chouser: you could use dejcartes to produce a .png, but google's service would allow you to let their servers do the work.

13:13 Lau_of_DK: But is it fast and stable?

13:13 gregh: you can have myservice?arg=1 redirect to google charts with the appropriate chart creation parameters

13:14 Lau_of_DK: I cant imagine GC being as flexibl as I need - The design its very clearly described

13:14 gregh: it's probably at least worth a look: http://code.google.com/apis/chart/

13:15 Lau_of_DK: Thanks greg

13:37 candera: Anyone have a clue how a ref can get completely trashed? As in, I can still do (class @foo), but @foo results in an NPE. I can isolate so that commenting out one line of code makes the problem go away, but the line of code in question doesn't try to modify the ref...

13:38 I hesitate to suggest a Clojure bug (since I know how often it turns out to be the app, not the RT), but that's my best theory at present.

13:38 jayfields: clojurebot url

13:38 hmm, how do I get the url for pasting code?

13:38 candera: There's paste.lisp.org - is that the one you're thinking of?

13:39 jayfields: no, there's some way to get the clojurebot in this room to give you a url.

13:39 @clojurebot url

13:39 #clojurebot url

13:40 Chouser: lisppaste8: url

13:40 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

13:40 Chouser: candera: what does (class @foo) return? Can you do (def tmp @foo)?

13:40 jayfields: thanks Chouser.

13:41 Chouser: jayfields: np

13:41 candera: (class @foo) => clojure.lang.LazySeq

13:42 I can (def tmp @foo), but evaluating tmp throws the same NPE.

13:42 replaca: candera: yeah, cause it's lazy til you try to get the head

13:43 candera: so when you try to evaluate the head (with @foo) the evaluation throws an NPE

13:43 candera: that's my guess anyway

13:43 candera: Makes sense.

13:43 Still leaves me guessing as to what the problem is, however. :)

13:47 Chouser: you should get a stack trace from the NPE that shows the root cause

13:49 candera: Chouser: So, this is a game. The error that's thrown is from the next deref of the ref. The update occurs previously. If I make a change in the update code, it no longer barfs.

13:53 AWizzArd: what is an easy way to convert a java HashTable or HashMap into a Clojure map?

13:53 Chouser: right, the update code is apparently creating a new lazy seq

13:53 AWizzArd: is into the best way?

13:53 Chouser: candera: it's in the evaluation of one of the items in the lazy seq that the NPE is thrown.

13:54 candera: Chouser: Ah, duh. Man I thought I had finally internalized this laziness stuff...

13:54 Chouser: Thanks! I'll proceed down that road.

13:55 Chouser: candera: here's a simple example, in case it helps: (def foo (lazy-cat [1 2 3] (.x nil)))

13:55 (take 3 foo) will work fine

13:55 but just foo by itself blows up, because the repl will evaluate the whole thing in order to print it.

13:56 AWizzArd: unless you're going to "update" the map, you should be able to just pass around the Java collection.

13:56 candera: Chouser: yep. That makes sense. Thanks again!

13:56 AWizzArd: Chouser: well, in reality I have a HashMap with strings as keys. In Clojure I would prefer to have them translated into keywords

13:56 Chouser: AWizzArd: otherwise, (into {} the-map)

13:58 AWizzArd: (zipmap (map keyword (keys the-map)) (vals the-map))

13:59 (reduce (fn [m [k v]] (assoc m (keyword k) v)) {} the-map)

13:59 * Chouser shrugs

13:59 AWizzArd: btw, does keys and vals guarantee the same order?

14:00 Chouser: if the underlying map does. I think but do not know that that's the case.

14:00 AWizzArd: provided no other thread writes to the map while we want to zipmap them, is it guaranteed that the key/value pairs will still match?

14:01 Chouser: AWizzArd: you should verify that or use the reduce version

14:06 lisppaste8: jayfields pasted "user defined globals" at http://paste.lisp.org/display/76474

14:06 jayfields annotated #76474 "using printer.clj" at http://paste.lisp.org/display/76474#1

14:08 jayfields annotated #76474 "failing version" at http://paste.lisp.org/display/76474#2

14:09 jayfields: okay, so I want to use (defonce *flag* ...) to allow users to set a flag when consuming my library, but when I try to set the flag and consume the printer class I get a failure (code available at the last link from lisppaste8)

14:10 I can get around this issue by defining the *flag* in the same namespace, but that seemed like poor form, or is that the correct way?

14:13 tashafa: jayfields: dont know what you are trying to do, but have you tried "require" instead of "use" in the ns form

14:14 jayfields: nope, I check the docs. I don't know the difference.

14:17 lisppaste8: tashafa annotated #76474 "using require" at http://paste.lisp.org/display/76474#3

14:19 jayfields: that code executes without throwing an exception, but 'hello' is printed

14:19 tashafa: i think 'use' infers all the symbols in the corresponding namesapce into the current namespace

14:19 jayfields: because (I assume) *should-print* from helpers.printer is being used by print-hello

14:20 what I want to be able to do is define a flag that will cause the print not to happen.

14:22 tashafa: i have no idea what *should-print* does... maybe someone more knowlegabel can help

14:23 jayfields: *should-print* is just the name of my flag

14:23 you could just as easily use *my-flag*

14:23 there's nothing special about it.

14:23 tashafa: and if that flag is set println shouldnt print?

14:23 set to false that is

14:23 kefka: If I call a function at a top-level (using emacs shell) that blocks, is there any way to stop it without killing the whole toploop?

14:24 jayfields: did you see helpers.printer?

14:24 ayrnieu: kefka - no.

14:24 tashafa: yeah

14:25 jayfields: oh, sorry, I missed some code, one second.

14:25 lisppaste8: jayfields annotated #76474 "print-hello that notices *should-print*" at http://paste.lisp.org/display/76474#4

14:26 jayfields: sorry, missed the conditional logic the first time.

14:27 so, given the last annotation, what I'm trying to do is let someone defonce *should-print* to false if they don't want the print to happen.

14:27 tashafa: i think you may want to use a ref

14:29 or be more functional

14:31 Raynes: Needs moar functional.

14:31 tashafa: Raynes: ha, you know what i mean

14:32 hiredman: why use a ref?

14:32 jayfields: okay. so the problem is, I need to define a test, and in one context, immediately run that test, and in another context, don't do anything.

14:32 cemerick: my first day seriously using a hierarchy -- I seem to be writing a lot of code like (some #(isa? (class foo) %) [::type1 ::type2 ::typeN]). Is there a better (and likely faster) way to work with determine if an object is a match against some set of hierarchy "types" that are only available at runtime?

14:32 hiredman: if you are using a ref you shouldn't use **

14:32 jayfields: I'm writing some tests that I want to execute one at a time sometimes, but also as part of a larger suite at other times

14:33 hiredman: ** is used to mark things that are intended to be dynamicaly rebound

14:33 jayfields: I created a macro that defines the test (using deftest from test-is) and runs the test when I want to execute individually

14:33 ayrnieu: jayfields - when you put this a library and have someone else use it, their defonce'd *should-print* will appear in another namespace. If you also export a (def *should-print* true) , then they could (bindings [*should-print* false] ...) to disable that. If you want a toplevel setting, then offer a ref for them to set or export a 'config' or like function that they can pass keywords to.

14:34 Raynes: I need to buy some ink so I can print the CA.

14:34 tashafa: hiredman: true, no **, @your-flag

14:34 jayfields: but I also want to not execute the individual test and run them all as a suite.

14:36 tashafa: Reaynes: CA?

14:36 lisppaste8: jayfields pasted "run individual tests" at http://paste.lisp.org/display/76476

14:36 shoover: jayfields: have you looked at binding? by definition it establishes a binding per thread, but it works great for doing different things in different contexts

14:37 hiredman: ^-

14:37 binding and set!

14:37 lisppaste8: jayfields annotated #76476 "with *execute-individual-test* set to do nothing" at http://paste.lisp.org/display/76476#1

14:37 hiredman: re-defing is bad, don't do it

14:37 ayrnieu: jayfields - ^ my last answer

14:37 jayfields: I get binding, but it doesn't work in my case because I want the code to execute without doing anything extra when run in isolation.

14:38 hiredman: ,(doc set!)

14:38 clojurebot: java.lang.Exception: Unable to resolve var: set! in this context

14:38 hiredman: bah

14:38 ayrnieu: jayfields - OK, now read that last part. Use a ref internally but export a nice function by which they can control your library's behavior.

14:38 hiredman: ugh

14:43 tashafa: what ayrnieu said... hiredman: are you disagreeing?

14:44 jayfields: okay, so in my test_runner namespace I'll use a ref, but I'll also create a function that changes that ref, right? And, couldn't I just use an atom?

14:45 hiredman: ,(binding [*in* 1] (set! *in* 2) (println *in*))

14:45 clojurebot: 2

14:45 hiredman: Yes

14:45 ayrnieu: jayfields - yes, for the sake of offering decent interface that you can extend later. You could.

14:46 hiredman: the mechanism used for setting things like that in core.clj is set!

14:47 ,(do (set! *in* 2) (println *in*))

14:47 clojurebot: java.lang.IllegalStateException: Can't change/establish root binding of: *in* with set

14:47 hiredman: I see

14:49 well

14:49 *cough*

14:49 shoover: jayfields: can you paste examples of calling into helpers.test_runner?

14:49 hiredman: if you do go the ref route, you will most likely want an atom instead

14:50 candera: Chouser: your advice was helpful in tracking down the problem. However, it's still weird: if I alter a vector via concat without first materializing it via vec, it still blows up.

14:50 hiredman: unless there is the potentional for lots of contention

14:50 shoover: jayfields: re atom vs. ref, yes, atom is fine instead of ref if you don't need to synchronize with other state

14:50 candera: That is, (alter foo concat (additional-items)) blows on me, but (alter foo (fn [v] (vec (concat v (additional-items))))) does not.

14:51 ayrnieu: ,(concat [1] [2])

14:51 clojurebot: (1 2)

14:52 lisppaste8: jayfields annotated #76476 "example using test_runner" at http://paste.lisp.org/display/76476#2

14:52 jayfields: shoover: there's a simple example

14:55 shoover: ok, and from the REPL you'd want that def-test to define and run the test, but from a suite you'd want to define everything and then run them all at the end?

14:56 jayfields: shoover: I'm doing it in IntelliJ with La Clojure, but I believe the result is the same.

14:56 Victorr: hello, I can't get Slime to work with clojure, I get "java.lang.Exception: Unable to resolve symbol: lazy-seq in this context (core.clj:70)", does anyone have any hint?

14:57 shoover: how about defining the default to actually run an individual test, so that works with IntelliJ, then define a suite-runner function that binds *execute-individual-test* to do nothing and inside that binding runs all the tests?

14:57 Victorr: I'm using the latest slime/swank/clojure from their repositories

14:57 hiredman: Victorr: it has come up before

14:58 AWizzArd: ,(map identity {:a 1, :b 2})

14:58 clojurebot: ([:a 1] [:b 2])

14:58 hiredman: Victorr: can you start the repl by itsself?

14:58 AWizzArd: Is there a function that will put the key/value pairs of a java HashMap or HashTable into a vector, as in that example above?

14:58 Victorr: hiredman: I can

14:59 hiredman: it seems to me that perhaps lazy-seq moved? It is in clojure-contrib, yet I don't see a (:use) statement for it in swank's core.clj

14:59 hiredman: nah

15:00 shoover: jayfields: actually, I see that because your macro expands to code to run the test right away, you will need to use an atom or find a way for the suite to actually load tests.heartbeat's code in a binding that nulls out *execute-individual-test*

15:00 hiredman: Victorr: I would check again that you have the latest everything

15:00 shoover: or manually def it in your IntelliJ interactive session to actually do something

15:00 Victorr: I just checked out from their repositories just now :-(

15:01 hiredman: I don't use emacs, but other people have come in here with that Exception before

15:01 Victorr: google is not turning up anything, unfortunately

15:01 hiredman: I have four or five hits for that exception in my irclogs

15:02 Victorr: ok, I'll see if I can irc logs for this channel..

15:02 shoover: Victorr: lazy-seq is defined in clojure.core in versions of clojure as of a few weeks ago. If it doesn't exist, swank is not running in a recent enough version of clojure

15:03 perhaps your swank-clojure settings are looking at the wrong clojure, or you haven't rebuilt clojure.jar?

15:03 Victorr: ok, I'm pretty sure I just downloaded the latest clojure, but I'll try again

15:03 I'll build from source

15:03 hiredman: the latest release is way old

15:04 and I am sure the latest swank/slime/etc won't work with it

15:04 Victorr: hiredman, thanks a lot, indeed building clojure from source fixed it!

15:05 * hiredman should remember that

15:08 cooldude127: did PersistentQueue disappear or something?

15:09 kotarak: cooldude127: just used it today clojure.lang.PersistentQueue/EMPTY

15:10 cooldude127: shouldn't have, looks like it's in the source tree. so why does simply typing clojure.lang.PersistentQueue into the REPL spit an error

15:10 i have some code that was using it and worked fine, and now when i try to load that file it whines

15:10 jayfields: thanks shoover.

15:10 kotarak: cooldude127: well. it does not for me

15:11 ,clojure.lang.PersistentQueue

15:11 clojurebot: clojure.lang.PersistentQueue

15:13 cooldude127: ok, i did ant in the clojure dir, killed SLIME, brought it back and we're good

15:13 cemerick: it would be very handy if when-let could accept more than one binding, returning nil if any binding in the binding-form is nil

15:14 ayrnieu: cemerick - 'whereas' is a name for a syntax like this. It makes some legalistic sense :-)

15:14 cemerick: ayrnieu: is that what CL calls it?

15:15 ayrnieu: cemerick - CL doesn't have a name for it, but the name came up in a discussion on comp.lang.lisp

15:15 cemerick: ah

15:16 it doesn't seem like another name should be at all necessary

15:16 at least given when-let's general charter

15:18 ayrnieu: yeah, the limitation is arbitary. I'll post a patch.

15:18 taggart: ,(abs -2)

15:18 clojurebot: java.lang.Exception: Unable to resolve symbol: abs in this context

15:18 jwinter: ,(Math/abs -1)

15:18 clojurebot: 1

15:19 taggart: aha interop

15:19 jwinter: :)

15:20 taggart: am I correct, that that is calling java.lang.Math.abs()?

15:20 or is it a namespaced clojure func?

15:20 ayrnieu: that is calling Math.abs()

15:20 cooldude127: taggart: you should look at clojure.contrib.math

15:21 taggart: ah yes thanks

15:21 cooldude127: it provides better definitions of certain math functions like abs and sqrt that work on all numeric types

15:21 including clojure's ratios

15:22 jwinter: clojure.contrib.math url:http://github.com/kevinoneill/clojure-contrib/blob/a19a1d1921618fe802e57fb835eb98c2164e51ba/src/clojure/contrib/math/tests.clj

15:26 tashafa: question, this might not even apply to clojure so please forgive me

15:27 cooldude127: go for it

15:27 tashafa: im using the lazy-xml from clojure.contrib to parse xml from a url

15:27 im getting the sax parse error "Content in prolog"

15:28 and i know the cause

15:28 Chouser: tashafa: what's the value of clojure.contrib.lazy-xml/has-pull

15:28 oh.

15:29 good, then. :-)

15:29 lisppaste8: ayrnieu pasted "n-binding when-let" at http://paste.lisp.org/display/76480

15:29 tashafa: the xml from the server doesnt start with <?xml ... ?>

15:30 anyway i can modify the stream before i send it to parse-trim

15:31 lisppaste8: ayrnieu annotated #76480 "oh, right, we have zero? at this point" at http://paste.lisp.org/display/76480#1

15:32 tashafa: Chouser: has-pull is false

15:33 The exact SaxParseException is "Content is not allowed in prolog."

15:33 Chouser: tashafa: ok, that just means you're a sax parser (instead of pull parser) running in its own thread using a blocking queue for communication with the main thread.

15:35 tashafa: ok... so i need to chage has-pull to true?

15:35 Chouser: nono, it's fine.

15:35 but since you were getting an error from the parser, it might be useful to know which parser.

15:36 if you don't specify one, it'll use the pull parser if available, otherwise the builtin sax parser

15:37 tashafa: has-pull is def'ed false

15:37 cemerick: ayrnieu: looks good, but it should probably assert (pos? (count bindings)) too

15:38 tashafa: so i dont see how it would use parse-seq-pull which in turn usess the pull parser

15:39 ayrnieu: cemerick - (let [] ...) also works. The user doesn't need to be protected here, and it helps with macros over when-let [including when-let itself, here].

15:40 cemerick: ah, I didn't realize that (let [] ) worked.

15:40 tashafa: i do have XPP in my calss path

15:40 classpath*

15:42 lisppaste8: ayrnieu annotated #76480 "grammar-fix in assert string" at http://paste.lisp.org/display/76480#2

15:43 tashafa: unless i change lazy_xml/has-pull to true in the source

15:44 which i dont want to do

15:44 :-/

15:47 ayrnieu: (def x 1) (.bindRoot #'x 2) x => 2

15:49 tashafa: anyways back to the original question

15:50 can a stream be modified before being used?

15:50 if so, how?

15:51 pjstadig: so after some tests with a simple java app...

15:52 it appears that I shouldn't expect Boolean.TRUE to be == across VMs

15:52 I could make Boolean.TRUE a root so that it is the same instance across VMs, but I get an error when I try to do that

15:53 so they either need to be compared using equals or .booleanValue == .booleanValue

15:53 or i could create another static field make it a root and make sure that field is always used instead of Boolean.TRUE and Boolean.FALSE

15:54 we almost have that with RT.T and RT.F, but there are some cases where Boolean.TRUE and Boolean.FALSE are used directly

15:55 tashafa: let me rephrase...

15:56 all i need to do is parse some xml, the xml is valid but has no prolog and i have no way to modify the stream

15:57 to add the prolog

15:58 actually its the xml declaration

15:58 and i think the saxparser chokes on this

15:58 Chouser: tashafa: (load "lazy_xml/with_pull") is supposed to re-def has-pull if it successfully loads xpp

15:59 tashafa: Chouser: but (load "lazy_xml/with_pull") is only called when has-pull is true

16:00 ([s] (if has-pull (parse-seq-pull s) (parse-seq s startparse-sax)))

16:00 (defn- parse-seq-pull [& _]) (try (load "lazy_xml/with_pull") ...

16:01 dcnstrct: Clojure + HtmlUnit FTW!! it's the ultimate web-interaction testing system. It totally blows away any of the Ruby libs for this kind of thing.

16:01 tashafa: or i'm i missing somethign

16:02 brb... meeting :(

16:03 Chouser: tashafa: no, that code is unusual and confusing. It may be buggy, but not in the ways you've mentioned yet.

16:03 tashafa: feel free to ping me when you get back.

16:03 dcnstrct: infact I'm finding so many java libraries that are better than most of the Ruby stuff I'm used to dealing with.. it's just that they were so painful to use before.. but now...

16:07 jwinter: what are you comparing HTMLUnit to?

16:13 Hooke: hi

16:18 Raynes: http://groups.google.com/group/LSharp/browse_frm/thread/f966f9a809cc702b Read what Rob said. (Yes this is relevant.)

16:22 tashafa: Im back

16:22 Chouser: Hooke: hi

16:23 Hooke: hi Chouser :)

16:23 Chouser: tashafa: the 'try' is not part of the definition of parse-seq-pull. It could probably do with a blank line in there.

16:24 tashafa: ah

16:24 i see

16:24 Chouser: if you really want to try using xpp, which may or may not solve your real problem, you could try commenting out the try and catch parts

16:25 that should give you a stack trace of what's actually failing in with_pull

16:29 tashafa: ok, so there isnt a way to add the xml declaration to an xml stream

16:31 Chouser: I'm surprised you need it. let me try some things..

16:32 ok, the xpp parser doesn't complain when given a correct xml document with no <?xml?> header.

16:35 tashafa: cool

16:36 aight let me see whats up

16:36 IT keeps deleting my .emacs file

16:36 * Hooke has just finished setting up emacs for clojure. yipieee!!

16:36 tashafa: they think its some sort of virus file

16:37 hiredman: makes sense to me

16:40 shoover: Hooke: I'm happy for you and sad that the conquest merits such elation

16:40 tashafa: THAT is a new one

16:41 +1 for emacs, -1 for emacs. dead even yet again

16:41 Hooke: shoover: thanks, .. I guess :D

16:43 Chouser: tashafa: I also get no error with the standard SAX parser. I think your problem must be somethine else?

16:44 tashafa: Chouser: for real

16:44 shoover: if it doesnt look like a windows file and its sitting in root they delete it

16:45 Chouser: (clojure.contrib.lazy-xml/parse-trim (java.io.StringReader. "<foo/>"))

16:45 shoover: tashafa: that's understandable. can you put it in your user profile directory?

16:46 tashafa: yeah thats what i need to do

16:49 chouser: if i give you the url to the xml could you try it on your end?

16:49 Chouser: sure

16:50 tashafa: pm'ed

16:56 cemerick: if-let has the same limitation of a single binding form as when-let. That probably makes more sense, though (especially since one wouldn't know what bindings are false in the else branch).

17:02 ayrnieu: cemerick - 'none of them' is wise.

17:05 cemerick: ayrnieu: what made me think of it is a situation where I needed to test whether any of a set of bindings were true, so I don't know about the friendliness/obviousness of that.

17:10 Raynes: (doc defonce)

17:10 clojurebot: defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated; arglists ([name expr])

17:10 Raynes: Lot's of def's.

17:23 replaca: tashafa: re: .emacs on Windows, you can set your HOME environment var and then put your .emacs file there instead of in c:\

17:25 tashafa: Chouser: figured it out

17:25 Chouser: ah, great, what was it?

17:26 tashafa: the respponse from the server is compressed

17:26 gzip

17:26 Chouser: ah, ok.

17:26 tashafa: now to figure out how to umcompress

17:27 Chouser: there's a java library for that! TM

17:27 tashafa: un*

17:28 Chouser: java.util.zip.GZIPInputStream

17:29 tashafa: thanks

17:39 cmvkk: it's not safe to use | as a symbol right?

17:40 or rather, it's possible/likely that it will be used for something in the future?

17:47 tashafa: chouser: golden! thanks for all your help man!

17:47 Chouser: golden! thanks for all your help man!

17:49 kotarak: cmvkk: the allowed characters for a symbol are detailed on the clojure site: http://clojure.org/reader I would only rely on those.

17:51 cmvkk: kotarak, yeah, that's why I asked, actually. Just wondering if there was any updated information along those lines.

17:51 thanks though

18:01 tashafa: ftw, add an item to the end of a list?

18:02 jakewins: Hi! I'm really wanting to try clojure out, but I am something of a newbie in Java-environments, and as such am having trouble getting my first clojure project to run.

18:02 Could someone point me to a hello-world example or something?

18:02 tashafa: ,"hello world"

18:02 clojurebot: "hello world"

18:02 jakewins: lol

18:03 Thanks. I need it to build together with a java application though,

18:03 tashafa: jakewins: do you already know your way around the repl?

18:03 jakewins: Tashafa: I know my way around nothing, I am afraid

18:04 tashafa: what exactly are you trying to build

18:05 or from what programming language are you coming from

18:05 ?

18:05 web, desktop, etc..

18:05 jakewins: Php mostly, some c

18:06 And I know java as a language, ie, I can write pretty decent applications

18:06 So I can get a normal java app to run without any trouble

18:06 What I want to do is go into "clojure-land" from my java class

18:07 One sec

18:08 tashafa: ftw, add an item to the end of a list? cons

18:08 god, im losing it today

18:08 jakewins: From my main()-method in java, I run something in the likes of

18:08 clojure.lang.RT.var("com.example.clotest.test", "main").invoke(args);

18:08 Which indeed launches clojure

18:09 But it launches it into the interactive-loop

18:09 or whatever it's referred to as

18:09 ie. I don't think it even runs the clojure function "main"

18:10 tashafa: nah...clojure doesnt work anything like java

18:10 Hooke: jakewins, I'm new too, but I'd say that the first you have to decide is what IDE to use. if you want netbeans, there the "enclojure" plugin. if you like emacs, there's clojure-mode

18:11 jakewins: Tashafa: Which is what I'm after :) My companies clients demand stuff that runs on java-platforms, but I'm not a fan of java, which is why i'd like to try this out

18:11 Hooke: I use eclipse

18:11 I found a clojure plugin for it, I haven't been able to figure out if it's any good though

18:12 *company's, sorry bout the spelling

18:12 tashafa: i tried the eclipse plugin for clojure a while back and it was a bit immature, dont know how well it fairs now

18:12 Hooke: ah, yeah, I installed that one too. didnt try it much though

18:13 tashafa: fares*

18:13 jakewins: Hooke, tashafa: I dunno, I haven't been able to really try it yet :)

18:14 Hooke: now I configured emacs according to http://riddell.us/clojure/

18:14 if you do emacs, i think thats best

18:14 tashafa: i'm also coming from eclipse... i would suggest emacs

18:14 Hooke: especially the example, ants

18:14 ants.clj

18:14 jakewins: Hmm.. I'll definately looked into that

18:14 Hooke: very impressive

18:14 tashafa: its a step learning curve, but worth every minute once you are comfortable

18:15 Hooke: if you try emacs, try the paredit mode

18:15 tashafa: ants.clj is pretty much on the advanced side

18:15 jakewins: Tashafa: I gave emacs a shot a while back, and I can see that once you've got the basic keyboard-shortcuts down it will rock your world

18:16 tashafa: what is the paredit mode anyawas

18:16 cp2: ants.clj is my favorite :)

18:17 Hooke: tashafa: it's for never having unballanced brackets

18:17 jakewins: Oh well, I'll dig deeper into this at work tomorrow, I've gotta get up in 7 hrs

18:17 Thanks for your help guys

18:18 tashafa: im i just turn on the Paren Hihglight matching

18:18 jakewins: come back on tomorrow

18:18 we'll be here

18:18 Hooke: all commands do things to sexprs, like splice, nest, and so on, without ever deleting a bracket on one side only

18:19 tashafa: hmm i have to try it out

18:20 Hooke: http://www.emacswiki.org/cgi-bin/wiki/ParEdit

18:20 tashafa: ftw, add an item to the end of a list? cons -> false

18:22 Hooke: http://mumble.net/~campbell/emacs/paredit.html

18:24 tashafa: sorry, I dont get what you mean

18:25 tashafa: Hooke: sorry i was asking how you would add an item to the end of a list

18:26 Hooke: ah, yeah, I understand that, but .. do you mean bringing an item from outside or writing it .. I mean, write it you always can

18:26 tashafa: from outside

18:26 Hooke: bringing it from after the list would be the command paredit-forward-slurp-sexp

18:26 tashafa: i guess

18:27 nah not talking ide anymore

18:27 Hooke: C-), C-<right>

18:28 ahm, sorry, what are you talking about now?

18:28 tashafa: ,(cons '( 1 2 3) 4)

18:28 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

18:29 tashafa: ,(conj '( 1 2 3) 4)

18:29 clojurebot: (4 1 2 3)

18:29 schoppenhauer: ,blah

18:29 clojurebot: java.lang.Exception: Unable to resolve symbol: blah in this context

18:29 tashafa: ,(cons 4 '( 1 2 3))

18:29 clojurebot: (4 1 2 3)

18:29 schoppenhauer: ,(lambda () ())

18:29 clojurebot: java.lang.Exception: Unable to resolve symbol: lambda in this context

18:29 schoppenhauer: ,(fn () ())

18:29 clojurebot: java.lang.NullPointerException

18:29 schoppenhauer: ,(fn [] )

18:29 clojurebot: #<sandbox$eval__7396$fn__7398 sandbox$eval__7396$fn__7398@3813c>

18:30 schoppenhauer: ,(do (fn []) (fn []))

18:30 clojurebot: #<sandbox$eval__7402$fn__7407 sandbox$eval__7402$fn__7407@12421db>

18:30 schoppenhauer: scnr

18:31 tashafa: is it even possible to add to the end of a list cause of lazy-seq?

18:32 ,(conj [1 2 3] 4)

18:32 clojurebot: [1 2 3 4]

18:32 hiredman: ,(concat '(a b)

18:32 clojurebot: EOF while reading

18:32 hiredman: ,(concat '(a b) '(c))

18:32 clojurebot: (a b c)

18:32 hiredman: but don't do that

18:32 tashafa: ok...

18:32 hiredman: lists are for fast adding to the head

18:32 tashafa: change to a vec and conj that

18:33 hiredman: ugh

18:33 tashafa: vec the list and then add it to the end

18:34 hiredman: I guess, but it would be to either always use a vector or always use a list

18:34 tashafa: turn the list into a vector and conjoin the item?

18:35 hiredman: you just said the same thing three times in a row

18:35 and I said "ugh" the first time

18:35 tashafa: sorry i thought you didnt understand what i said

18:35 hiredman: ,(time (vec (range 1000)))

18:35 clojurebot: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 13

18:35 "Elapsed time: 0.999 msecs"

18:36 Hooke: ,(+ 2 2)

18:36 clojurebot: 4

18:36 hiredman: ,(time (do (vec (range 100000)) nil))

18:36 clojurebot: "Elapsed time: 66.523 msecs"

18:36 hiredman: I guess that could be acceptable

18:39 tashafa: no p i was applying a list to a partial struct ...

18:39 so i jest changed the structure of the list

18:39 so i just changed the structure of the defstruct*

18:39 if that makes any sense

18:40 i need to take a break...

18:40 my typing is awful

18:40 goodnight folks

18:40 Hooke: gnite taggart

18:40 sorry

18:40 gnite tashafa

19:14 stuhood: ,(class (vec (range 10)))

19:14 clojurebot: clojure.lang.LazilyPersistentVector

19:14 stuhood: hiredman: i thought 66ms looked suspicious... heh

19:15 ,(class (doall (vec (range 10))))

19:15 clojurebot: clojure.lang.LazilyPersistentVector

19:16 stuhood: ~source vec

19:17 ,(class (to-array (range 10)))

19:17 clojurebot: [Ljava.lang.Object;

19:18 stuhood: nevermind... it wasn't actually being lazy. it's just that fast

19:48 yonatan__: newbie question: any way to get a stack trace on an exception?

19:49 i'm getting "java.lang.IndexOutOfBoundsException (bitmap.clj:0)"

19:49 how do you debug this?

19:52 Chouser: yonatan__: you're at a regular repl?

19:52 yonatan__: yeah

19:52 Chouser: (.printStackTrace *e)

19:52 yonatan__: thanks!

19:54 Chouser: np

19:55 Drakeson: is this: (import '(org.postgresql Driver)) supposed to work, when I have obtained http://jdbc.postgresql.org/download/postgresql-8.3-604.jdbc4.jar ?

19:57 Chouser: yes. That .jar must be in your classpath.

19:58 or must be in a directory named by -Djava.ext.dirs=

20:02 Drakeson: Chouser: thanks

20:02 jhawk28: related to Issue 34: is there any good way to access the value of a Var in the dynamic scope on the Java side?

20:02 * Drakeson is sooooo00OO confused

20:03 * Drakeson thinks computer just played a trick on him

20:07 jhawk28: I can look up the var using the find method, but it has the global value instead of the dynamic scope

20:09 Chouser: jhawk28: you'd have to be within dynamic scope, of course, but then you should be able to call the .get() method

20:13 * Hooke has to go. byee

20:33 jhawk28: chouser: I think my issue is the dynamic scope

20:42 Chouser: is there a reason why the eval reader does not have visibility of the *myVar* in: (binding [*myVar* false] #=(eval (def x 3)))

20:43 Chouser: forms are processed in several phases. string->data which is called "read", and that's when the #=() form is evaluated.

20:43 then compilation, then eval.

20:44 jhawk28: so, even though it is in the scope from a lexical perspective, it is not actually in the dynamic scope?

20:45 ayrnieu: jhawk, #=() is also not in the form's lexical scopes.

20:46 hiredman: the answer is, don't use #=

20:47 ayrnieu: jhawk - it's as if you were copying some text from one page to another by hand, and you resolved to always replace lowercase symbols with uppercase symbols, to always replace 'foo with (quote foo) , etc. So you do this -- and this is when #=() happens -- and *then* turn to what you've written and say: should I expand any macros, here?

20:47 the answer is: understand what you're doing.

20:49 jhawk28: hehe

20:50 gnuvince_: Anybody knows git here?

20:50 ayrnieu: gnuvince - ask a question about it.

20:54 gnuvince_: I think I found it

20:55 I had committed and pushed a file with a DB password

20:55 I wanted to rewrite the history

20:55 I think I found it

21:37 yangsx: what is the best way to get the numeric value of a char?

21:37 ayrnieu: ,(int \a)

21:37 clojurebot: 97

21:39 yangsx: ayrnieu: thanks, I thought that's for numbers :)

22:02 hiredman: ~translate to ru: they just chug half-and-half in the morning

22:02 clojurebot: ??? ?????? chug ??????? ? ?????? ???????? ???

22:06 drewr: ~translate to es: clojurebot is so crazy

22:06 clojurebot: clojurebot es tan loco

22:12 jhawk28: clojurebot: where are you?

22:12 clojurebot: http://github.com/hiredman/clojurebot/tree/master

22:56 felzix: I find that if I define function A before function B then A cannot call B. Is there a way around this?

22:57 hiredman: ,(doc declare)

22:57 clojurebot: "([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

22:57 felzix: ah, thank you :)

22:58 cooldude127: is there any difference between def and declare in that case except that declare accepts multiple names?

22:58 i.e. (def x) == (declare x) ?

22:59 felzix: cooldude127: no

22:59 it just maps over what you supply, def'ing it

23:00 but you can do lots at once :)

23:00 cooldude127: felzix: so for the single case, it is the same?

23:00 that's what i was asking

23:00 felzix: yes

23:00 cooldude127: k, cuz i had been using def for that purpose

23:00 didn't even know declare existed

23:02 felzix: me either. I'm still fuzzy on how globals work in clojure so I wasn't sure I could def things like that

23:04 cooldude127: we don't call them globals :)

23:04 do we?

23:04 hiredman: def once, run anywhere

23:05 cooldude127: lol

23:05 felzix: ah

23:06 Chouser: they do the same thing, but they imply different things to the human reader.

23:06 use 'declare' for forward declarations that will be re-def'ed.

23:06 cooldude127: yeah i figured that was the ideal way

23:07 Chouser: use 'def' with no initial value for things that you will thread-local bind later.

23:27 dreish: ~translate to ru: I can eat glas, it does not hurt me.

23:27 clojurebot: ? ???? ?????? Glas, ??? ?? ?????? ???.

23:27 cooldude127: where did that sentence come from?

23:27 dreish: If I'd spelled it correctly, it would have come from http://www.geocities.com/nodotus/hbglass.html

23:27 dulanov: ~trabsltae to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup.

23:28 clojurebot: excusez-moi

23:28 dreish: Which is in turn devoted to a long-extinct page from I'll say 1995.

23:28 dulanov: ~translate to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup.

23:28 clojurebot: ??? ?????? ?????? ?????? ????????, ????? ?? ???????? ??????? ????????? ???????, ????????????? ? ?????????? ??? ????? ?????????.

23:50 cooldude127: can clojurebot translate to other languages?

23:51 ~translate to es: your mother

23:51 clojurebot: tu madre

23:51 cooldude127: that answers that

23:53 slashus2: su madre?

23:53 cooldude127: tu madre is the informal version

23:54 ~translate to es: I'm on a boat mother fucker, don't you ever forget

23:54 clojurebot: Estoy en un barco de puta madre, �nunca se olvide

23:54 cooldude127: lol

23:56 ~translate to es: I'm on a boat, mother fucker, don't you ever forget

23:56 clojurebot: Estoy en un barco, hijo de puta, no te olvides nunca

23:58 cooldude127: ~translate to ro: I'm on a boat, mother fucker, don't you ever forget

23:58 clojurebot: Sunt pe o barca, mama fraiere, nu te mai uita

Logging service provided by n01se.net