#clojure log - Apr 09 2009

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

1:22 hiredman: ~jdoc java.util.LinkedList

1:54 scottj_: I have some html that is not standards compliant and I would like to use xml-seq with it. It appears that xml-seq needs parse which only works with standards-compliant xml. am I missing something?

2:12 spaceman_stu: hm. When I launch my compojure site from the repl, it can't find the public directory I set up with images, etc

2:12 rather, launch from slime

2:13 it's behaving as though it's not referencing directories from the app's root

2:13 is that a .emacs setting?

2:15 scottj_: probably referencing it from whatever directory was the working directory when you started slime. C-x C-f will try to open a file in the current working directory I think

2:15 hiredman: I think compojure looks for a directory called public in the cwd

2:15 spaceman_stu: cool. So how would I change the cwd?

2:16 hiredman: it is where you start clojure

2:17 scottj_: spaceman_stu: don't really know the best way. you could open a file in the directory you want to be your cwd and then launch slime from there, maybe

2:17 I don't know if ,cd in slime changes the cwd, or whether you need to do that before you load your compojure code

2:20 spaceman_stu: looks like M-x cd is what I'm looking for. THanks both of you

2:31 hiredman: ~mock objects?

2:31 clojurebot: Your mock object is a joke; that object is mocking you. For needing it. -- rhickey

3:21 AWizzArd: Moin moin

3:23 ~seen rhickey

3:23 clojurebot: rhickey was last seen quiting IRC, 318 minutes ago

3:24 AWizzArd: ~max people

3:24 clojurebot: max people is 164

3:33 jdz: hmm, is there a function in core that composes functions?

3:33 i don't like how #(max (count %)) looks

3:34 hmm

3:34 those don't glue together anyway

3:34 but the question still remains

3:36 leafw: jdz: yes: comp

3:36 ,(doc comp)

3:36 clojurebot: "([& fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."

3:36 jdz: ok, thanks

3:43 hiredman: ,(pl ((inc � dec) 0))

3:43 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$dec

3:43 hiredman: ,(pl inc � dec)

3:43 clojurebot: #<core$comp__3753$fn__3755 clojure.core$comp__3753$fn__3755@411379>

3:43 hiredman: ,(pl (inc � dec 0))

3:43 clojurebot: 0

3:44 hiredman: ,(pl (range � inc 3))

3:44 clojurebot: (0 1 2 3)

5:02 AWizzArd: hiredman: what is this pl thing?

5:13 jdz: what would be a proper way to iterate over keyvals sequence (like :key1 val1 :key2 val2 etc) without first creating a map with apply?

5:14 by properly i mean at each iteration step getting a key/value pair

5:26 AWizzArd: like should have a header such as (defn like [[k v] & args] ...)

5:28 or just take [& args] and have a (loop [[k v & rest] args, result []] ... (recur rest (conj result [v k])))

5:28 jdz: hmm...

5:29 AWizzArd: ,(loop [[k v & rest :as all] '(:a 1 :b 2 :c 3), result []](if-not all result (recur rest (conj result [(inc v) k]))))

5:29 clojurebot: [[2 :a] [3 :b] [4 :c]]

5:31 AWizzArd: Does this get you started?

5:31 jdz: too bad "for" does not support this kind of destructuring...

5:31 yes, thanks

5:32 i have written so many loop/recur's that i'm trying to get rid of them

5:32 they have their place in utility functions, but not sprinkled all over the code

5:36 AWizzArd: They are as typical as loops are in any language, such as Javas for loop.

5:36 It's everywhere :)

5:36 jdz: yes but i recently discovered "for" and many things can be written so much more clearly

5:37 AWizzArd: right

5:37 jdz: something like CL' s iterate would be awesome to have, though

5:37 and lazy!

5:47 AWizzArd: In principle I see it as a bug that it does not work with (for ..)

5:47 The problem is the use of when-first in the for macro.

5:48 jdz: yes, i gathered as much

5:49 AWizzArd: The for macro needs a correction in my opinion.

5:50 Currently it is hardwired into it that one takes only one element out of the collection.

5:52 hosiawak: ,(doc pl)

5:52 clojurebot: "([& forms]); replaces a $ b with (a b) walking right to left replaces a � b with (comp a b) left to right ?a with (uncurry a) left to right ?a with (flip a) left to right"

5:59 antifuchs: so... plyntax?

6:07 Chousuke: jdz: partition might work too

6:08 jdz: Chousuke: yes, thank you.

6:11 ,(for [[k v] (partition 2 '(:a 1 :b 2 :c 3))] [(inc v) k])

6:11 clojurebot: ([2 :a] [3 :b] [4 :c])

6:11 jdz: looks so much better!

6:16 AWizzArd: jdz: but this is then again already much closer to the apply which you did not want to have

6:17 jdz: what apply?

6:17 the point is that i want function to accept a list of key/value pairs, not a map

6:18 like (defn foo [x y & keyvals] ..) instead of (defn foo [x y keyval-map] ...)

6:19 AWizzArd: Why? :)

6:19 jdz: and creating a map in-between feels worse than going through a sequence by two elements

6:20 because the first approach looks better at the call site

6:20 AWizzArd: It saves two chars: { and }

6:20 jdz: and many core functions work that way

6:20 and it also saves stress on my eyes

6:20 AWizzArd: Several of these core functions work this way to *create* a map.

6:21 jdz: yes, but they do not ask you to provide a map :)

6:21 AWizzArd: This is obviously necessary.

6:21 jdz: like assoc; there is a difference between assoc and merge

6:21 AWizzArd: Sure, how could you provide a map if your goal is to create one?

6:22 ,(conj {:a 1, :b 2} {:c 3})

6:22 clojurebot: {:c 3, :a 1, :b 2}

6:23 AWizzArd: The map is a really good data structure if you need key/value pairs.

6:23 jdz: i'd prefer (assoc {:a 1, :b 2} :c 3) to conj any time of day

6:24 AWizzArd: That's fine. But in that case you must already know what the target is.

6:25 jdz: target being?

6:25 AWizzArd: hashmap

6:25 jdz: in your context?

6:25 AWizzArd: ,(conj (list 1 2 3) 0)

6:25 clojurebot: (0 1 2 3)

6:25 AWizzArd: ,(conj (vector 1 2 3) 4)

6:25 clojurebot: [1 2 3 4]

6:26 jdz: i'm not getting the drift, sorry

6:26 AWizzArd: assoc is very good for documenting the code. It tells your readers that you explictly want to work on maps.

6:26 But conj allows for more generic algorithms.

6:26 jdz: yes, and that is besides the point

6:27 AWizzArd: also in your example you will need to apply assoc to your & kv-pairs

6:27 if that were a map you could just assoc them

6:27 jdz: no

6:28 AWizzArd: ,(assoc {:a 10, :b 20} '(:c 30))

6:28 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc

6:28 AWizzArd: ,(apply assoc {:a 10, :b 20} '(:c 30))

6:28 clojurebot: {:c 30, :a 10, :b 20}

6:28 AWizzArd: vs

6:28 ,(assoc {:a 10, :b 20} {:c 30})

6:28 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc

6:28 AWizzArd: cool

6:28 jdz: the point is that i don't want to create a map

6:29 i want my function to accept options

6:29 AWizzArd: To save the caller side from typing two more chars?

6:29 jdz: the caller should not be constructing maps just to please the callee

6:29 AWizzArd: Yes, like keyword args in CL.

6:29 jdz: all i want is to pass some options

6:29 constructing maps is just a clutter

6:29 AWizzArd: But how do you define the defaults?

6:30 jdz: if the callee wants to construct a map out of the options, it's callee's business

6:30 AWizzArd: The idiomatic Clojure design pattern is to pass a map and merge it with the defaults.

6:30 jdz: in my case i don't have defaults

6:30 AWizzArd: What if you want to add them later?

6:31 jdz: it would be no problem

6:33 well, it may be my exposure to CL being at work here; i'm sure i'll pick up clojure idioms while writing more code

6:33 AWizzArd: I also come from CL. And &key args would indeed be nice to have.

6:35 It's just the closest bet we have in Clojure to pass maps. Those you can easily bind in a let with destructuring and merge.

6:35 (defn foo [args] (let [{port :port, prot :protocol, url :url} (merge defults args)] ...))

6:36 &key args always need to have a default. Without one they don't make sense.

6:37 If you really have no defaults in your case then I don't see why the user has to pass in key/value pairs vs just values.

6:37 jdz: sometimes they do; like in my case: (node "node" :fontname "Helvetica" :fontsize 16 :fillcolor "white")

6:37 AWizzArd: What if the caller does not specify a :fillcolor?

6:38 jdz: then the :fillcolor is not being used.

6:38 i mean, is not being used in the output

6:38 AWizzArd: So the output will have no color?

6:38 jdz: i'm generating .dot files here

6:38 AWizzArd: What fontsize will be used?

6:38 jdz: the default graphviz font size

6:38 AWizzArd: You are implicitly using the defauts of .. yes

6:39 jdz: yes

6:39 and i don't want to create my own defaults and override graphviz's defaults with them

6:39 AWizzArd: Does anyone here remember why Clojure does not support key args?

6:40 jdz: they don't mesh very well with rest args :)

6:40 umm, the optional ones

6:40 AWizzArd: true

6:41 I mean, CL has a way to handle that, but maybe Rich thought it would make Clojure too complicated.

7:29 Neronus: I guess because you can emulate this very well using maps or arraymaps

7:49 AWizzArd: genau

8:03 * Neronus thinks AWizzArd sounds a little like clojurebot

8:37 hosiawak: where can I find the def of pl clojurebot knows about ?

8:40 AWizzArd: You can ask the bot where its sources reside.

8:54 Is there an X that allows me to say (X methodC methodB methodA (get-some-object)) instead of (.methodC (.methodB (.methodA (get-some-object))))? If yes, what is it?

8:54 I am aware that I can do (-> (get-some-object) (.methodA) (.methodB) (.methodC)).

8:55 gnuvince: AWizzArd: ..?

8:55 jdz: i curious why would you want that...

8:55 gnuvince: (doc ..)

8:55 clojurebot: form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get "os.name")) expands to: (. (. System (getProperties)) (get "os.name")) but is easier to write, read, and understand.; arglists ([x form] [x form & more])

8:58 AWizzArd: .. seems to be doing what -> is doing.

8:58 gnuvince: (.. "Hello" length (equals 5) toString)

8:58 ,(.. "Hello" length (equals 5) toString)

8:58 clojurebot: "true"

8:58 AWizzArd: But for this case it documents better what I want to do. Thanks gnuvince

8:58 gnuvince: np

8:58 ,(macroexpand-1 '(.. "Hello" length (equals 5) toString))

8:58 clojurebot: (.. (. "Hello" length) (equals 5) toString)

8:59 AWizzArd: I thought I would want to have it as (.. toString (equals 5) length "Hello"), but the other way around it's perhaeps even better.

8:59 gnuvince: ,(macroexpand '(.. "Hello" length (equals 5) toString))

8:59 clojurebot: (. (. (. "Hello" length) (equals 5)) toString)

9:09 AWizzArd: jdz: I want that to make it a bit easier for a human reader to parse what it means.

9:09 That is probably the biggest use of ..

9:10 jdz: well yes, i was just wondering about the order of invocation (since it seemed that you wanted the opposite of ->)

9:11 AWizzArd: jdz: Yes, that was indeed my first idea. But now I like the order of .. (or ->) more :)

9:26 Hi PJ.

9:31 ozzilee: Hey all. I wrote a java class in Clojure that I can compile and call with JSVC. JSVC calls the class's 'start' method...

9:32 I'd like to be able to run it from an ant task without compiling for development. Can I get clojure.lang.Script to do this?

9:33 Or do I need to compile, and maybe write another script to start it?

9:41 hosiawak: clojurebot: def pl

9:43 clojurebot: def aofjo

9:45 AWizzArd: clojurebot: where are your sources?

9:45 clojurebot: I don't understand.

9:45 AWizzArd: clojurebot: where is your source?

9:45 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

10:01 pjstadig: AWizzArd: hi

10:21 cconstantine: booo! java regex is broken, so I can't do what I want in clojure :(

10:21 no named captures == broken

10:23 gnuvince: why?

10:23 It's a missing feature for sure, but I wouldn't call it broken

10:23 cconstantine: I shamelessly thing of Perl's regex as canonical, so if Perl's regex can do it anyone should be able to

10:24 s/thing/think

10:24 * cconstantine wonders how hard it would be to implement regex in pure clojure...

10:25 Cark: basic regex is easy, full blown and optimized is hard

10:25 cconstantine: yeah, with lookahead/behind and all that

10:26 even perl doesn't optimize as much as it could

10:26 Cark: have a look to http://www.weitz.de/cl-ppcre/ for a common lisp implementation

10:26 which is faster on some implementations than perl

10:26 cconstantine: Cark: I've had much luck with that. I was looking to re-write my fancy-grep in clojure based on my CL implementation

10:27 gnuvince: I don't see the point of rewriting the regex engine when there's one that works pretty darn well

10:27 cconstantine: My CL implementation wasn't very lisp-y anyway

10:27 no named captures... my fancy-grep is based around that feature

10:27 gnuvince: Especially if you can't use your own with Java libs

10:27 Chouser: named capture in perl is pretty new, isn't it?

10:27 gnuvince: Chouser: 5.10

10:27 Python had it way before

10:28 Chouser: I have a whole project written in python because I wanted named capture and neither perl nor ruby had it.

10:28 Cark: anyways if you need named capture, you might want to look into soime parser library instead ?

10:28 cconstantine: I know the CL, and o-caml implementations had it over a year ago.

10:28 frodwith: Parser::RecDescent, for instance.

10:30 cconstantine: eh, I have an implementation of my fancy-grep in python also (used it to learn both CL and python). I was hoping to implement it in clojure as a learning experiance

10:31 AWizzArd: Is there a way to list all namespaces which Clojure currently knows? (because of using/requiring Clojure libs)

10:32 cconstantine: Chouser: I'd avoid writing whole project in perl... but that's because I've never been able to write a non-trivial perl program/script and maintain it.

10:32 AWizzArd: ,(doc all-ns)

10:32 clojurebot: "([]); Returns a sequence of all namespaces."

10:33 AWizzArd: oki

10:36 eyeris: If I have a string who's contents name a function, how can I call that function?

10:37 pjstadig: ,(apply (eval "str") 1 2 3)

10:37 clojurebot: DENIED

10:37 pjstadig: d'oh

10:39 (apply (ns-resolve *ns* (symbol "str")) 1 2 3)

10:39 ,(apply (ns-resolve *ns* (symbol "str")) 1 2 3)

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

10:39 pjstadig: ,(apply (ns-resolve *ns* (symbol "str")) [1 2 3])

10:39 clojurebot: "123"

10:39 pjstadig: ,((ns-resolve *ns* (symbol "str")) 1 2 3)

10:39 clojurebot: "123"

10:40 eyeris: ((symbol "str") [1 2 3])

10:40 ,((symbol "str") [1 2 3])

10:40 clojurebot: nil

10:40 eyeris: ,((symbol "str") 1)

10:40 clojurebot: nil

10:40 pjstadig: you would have to resolve the symbol to a var

10:40 eyeris: Oh, right

10:41 pjstadig: ,((resolve (symbol "str")) 1 2 3)

10:41 clojurebot: "123"

10:41 pjstadig: if you want to specify a specific ns i guess you'd use the ns-resolve

10:41 ~def resolve

10:42 resolve is the same thing as (ns-resolve *ns* sym)

10:42 ,(resolve "str")

10:42 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol

10:45 eyeris: Thanks. That worked.

10:45 pjstadig: np

11:23 eyeris: How can I get the length of a Java array?

11:23 slashus2: .length ?

11:23 pjstadig: (doc alength)

11:23 clojurebot: Returns the length of the Java array. Works on arrays of all types.; arglists ([array])

11:24 eyeris: ah!! alength!

11:24 pjstadig: most of the array functions start with an 'a' as a prefix

11:24 so they are conveniently grouped on http://clojure.org/api

11:25 Chouser: kinda interesting that I've never needed that.

11:25 eyeris: This is so annoying. I've spent 3 hours tracking down phantom bugs in my clojure code, only to find out that this java Excel library is broken

11:26 pjstadig: (.length (to-array [1 2 3])

11:26 ,(.length (to-array [1 2 3])

11:26 clojurebot: EOF while reading

11:26 eyeris: ,(.length (to-array [1 2 3]))

11:26 clojurebot: java.lang.IllegalArgumentException: No matching field found: length for class [Ljava.lang.Object;

11:27 eyeris: ,(count (to-array [1 2 3]))

11:27 clojurebot: 3

11:27 eyeris: ,(acount (to-array [1 2 3]))

11:27 clojurebot: java.lang.Exception: Unable to resolve symbol: acount in this context

11:27 eyeris: ,(alength (to-array [1 2 3]))

11:27 clojurebot: 3

11:27 slashus2: (.length (make-array Integer/Type 10))

11:27 ,(.length (make-array Integer/TYPE 10))

11:27 clojurebot: java.lang.IllegalArgumentException: No matching field found: length for class [I

11:29 eyeris: slashus2 .length is a property, not a method

11:29 slashus2: yeah

11:29 I know

11:29 pjstadig: (amap (to-array [1 2 3]) i [] inc)

11:29 ,(amap (to-array [1 2 3]) i [] inc)

11:29 clojurebot: java.lang.IllegalArgumentException: Argument is not an array

11:29 pjstadig: ,(amap (to-array [1 2 3]) i (to-array []) inc)

11:29 clojurebot: java.lang.Exception: Unsupported binding form: (to-array [])

11:30 pjstadig: ,(amap (to-array [1 2 3]) i ret (inc i ret))

11:30 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$fn

11:34 hosiawak: ,(Integer/valueOf "2")

11:34 clojurebot: 2

11:34 hosiawak: ,(map #(Integer/valueOf) '(1 2 3))

11:34 clojurebot: java.lang.NoSuchFieldException: valueOf

11:35 hosiawak: how to pass Integer/valueOf to map ?

11:35 pjstadig: ,(map Integer/valueOf '(1 2 3))

11:35 clojurebot: java.lang.Exception: No such namespace: Integer

11:35 Chousuke: #(Integer/valueOf %)

11:35 don't forget the parameter :P

11:36 ,(map #(Integer/valueOf %) '(1 2 3)) ; like this

11:36 clojurebot: (1 2 3)

11:36 Chousuke: not very interesting though

11:36 hosiawak: ,(map #(Integer/valueOf %) '("1" "2" "3"))

11:36 clojurebot: (1 2 3)

11:37 hosiawak: is there other way to get the integer value of a string ?

11:37 Chousuke: using vectors instead of quoted lists for literals is slightly more clojurey :)

11:37 Integer/parseInt

11:37 hosiawak: ok, thanks

12:19 kadaver: how would you implement types in clojure itself? i mean not writing a parser for a new language but jsut add it to clojure itself?

12:20 pjstadig: using maps, structs, and multimethods

12:24 kadaver: ok i did it with struct

12:25 so basically you do it like with cons and cdr

12:25 you jsut implement it as a function

12:26 http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3592#a3592

12:26 haskell Maybe-type ^, is that how you would do it?

12:27 and is there a function or macro for this: if x x y; ? instead do-if x y; so it will return the tested condition without me having to write it again as the then branch?

12:28 scottj_: Is there a way to use xml-seq with bad html? the parse function is too strict for most webpages.

12:29 stuarthalloway: kadaver: if-let

12:30 kadaver: (defn neat-if [a b]

12:30 (if a a b))

12:30 is what i want

12:32 Chouser: kadaver: or

12:37 AWizzArd: rhickey: Are you aware of the suggestions in this video? http://www.infoq.com/presentations/click-fast-bytecodes-funny-languages

12:39 hiredman: AWizzArd: I am interested to hear what you think the suggestions from the video are

12:41 AWizzArd: Dr. Click explains that he found some ways how Clojures bytecode could be improved to be more efficient. I don't understand in detail what he is talking about. But maybe rhickey does understand it, and perhaps there is new info waiting for him. So, I am just interested if he is aware.

12:42 rhickey: AWizzArd: I was there and spent a lot of time with Cliff. At the time, Clojure didn't inline all the ops in his test, it now does, he's seen that, and it's the same as Scala on his benchmark

12:42 AWizzArd: Oki, thanks.

12:48 stuarthalloway: rhickey: got two compiler questions for you: (1) any reason bytecode would blow up coverage tools? and (2) how would I compile to avoid this warning: "EMMA: package [clojure/contrib] contains classes [test_is__init] without full debug info"?

13:27 eyeris: Could someone tell me what I am doing wrong that is making Clojure fail to find this Java method? http://pastebin.ca/1387241

13:28 stuarthalloway: eyeris: getRefersToFormula sounds like the name of a getter method, not a field

13:30 eyeris: It is a method.

13:31 stuarthalloway: I don't see Clojure code in the paste, just a stack trace

13:31 eyeris: Here it is: http://pastebin.ca/1387245

13:33 stuarthalloway: can you try calling bean on the object to see what properties it does expose?

13:36 eyeris: The output of bean is appended here: http://pastebin.ca/1387247

13:37 Though isn't the problem that clojure thinks I am accessing a field instead of a method?

13:37 stuarthalloway: no, the message is a little misleading

13:38 ,(.toUpperCase "foo")

13:38 clojurebot: "FOO"

13:38 stuarthalloway: ,(.toNonexistentPlace "foo")

13:38 clojurebot: java.lang.IllegalArgumentException: No matching field found: toNonexistentPlace for class java.lang.String

13:38 eyeris: Oh. Ok.

13:39 stuarthalloway: the bean info may be the clue -- it includes deprecated names and does not include the name you want

13:39 old version of the jar?

13:40 eyeris: Does getRefersToFormula being defined in an interface, and implemented in the class complicate matters with bean?

13:40 No, it's the newest jar.

13:40 What do you mean by "deprecated" names?

13:41 stuarthalloway: according to http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFName.html, the property "reference" is deprecated

13:41 eyeris: perhaps that documentation doesn't refer to the latest release, but some in-development realease...

13:43 Yep

13:43 That's it

13:43 I will track that down after lunch :)

13:43 thanks for helping me track that down.

13:43 stuarthalloway: good luck

13:47 cemerick: the fact that (not= (delay 5) 5) has become a serious inconvenience, especially in the context of map and vector equality

13:48 does anyone see any potential issues with the notion of building a c.l.Delay subclass that provides equals and hashcode impls that always force the delay's value and delegate such calls to that value?

13:52 Chouser: you want every delay in a key or value of a map forced if you test = on that map?

13:52 cemerick: in certain circumstances, yeah

13:52 or, actually, in most circumstances, actually

13:53 ...maybe that's a sign I'm doing things wrong in a fundamental way....?

13:57 Chouser: cemerick: I couldn't say -- I've not used delay at all.

13:57 people have previously asked for other operations to auto-force, such as math operators.

13:57 are you sure you're only going to want hash and = ?

13:58 cemerick: well, auto-forcing isn't really appropriate across the board, I don't think (Rich semi-convinced me of that some time ago)

13:58 I think that's all that's necessary in order to get maps and vectors to work properly.

13:59 twism: clojure question... when (let [kws (keys a-map)] ...) would (last kws) be equal to the last kw in a (doseq [kw kws] ...)?

14:00 if that makes any sense

14:00 of course i cold just test it out

14:02 but it equality could be true by chance

14:03 am i making sense or am i being stupid

14:04 pjstadig: twism: are you asking about a stable iteration ordering?

14:04 lisppaste8: cemerick pasted ""transparent" delays" at http://paste.lisp.org/display/78320

14:05 cemerick: that feels wrong, somehow....

14:07 twism: pjstadig: basically are the keywords of maps when returned by the "keys" fn ordered the same?

14:07 Chouser: twism: every time get a seq for the same map's keys, the seq will have those keys in the same order.

14:08 twism: Chouser: thanks i thought so

14:08 Chouser: as soon as you add anything or removing anything from the map, I wouldn't rely on the order being at all the same.

14:08 twism: ok

14:08 gotcha

14:08 thanks again

14:08 Chouser: cemerick: wrong because it was so easy to implement?

14:09 cemerick: heh, that's the good part!

14:09 No, I just know I've planted some pretty difficult-to-track bugs for myself when I start screwing with identity like that.

14:09 in the past, that is

14:17 dakrone_hb: can someone give me a hand with some refactoring? I have this code: http://gist.github.com/92640 and I think I need to switch it around to better operate on each line rather than loading the entire thing into memory...

14:22 hiredman: if use exec directly you get an outputstream from the process

14:22 you can wrap the os with a bufferedreader, then call line-seq on it

14:23 Chouser: don't forget to clean up the streams and process when you're done

14:23 Neronus: but don't close it before line-seq has seen it all, or you're dead... or something less worse

14:23 less worse

14:24 that doesn't sound correct to me

14:24 less bad

14:24 hiredman: which is why you should use a scope

14:24 Chouser: dakrone_hb: shell-out doesn't let you get at the streams or the process directly precisely because that's a whole lot to worry about for those many cases where getting a single string is sufficient.

14:24 Neronus: or write your own lineseq

14:24 dakrone_hb: hiredman, were you talking to me when you said exec?

14:25 so, I need to write something that will let me operate on a single line with a function, without loading *all* the lines into memory?

14:25 Neronus: which uses scoping, so... forget me :)

14:25 dakrone_hb: or does something already exist in this capacity?

14:26 hiredman: Runtime getRuntime exec?

14:28 dakrone_hb: hiredman, I was using this macro a while back: http://pacific.mpi-cbg.de/wiki/index.php/Clojure_Scripting#Executing_a_command_in_a_shell_and_capturing_its_output then Chouser suggested I use shell-out instead

14:29 hiredman: processing the output of a shell comand lazily is pretty silly

14:29 the ouput is not generated on demand anyway

14:30 it is just dumped into a buffer so it already exists

14:30 Chouser: well, a process will block waiting to write if the output buffer is full, won't it?

14:31 hiredman: I have no idea

14:31 Chouser: I think it does.

14:31 hiredman: I guess that depends on how java manages it

14:31 dakrone_hb: I believe that's what happens

14:32 pjstadig: i think the point still stands, you're not asking a shell command for its output, it is giving it to you

14:32 hiredman: dakrone_hb: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html

14:33 pjstadig: so you process it based on the whim of the shell command, which means you don't really decide to be lazy

14:34 dakrone_hb: so instead of a line-seq, I'd use something that wasn't lazy, correct?

14:34 Chouser: you'll be dealing with lines not chunks of binary data or something?

14:35 hiredman: dakrone_hb: you are already doing that

14:36 dakrone_hb: Chouser, yes, dealing with another program that doesn't have an api, so I need to call it's executables, and then process each line of output to do different things with them

14:36 pjstadig: dakrone_hb: i don't think the OOME is coming from your code, but from the shell-out code that is trying to load all of the output at once

14:36 Chouser: dakrone_hb: in that case, a line-seq is probably appropriate

14:36 pjstadig: so if you use exec directly and read from the stream incrementally, then you wouldn't error out

14:37 Chouser: but shell-out isn't going to help you at all as it stands

14:37 dakrone_hb: so doing a (read <stream>) only return 1 line at a time?

14:37 Chouser: dakrone_hb: you're name's not Kyle is it?

14:37 hiredman: Chouser: it might be nice to have something like ruby's IO.popen

14:38 dakrone_hb: Chouser, no, why do you ask?

14:38 hiredman: well

14:38 dakrone_hb: yea, a popen is exactly what I need

14:38 Chouser: someone named kyle is asking for similar features for shell-out

14:38 hiredman: with readlines.each

14:38 dakrone_hb: oh, well that wasn't me

14:38 hiredman: basically a combination of with-open an shell-out

14:38 with-open-proc

14:39 Chouser: the reason it doesn't have it already is because it forces the user to mange the closing of streams and the cleaning up of the process

14:39 and there are a lot of simple use cases where getting a String back is fine, so it's nice to not worry about all that.

14:39 kadaver: what do you people prefer with Clojure over Haskell?

14:39 hiredman: (with-open-proc "echo foo" [stdin stdout stderr] (do stuff))

14:40 Chouser: I think these more advanced usages warrent a bit more design and thought.

14:41 hiredman: kadaver: I like lisp and clojure has easy access to all the millions of java libraries

14:42 rsynnott: because haskell is, well, haskell ;)

14:43 pjstadig: kadaver: i know Clojure, and I do not know Haskell

14:44 hiredman: there was a great quote

14:44 dakrone_hb: Chouser, I look forward to additions to the shell-out library ;) in the meantime I will try to hack something up with my limited knowledge of it

14:45 hiredman: #clojure.log:2009:Feb:10:16:37:16 ayrnieu : you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work.

14:46 Neronus: lol

14:46 dakrone_hb: hiredman, Chouser, pjstadig, thanks for the help :)

14:46 pjstadig: np

14:47 kadaver: hiredman: what feature was that?

14:47 hiredman: I forget

14:48 kadaver: I used to use Clojure (got interested in functional programming via Python) and I thought at first Haskell was too facist functional but after some time in Clojure and really grokking functional programming then I loved Haskell the next time I tried it.

14:48 hiredman: clojurebot: logs?

14:48 clojurebot: logs is http://clojure-log.n01se.net/

14:50 hiredman: http://clojure-log.n01se.net/date/2009-02-10.html#19:37

14:50 for context

14:50 the context was infix operators, I believe

14:51 ,(pl inc $ inc $ inc $ 0)

14:51 clojurebot: 3

14:51 pjstadig: ?

14:52 kadaver: if you don't have macros int he lisp-sense then infix-math is nice...

14:52 hiredman: ,(macroexpand `(pl inc $ inc $ inc $ 0))

14:52 clojurebot: (do (clojure.core/inc (clojure.core/inc (clojure.core/inc 0))))

14:52 pjstadig: (doc pl)

14:52 clojurebot: Huh?

14:52 hiredman: ,(doc pl)

14:52 clojurebot: "([& forms]); replaces a $ b with (a b) walking right to left replaces a � b with (comp a b) left to right ?a with (uncurry a) left to right ?a with (flip a) left to right"

14:52 pjstadig: oh

14:53 hiredman: pl is not in clojure.core so (doc pl) doesn't pick it up

14:53 ,(doc uncurry)

14:53 clojurebot: "([x]); applied to a function it returns a function that will continue partially applying until it is called with no arguments"

14:53 pjstadig: hiredman: is there a way to get clojurebot to show the definition of a non-core function?

14:53 hiredman: ,(((uncurry +) 1) 2)

14:53 clojurebot: #<sandbox$uncurry__1858$uc__1860 sandbox$uncurry__1858$uc__1860@8443a3>

14:53 pjstadig: ~def parallel.par

14:54 hiredman: ha ha

14:54 pjstadig: ~def clojure.parallel.par

14:54 * hiredman falls out of his chair

14:54 pjstadig: ~def clojure.parallel/par

14:55 hiredman: ,(require '[clojure.parallel :as p])

14:55 clojurebot: java.io.FileNotFoundException: Could not locate clojure/parallel__init.class or clojure/parallel.clj on classpath:

14:56 pjstadig: it needs to to be required to post a url?

14:56 hiredman: clojure needs to be able to resolve the symbol

14:56 I don't have the funky jars needed for parallel.clj

14:56 pjstadig: k

14:57 hiredman: ,((((uncurry +) 1) 2))

14:57 clojurebot: 3

14:57 pjstadig: ~def clojure.set/union

14:57 gotcha

15:00 hiredman: fail whale

15:00 I think this is my first (shows how 2.0 I am)

15:00 pjstadig: my first was just a couple of days ago

15:00 hiredman: http://twitter.com/boscoh/statuses/1484205898 <-- ouch

15:01 pjstadig: but then i only joined twitter like last month

15:02 hiredman: you know, clojurebot has a twitter...

15:02 cemerick: whoa, dude's got some rage

15:04 pjstadig: i like having my brain turned inside out by new ideas....but maybe i'm just weird

15:07 hiredman: I just don't get it

15:07 functions are like the simplest thing ever

15:08 cemerick: not having mature tools can often trip people up pretty easily

15:09 pjstadig: it's maybe simple once you get it, but it takes people a while to give up their for loops

15:09 hiredman: clojurebot: functions?

15:09 clojurebot: anonymous functions are functions with no names

15:10 hiredman: clojurebot: functions is <reply>functions are maps

15:10 clojurebot: You don't have to tell me twice.

15:10 hiredman: clojurebot: maps?

15:10 clojurebot: Titim gan �ir� ort.

15:10 hiredman: clojurebot: maps is <reply>maps are functions

15:10 clojurebot: You don't have to tell me twice.

15:20 dhaas: are there any particular windowing toolkits that mesh well with clojures way of doing things?

15:21 hiredman: there are some miglayout (swing layout manager) wrappers in contrib

15:21 some seem to like QT's java bindings, but those have been discontinued

15:23 I would just swing, just watch out for the event dispatch thread

15:24 jcip has a short section on concurrent guis, which made me re-think my opinion of swing

15:26 durka42: for the better or worse?

15:26 hiredman: it made me appreciate the need for all the EDT redtape

15:27 http://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html

15:28 I still hate writing guis, and avoid it

15:28 clojurebot: <3

15:28 clojurebot: Huh?

15:28 cemerick: hiredman: jcip?

15:29 hiredman: clojurebot: jcip?

15:29 clojurebot: I don't understand.

15:29 pjstadig: java concurrency in practice

15:29 cemerick: ah

15:29 hiredman: clojurebot: jcip is Java Concurrency in Practice

15:29 clojurebot: Ack. Ack.

15:29 cemerick: still haven't read that :-(

15:29 Chousuke: clojurebot: <3 is <3

15:29 clojurebot: Ok.

15:29 Chousuke: clojurebot: <3 is also </3

15:29 clojurebot: Ik begrijp

15:29 pjstadig: clojurebot: <3

15:29 hiredman: ~<3 is also ?

15:29 clojurebot: Roger.

15:29 <3 is </3

15:30 Chousuke: hm

15:30 pjstadig: clojurebot: <3

15:30 clojurebot: <3 is <3

15:30 Chousuke: needs <reply>

15:30 hiredman: clojurebot: literal [?] <3

15:30 clojurebot: 3

15:31 hiredman: ~<3 is also <reply>?

15:31 clojurebot: c'est bon!

15:57 bradford: suppose i have a seq generated by file-seq

15:58 how would i find all jars?

15:59 cp2: (filter #(.endsWith "jar" (.getName %)) blah)

15:59 i guess

16:00 oh oops

16:00 Chouser: (filter #(.endsWith (str %) ".jar") blah) ?

16:00 cp2: #(.endsWith (.getName %) ".jar") rather

16:06 bradford: (def files-and-dirs (file-seq (new File "~/opt/capjure")))


16:06 (filter #(.endsWith (str %) ".jar") files-and-dirs)

16:06 i'm getting an empty seq back

16:06 thought i know there are jars under there

16:07 hiredman: decompose and examine intermediate results

16:14 dhaas: i hate writing GUIs as well, but they are still quite useful :(

16:16 bradford: ah, i was being dumb. :-) the result of filter is also lazy so i need to force it to see results

16:49 dhaas: im trying to do an import once im in a namespace

16:49 (in-ns 'foo) ........ (clojure/refer 'clojure)

16:49 but it doesnt think clojure is a valid ns...?

16:51 hiredman: clojure.core

16:54 dhaas: its having a problem resolving clojure/refer

16:54 java.lang.Exception: No such var: clojure/refer (NO_SOURCE_FILE:1)

16:55 pjstadig: ,clojure.core/refer

16:55 clojurebot: #<core$refer__4341 clojure.core$refer__4341@18600d7>

16:56 pjstadig: ,clojure/refer

16:56 clojurebot: java.lang.Exception: No such namespace: clojure

16:56 dhaas: ah:)

16:56 hiredman: dhaas: there is no clojure namespace

16:56 dhaas: understood

16:56 (now)

16:57 hiredman: now as of five (six?) months ago

16:59 AWizzArd: ~ def time

17:02 kefka: ,(let [rg (set (range 50000))] (count (set rg)))

17:02 clojurebot: 50000

17:02 kefka: ,(let [rg (set (range 50000))] (time (count (set rg))))

17:02 clojurebot: 50000

17:02 "Elapsed time: 210.43 msecs"

17:03 kefka: It costs significant time to call set on a large object that's already a set.

17:04 pjstadig: ,(let [rg (set (range 50000))] (count rg))

17:04 clojurebot: 50000

17:04 pjstadig: ,(let [rg (set (range 50000))] (time (count rg)))

17:04 clojurebot: 50000

17:04 "Elapsed time: 0.04 msecs"

17:04 pjstadig: ~def set

17:05 hiredman: set calls seq first

17:05 oh

17:05 oops

17:06 looking at the wrong def

17:08 kefka: ,(doc set)

17:08 clojurebot: "([coll]); Returns a set of the distinct elements of coll."

17:08 hiredman: well, someone has to ask

17:08 pjstadig: ~def hash-set

17:08 hiredman: why call set on a set?

17:08 kefka: Calling set on a collection that may be a set.

17:14 eyeris: Uhm, how do I exit the repl?

17:14 pjstadig: (System/exit 0)

17:14 cp2: you may not leave :)

17:14 hiredman: I usually use control-d

17:15 eyeris: Yeah, ^d doesn't work on Windows. Neither does ^z^z for some reason

17:16 hiredman: yet another strike against windows...

17:16 pjstadig: to exit on window, insert unbuntu cd, go to start=>restart and install

17:17 cp2: actually its start -> turn off computer -> restart

17:17 pjstadig: oh you're right....that makes much more sense...

17:18 hiredman: start -> cmd.exe -> figure out the syntax for the shutdown command -> shutdown

17:18 cp2: that is true hiredman

17:18 pjstadig: you mean start -> run "cmd.exe"?

17:18 cp2: yes

17:18 or winkey + r

17:18 !

17:18 hiredman: ah, depends

17:19 you might have cmd.exe in your start menu, or have vista with the search thinger

17:19 so you just type "cmd.exe" and it finds it, and you hit enter

17:25 Chouser: ^Z<enter>

17:31 eyeris: Is there a clojure api wrapper for Double/parseDouble?

17:32 hiredman: why would you need one?

17:32 ,(Double/parseDouble "1.0")

17:32 clojurebot: 1.0

17:32 hiredman: ~javadoc Double

17:33 looks even simpler then Integer/parseInt

17:35 duncanm: it'd be nice if the api page on clojure.org contains examples, particularly for the macros

17:35 eyeris: But (dbl "1.0") would be cooler :)

17:36 duncanm or at least a link at the top of the page to the examples page

17:36 Chouser: ~examples

17:36 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

17:37 duncanm: i wanted to know how IF-LET looks

17:37 (if-let [x 0] test? then-clause else-clause) ?

17:39 slashus2: duncanm: You mean having non-trivial examples in the doc strings?

17:40 Chousuke: duncanm: (if-let [x whatever] whatever-is-true whatever-is-false)

17:40 Chouser: people say that a lot. what is "non-trivial"

17:40 duncanm: Chouser: where's the test, then?

17:40 Chousuke: it's basically (let [x whatever] (if x ...))

17:41 duncanm: oh!

17:41 slashus2: Chouser: I think a concise example that demonstrates the core usage of the api item is good enough.

17:42 duncanm: it says bindings => binding-form test in the docs

17:42 it's kinda hassle that metadata associated with a list 'l' is not preserved in (rest l)

17:42 it makes sense, but it's a hassle

17:43 bradford: if want to go over a seq and call a func with each element of the seq, what is the right way..its like an each in ruby

17:43 pjstadig: (doc doseq)

17:43 clojurebot: Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Does not retain the head of the sequence. Returns nil.; arglists ([seq-exprs & body])

17:43 duncanm: bradford: do you want to get a seq back?

17:43 MAP or DOSEQ

17:43 bradford: nope, not getting a seq back..its not a map

17:44 duncanm: then doseq

17:44 pjstadig: use doseq for side effects and map if you are transforming the seq

17:44 duncanm: (doseq [i '(1 2 3)] (println i))

17:44 bradford: yea, its causing side effects

17:44 cool, thx

17:52 ok, so if i throw a println in to see that my seq contains what i think in contains, how do is see the resutsl if i do a slime-eval-region?

18:01 i'm such a fool - it all sows up in the repl of course :-)

18:06 dakrone_hb: are there any already-built libraries for Clojure+Lucene?

18:10 Chouser: dakrone_hb: stuart sierra's apparently using it, though I don't know exactly what it is: http://groups.google.com/group/clojure/browse_thread/thread/62600c60f5279b8e

18:11 bradford: what is the best way to concat a string ... file:// /foo/bar/baz -> file:///foo/bar/baz

18:11 cp2: (str "abc" "def")

18:12 dakrone_hb: Chouser, cool, I'll check it out, thanks

18:17 bradford: suppose i have a filter liek this: (filter #(.endsWith (.getName %) ".jar") files-and-dirs)

18:17 if i now want to extend the predicate to filter .jar and /src dirs, how to i add that?

18:21 hiredman: it depends on what files-and-dirs is a seq of

18:22 bradford: (def src (filter #(.endsWith (.getName %) "src") files-and-dirs)) ... is how I would filter if i defined it seperately

18:22 hiredman: it might be easier to half two filters one for jar files and one for directories named "src"

18:22 bradford: yea, that is what i have now

18:22 hiredman: well

18:22 that is easy

18:22 bradford: perhaps i will jsut stick to that

18:22 hiredman: just use or

18:22 #(or (.endsWith (.getName %) "src") (.endsWith (.getName %) ".jar"))

18:23 (def jar-filter (partial filter #(.endsWith (.getName %) ".jar")))

18:23 (def src-dir-filter (partial filter #(.endsWith (.getName %) "src")))

18:24 (-> files-and-dirs jar-filter src-dir-filter)

18:24 hmm

18:24 that wouldn't work

18:25 bradford: i was wondering, in your first example using or...might there be another anonymous function to extract to avoid the cuplication?

18:25 the endswith getname stuff

18:25 hiredman: *shrug*

18:25 bradford: hehe

18:25 i'll jsut leave it as two seperate seqs :-)

18:27 Raynes: hiredman: Would you still love me if I learned Scala? :)

18:30 hiredman: be sure, I would not love you the less for doing such a thing

18:34 SethTisue: there are 12 of us on both #clojure and #scala

19:32 bradford: add-classpath at the repl is not working for me as it did earlier

19:32 (add-classpath "file:///home/bradford/opt/capjure/lib/java/hadoop-0.18.1-core.jar")

19:32 then ... (System/getProperty "java.class.path")

19:33 and that jar is not on the cp

19:33 any ideas?

19:33 hiredman: (System/getProperty "java.class.path") is never updated

19:34 clojurebot: add-classpath

19:34 clojurebot: add-classpath is bad, avoid it. I mean it!

19:34 bradford: ok, what shall i use?

19:34 hiredman: java -cp

19:35 clojurebot: jar directory

19:35 clojurebot: with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

19:36 bradford: i ahve been using the swank-clojure-extra-classpaths

19:37 but i building up a project with many dependencies...and trying to find a nice way to slurp up al the deps in various lib folders (jars) and esatablish deps on .cljs via the src dirs

19:39 hiredman: why bother connecting jars to individual source files?

19:39 bradford: so, sicne add-classpath is not working. what is a good hook for me to use so that I can create a clojure script that generates the list of paths that I want to feed to swank-clojure-extra-classpaths?

19:40 hiredman: just use the find command from above

19:40 unless you are on windows, in which case find does something completely different

19:40 bradford: well, if i skip the add-classpath garbage, i don't need to collect jars sicne i can just add lib dris with lib/*

19:40 hiredman: and the classpath seperator is different

19:40 correct

19:44 bradford: the issue is finding dirs containing jars to add lib/* to classpath and then finding dirs such as /src containing other clojure projects to add those paths to classpath to be able to use vars from those projects

19:45 I already have all the manual hackery in the my .emacs and bash scripts and stuff. but this is not really a great setup for maintaining a project aht dependens on many other clojure projects.

19:45 hiredman: I would jar up the other clojure projects

19:45 bradford: ah

19:45 hiredman: so you just have a set of jars

19:46 bradford: so assume that everything msut be jar'd

19:46 hiredman: well it lets you manage java and clojure in a uniform way

19:46 bradford: so then i just bring all projects under one dir my/project/deps ... jar them all up, and then something simpelr like find will be OK

19:46 good point

19:47 durka42: i see

19:48 bradford: and i should not need to use the find comamnd at all in that case?

19:48 will the lib/* work recrusively?

19:48 hiredman: I dunno

19:48 bradford: cool, i'll find out.

19:48 thx

19:54 hiredman: the "*" is not handled by shell globing but by java

21:13 redalastor: How can I do a GUI with a data entry zone and a rendering zone (data should asynchronously be rendered as typed).

21:14 I thought of using an agent but I want the current rendering to be thrown out if it's not done and more data is typed. An agent would just queue all the intermediate stages.

21:15 arohner: redalastor: have you looked at atoms?

21:16 redalastor: I read about them but I didn't grok how they work.

21:18 arohner: they are a variable than can be set without race conditions

21:18 the new value is a function of the old value

21:18 but thinking about it, that isn't quite what you want

21:19 you sort of want agents, but you want new jobs to cancel in-progress jobs

21:19 redalastor: Exactly

21:20 Chouser: your in-progress jobs are going to have to poll to see if they should give up

21:20 redalastor: So somewhere in my rendering loop, I have to check if I should continue or not?

21:21 Chouser: Java doesn't like you cancelling threads from outside the thread, so I think your only option is from within the thread.

21:21 redalastor: Would there be a way to achieve what I want by storing a future in an agent?

21:22 Chouser: futures are for when you want something to block if it's not done computing yet

21:22 I think some kind of reference type (perhaps an atom) to store the most-recent data value as entered by the user.

21:22 redalastor: Yes. But they return instantly so if I call an agent twice it will hapilly replace the first future with the second, right?

21:23 Chouser: you can put a watcher on that so that when the value changes it sends off an agent

21:23 arohner: you could use an atom or a ref to cancel in-progress rendering jobs

21:23 Chouser: that agent runs, occasionally checking its starting value with the current value of the atom

21:24 if they don't match, return out of the agent, allowing the next watcher-sent agent in the queue to start over

21:25 redalastor: Makes sense. I was hoping there was a way to kill off a thread from outside itself.

21:25 Chouser: yeah, java doesn't like that

21:26 redalastor: According to Google, Java used to like it but it's deemed unsafe these days.

21:26 http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html

21:27 dreish: Sounds like STM and immutable data structures would fix these problems.

21:29 redalastor: That's what I was thinking.

21:29 Chouser: fix the problems with halting a thread?

21:29 redalastor: With having damaged objects when you do.

21:30 Chouser: ah

21:30 dreish: I wouldn't trust it without a test running for tens or hundreds of hours, though.

21:30 Chouser: well, you could still have issues with exiting without going the finally blocks and such

21:33 * dreish still has no plans to call Thread.stop(), ever.

21:34 Chouser: I do it every time I press Ctrl-C

21:34 dreish: gasp!

21:34 Wouldn't it be simpler to never make mistakes?

21:34 Chouser: hehe

21:35 dreish: I hold a code review meeting before hitting return, every time.

21:51 hiredman: must an issue clearing day

23:11 ~ticker IDSOX

23:11 clojurebot: IDSOX; +0.54

23:11 hiredman: :D

23:21 markgunnels: Not sure of the protocol but I have two Clojure questions I was hoping to get answered. I imagine they are rather simple but just non-obvious to a noob like myself.

23:23 If variables in Clojure are by default non mutable, why does this work:

23:23 (def favorite-books (list "Anathem" "Matter" "I know this much is true"))

23:24 (def new-favorite-books (cons "The Road" favorite-books))

23:24 Oops.

23:24 I mean (def favorite-books (cons "The Road" favorite-books))

23:24 It seems that I shouldn't be able to reuse the favorite-books variable.

23:24 arohner: markgunnels: vars can be re-defed to make development easier

23:25 you shouldn't do that in production

23:25 hiredman: it's usefull for swapping code in a running system

23:25 markgunnels: Ok. I know Erlang calls me on it.

23:25 So it surprised me when I got away with it.

23:26 Thanks.

23:26 arohner: np

23:27 hiredman: just do anything crazy like re-def'ing in a loop

23:27 markgunnels: Ok.

23:29 Chouser: don't

23:31 hiredman: good catch

23:31 cp2: heh

23:31 markgunnels: :-) I translated.

23:31 hiredman: ~hiredman

23:31 clojurebot: hiredmans euler.clj is so embarassing

23:39 arohner: is there a way to find all existing refs?

23:40 when unit testing, I was thinking of a macro that would grab all refs, grab their value, execute body and then ref-set all of them back to their original value

23:40 hiredman: erm

23:41 for why?

23:41 Chouser: arohner: I highly doubt it

23:41 arohner: so I don't have to worry about tests causing side-effects and interfering with each other

23:42 Chouser: arohner: you could find all vars in a namespace

23:42 arohner: from there, I could find all vars in all namespaces that are refs

23:42 hmm...

23:43 Chouser: but not any local refs

23:43 or any refs only accessible via closures

23:43 arohner: yeah

23:48 slashus2: ,(^ 5 2)

23:48 clojurebot: java.lang.NullPointerException

23:48 hiredman: ,(pow 5 2)

23:48 clojurebot: java.lang.Exception: Unable to resolve symbol: pow in this context

23:48 hiredman: ,(.pow 5 2)

23:48 clojurebot: java.lang.IllegalArgumentException: No matching method found: pow for class java.lang.Integer

23:49 slashus2: It is because ^ is a reader macro

23:49 reader syntax

23:49 ,(Math/pow 5 2)

23:49 clojurebot: 25.0

Logging service provided by n01se.net