#clojure log - Jun 30 2009

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

0:24 seths: any chance that Chouser is online? Does the trailing underscore mean afk?

0:25 slashus2: seths: I think it means that he was disconnected, and reconnected to have his original name in the room.

0:26 Anniepoo: I've got an idiot beginners question, no point in spamming the channel, anybody willing to help me get a file to compile as a java class?

0:28 seths: slashus2: thx from an IRC newbie

0:29 Anniepoo: do I point classpath at the root of the package tree like Java?

0:37 newbie_: Hi all, what is ethic for asking questions do i just type in to the main channel chat?

0:43 Anniepoo: newbie, I think the channel is a lot deader than it appears from the number of people subscribed

0:44 I'm striking out about 50% of the time with newbie questions, and I don't think I'm being obnoxious or overusing the resource

0:45 I'd try to answer, but I'm a complete noob

0:47 newbie_: thanks, i have a function that reads tokens from a input stream and create map of it one input for key one input for value but it justs makes the repl lock up no error nothing it goes in to a infinite loop

0:47 (defn process-map [ stream ]

0:47 (loop [ result {} ]

0:47 (let [c (char (.read stream) ) ]

0:47 (if (= c \e )

0:47 result

0:47 Anniepoo: hang on

0:47 newbie_: (recur (assoc result (get-next stream (int c) ) (get-next stream (int c) ) ) )

0:47 ))))

0:48 Anniepoo: lisppaste8: url?

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

0:48 Anniepoo: do that instead

0:48 newbie_: kk

0:49 lisppaste8: newbie_ pasted "loop" at http://paste.lisp.org/display/82739

0:50 replaca: newbie_: how are you running? straight repl from shell?

0:51 newbie_: repl from within emacs, using C-x C-e

0:52 replaca: mmm, and is stream set to *in* or some other file

0:52 newbie_: btw, stream is an input-stream

0:52 replaca: ?

0:52 oh. ok

0:53 what do you think \e is?

0:53 it isn't eof, you know...

0:53 newbie_: it marks the end of the token stream it is not eof

0:53 replaca: it's the letter 'e'

0:53 ok

0:54 newbie_: i want processing to stop when it sees e char

0:54 replaca: the code looks ok to me (hard to tell completely without sseeing the input stream and other funcs)

0:55 I'd put some prints in to see how it's going in the loop

0:56 I use the prlabel func in c.c.pprint.utilities for this: (prlabel place val1 val2 ...) prints place val1=(it's val) val2=...

0:56 it's a macro, so it's pretty easy

0:57 but a simple print would work just fine too

0:57 newbie_: thx i'll look in to it.

0:58 replaca: newbie_: sorry i couldn't be more help

0:59 newbie_: np

1:00 is there a possibility that both get-next functions are called at the same time causing the sequence in the input stream to mess up? because if i call get-next manually couple times i get my tokens just doesn't work in the loop?

1:05 replaca: shouldn't be in that case

1:06 I'd say they'd be called in sequence

1:06 (although I'm not sure if left to right order is guaranteed)

1:08 I'd try (let [key-val (get-next) val-val (get-next)] (print key-val val-val) (recur (assoc result key-val val-val)))

1:08 and see what that tells you

1:09 (with some extra decoration on the prints to make them easier to read)

1:11 newbie_: kk thanks i was wondering how to reformat it like that.

1:11 replaca: newbie_: what's your language background?

1:12 newbie_: java,c++ mostly and a bit of elisp

1:13 but since i tried lisp i figured i did not know anything about lisp. elisp clojure so much difference

1:13 * clojure

1:13 replaca: cool, then you'll want to use (println (format "%s: %s" key value))

1:13 yeah, clojure is its own thing. A lot nicer than elisp, once you get the hang of it

1:15 oh, you know you're reading a char before you even start your loop, right?

1:15 newbie_: yeah to see if the token stream ends.

1:17 replaca: ok, so that supports the 0 token case

1:18 you might try a file that begins with 'e' as a base test

1:18 newbie_: ok

1:21 samwisem: would someone be able explain to me why it was decided to remove 'lazy-cons' from clojure?

1:24 replaca: samwisem: it's part of the "new" lazy seq architecture which makes laziness much more general and pervasive in Clojure. See http://clojure.org/lazy for some of Rich's notes

1:25 samwisem: you use the "lazy-seq" macro now

1:25 samwisem: ok

1:25 thanks i'll read that

1:26 newbie_: one more question replica, can i turn a vector or a list in to map? cause instead of creating the map directly i can read everthing in a vector or list and create if from that?

1:28 kotarak: ,(apply hash-map [:a 1 :b 2 :c 3])

1:28 replaca: newbie_: yeah, create a vector v of tuples [[k1 v1] [k2 v2] ...] and then do (into {} v) and, voila, a map

1:28 kotarak: No clojurebot -.-

1:28 replaca: or kotarak's way too :-)

1:28 kotarak: It depends on how the list/vector looks like.

1:28 replaca: yup

1:29 kotarak: or (zipmap [:a :b :c] [1 2 3])

1:31 replaca: a beautiful part of clojure is how easy arbitrary transformations are!

1:31 kotarak: replaca: yeah! that's awesome. The ease of use of the appropriate data structure.

1:56 newbie_: i was testing the following in repl but it gives me classcastexception (into {} (partition 2 ["test" "mest" "test2" "mest2"] ) )

1:57 cp2: whats the full message of the exception

1:58 newbie_: java.lang.ClassCastException: java.lang.String (NO_SOURCE_FILE:0)

2:04 replaca: hmm, the problem is that partition is making seqs which are behaving differently than vectors here

2:04 (into {} (for [ [k v ] (partition 2 ["test" "mest" "test2" "mest2"])] [k v ]))

2:04 works, but is ugly

2:06 this seems like a bug to me, but who knows...

2:06 however, kotarak's (apply hash-map ...) is a better sol'n here and works fine

2:08 newbie_: thanks for pointing that out i missied his message

5:56 mauritslamers: question: I seem to have a problem importing the right class. That is: I import the class, but when I want to use it, it returns no matching ctor found for class

5:56 lisppaste8: mauritslamers pasted "clojure-javax-sound" at http://paste.lisp.org/display/82749

5:57 Chousuke: mauritslamers: you don't want the [] around the parameters

5:57 mauritslamers: ah ok :)

5:57 Chousuke: mauritslamers: also, the closing parens are typically on the same line, not on their own like in C

5:57 mauritslamers: I know :)

5:58 But it confuses me :)

5:58 I have a small bit of Lisp experience

5:58 Chousuke: better get used to it.

5:58 mauritslamers: But I keep getting confused where something ends

5:58 Chousuke: that'll only last a while

5:58 as long as you indent properly

5:59 and have a decent editor )

5:59 :)

5:59 mauritslamers: using eclipse at the moment, so the editor is reasonably decent :)

5:59 Chousuke: hmm, I don't know about the eclipse plugin

6:00 I guess it does paren highlighting

6:00 mauritslamers: it does

6:00 Chousuke: anyway, most clojure code will use the lisp convention, so you'll need to get used to it in any case. It's better to go with the flow in this case

6:02 mauritslamers: Chousuke: mmm normally I have an innate problem going with the flow :)

6:04 Chousuke: this is how code looks like in Eclipse: http://skitch.com/mauritslamers/bsyri/javasound.clj-eclipse-platform-users-maurits-development-eclipse-workspace3

6:04 Chousuke: Understandable. But in this case you'll just end up making things more difficult for yourself.

6:05 mauritslamers: Thanks for the advice :)

6:06 Chousuke: http://mumble.net/~campbell/scheme/style.txt here's a style guide for scheme. It can be applied to Clojure

6:07 kotarak: There is also a "Why good style matters" or something similar. Also a funny read. :)

6:07 mauritslamers: second question: I want to write the following Java line as a clojure function: new DataLine.Info(SourceDataLine.class, DSP_AudioFormat);

6:07 Chousuke: Info is an inner class?

6:08 (DataLine$Info. SourceDataLine DSP_AudioFormat) should work

6:08 note the .; it's shorthand for new

6:09 kotarak: ah, there it is: http://www.cs.umd.edu/~nau/cmsc421/norvig-lisp-style.pdf

6:11 mauritslamers: I was calling (. SourceDataLine class) instead of just SourceDataLine

6:11 that 'll be the issue

6:11 thanks!

6:12 Chousuke: the other shorthands are Math/PI (equivalent to (. Math PI) or (Math/min 5 4) (. Math (min 5 4)) for static fields/methods and (.toUpperCase "bar") which is (. "bar" toUpperCase) for instance fields/methods. Please use these instead of using . directly

6:12 for method chaining, the -> macro is good to learn

6:14 for example, you can mix clojure and java: (-> "foobar" .toUpperCase (subs 3 6) .intern); yields "BAR", interned :P

6:14 kotarak: ... and doto for side-effects. (eg. configuring a fresh object)

6:17 Chousuke: the magic is that (-> foo (bar whatever)) becomes (bar foo whatever). ie. the previous expression is put as the first argument of the of the next expression, which repeats until there is no more to replace

6:18 so the previous example becomes (-> (.toUpperCase "foobar") (subs 3 6) .intern) --> (-> (subs (.toUpperCase "foobar") 3 6) .intern) --> (.intern (subs (.toUpperCase "foobar") 3 6))) -> "BAR"

6:36 mauritslamers: Another question: how to cast a result of a function to an interface in clojure? the original java line is (SourceDataLine) AudioSystem.getLine(dataLineInfo);

6:36 I want to be able to call the open method on the result, but I get "no matching method found"

6:37 which is true, as the object is of the wrong type (MixerSourceLine instead of SourceDataLine)

6:40 I tried (cast SourceDataLine (AudioSystem/getLine info)) but that did not result in having a SourceDataLine instead of a MixerSourceLine

6:41 AWizzArd: ,(doc cast)

6:41 kotarak: If MixerSourceLine implements the methods it should be found.

6:42 AWizzArd: ([c x]) Throws a ClassCastException if x is not a c, else returns x.

6:42 It seems that the function cast does not do casting.

6:42 kotarak: AWizzArd: it doesn't need to.

6:43 mauritslamers: MixerSourceLine does not implement the methods ... otherwise the casting wouldn't be necessary :)

6:46 AWizzArd: Maybe you can give a type hint? Where do you introduce the var?

6:46 (let [#^SourceDataLine sdl (AudioSystem/getLine info)] ...)

6:47 mauritslamers: I was looking into that indeed

6:47 checking...

6:52 compiling correctly now, no method problem anymore :)

6:52 let's write some sine function to create sound :)

6:55 AWizzArd: grats

6:56 And good to know that it works this way. We all can try to remember it :-)

6:58 mauritslamers: sadly it does not entirely

6:58 I'll paste the function.. moment

6:59 lisppaste8: mauritslamers pasted "clojure casting" at http://paste.lisp.org/display/82750

7:00 mauritslamers: The type hinting does seem to work

7:00 but does not seem to be able to return with the return value of the function

7:00 typehinting it again to be able to use the write function does not work: method not found

7:18 hoeck: mauritslamers: the get-sound-out function returns a MixerSoundLine here

7:18 I mean a com.sun.media.sound.MixerSourceLine

7:28 Chousuke: you shouldn't need to cast.

7:31 mauritslamers: hoeck: it does here too

7:31 it should be a SourceDataLine however

7:31 maybe the Java code I am trying to port is flawed in that manner

7:33 searching into the java stuff, it seems that there are other function to solve this issue

7:33 getSourceDataLine instead of getLine

7:35 hoeck: mauritslamers: it is a SourceDataLine (which is an interface according to my javadoc)

7:35 mauritslamers: mmm

7:36 hoeck: mauritslamers: try (supers (type (get-sound-out ...)))

7:36 so it implements the two open method

7:37 no matching metho found also happens if you call an existing method with the wrong parameters

7:37 like (.toString (Object.) "a")

7:38 mauritslamers: you're absolutely right, I must be sleeping over here :)

7:38 didn't think of that

7:38 Chousuke: the .open method call works just fine for me.

7:38 I get a mixersourceline out of get-sound-out with no errors

7:39 mauritslamers: supers returns: #{javax.sound.sampled.Line java.lang.Object javax.sound.sampled.DataLine javax.sound.sampled.SourceDataLine com.sun.media.sound.AbstractLine com.sun.media.sound.AbstractDataLine}

7:39 hoeck: exactly

7:39 Chousuke: I wonder what use the cast operation is in Clojure :/

7:39 other than asserting that an object is of a certain class.

7:40 mauritslamers: Chousuke: that also works for me, but then writing didn't work

7:40 but probably because I did not call the method correctly

7:40 stupid me :)

7:41 Chousuke: heh

7:41 hoeck: mauritslamers: well, java api's are sometimes a bit weird, especially when driven from clojure :)

7:42 mauritslamers: the error is completely understandable, because it is more or less the same as the java error message

7:43 but the clojure error is a little less verbose...

7:43 and therefore a bit confusing :)

7:47 hoeck: mauritslamers: please continue the sound example, I'm interested in playing "hello sine" from the repl :)

7:48 mauritslamers: hoeck: I most certainly will :)

7:49 annotating code on paste.lisp.org to contain the latest version of the code

7:50 lisppaste8: mauritslamers annotated #82750 "clojure sound" at http://paste.lisp.org/display/82750#1

7:51 achim: hi all!

7:51 hoeck: hi!

7:51 mauritslamers: when doing (try (.write soundout (take 100 sine) 0 100)), I am getting a class cast exception

7:52 hoeck: mauritslamers: yes, write wants a byte array

7:52 achim: does anybody have some pointers on diff'ing trees/nested data structures?

7:53 mauritslamers: I was hoping clojure would to the conversion automatically :)

7:53 hoeck: you have to convert the seq to an array, like (into-array Byte/TYPE .. seq of bytes

7:53 mauritslamers: hoeck: great!

7:53 achim: (not a very clojure-specific question, i know ...)

7:54 hoeck: mauritslamers: and don't forget to (map byte (take 100 sine)), cause the literal clojure numbers are not Bytes

7:55 mauritslamers: exactly the issue I was running into :)

7:56 working!

7:57 hoeck: mauritslamers: so just feeding the bytes into the mixer works? no extra methodcalls like start?

7:58 lisppaste8: mauritslamers annotated #82750 "working clojure soundout" at http://paste.lisp.org/display/82750#2

7:58 mauritslamers: That is already done in the get-sound-out function

8:00 It is easy now to create some function that just takes any seq of numbers and just output them...

8:00 that function could just allocate a source data line on the fly, play the data and next close the source data line again

8:03 maacl_: Is there a way to use amap on a 2-dimensional array (e.g. (make-array Integer 8 8))?

8:05 hoeck: mauritslamers: cool, but can't hear anything on my machine :(

8:05 mauritslamers: ?

8:06 hoeck: mmm

8:06 hoeck: are you using the code as I just pasted it ?

8:06 hoeck: yes, but its probably my broken sound setup + linux

8:07 mauritslamers: this setup should normally play to the standard output

8:11 hoeck: mauritslamers: it works! had to issue a (.start soundout) and then it played!

8:11 mauritslamers: great :)

8:11 was already trying to upload a small sample

8:12 strange that the (get-sound-out) function did not start the soundout then..

8:12 hoeck: mauritslamers: thanks for this sound example, way better to show off than hello-worlds or fib :)

8:12 mauritslamers: yw

8:12 it is a kind of starters thing for me with clojure

8:12 just trying to get something to work

8:13 :)

8:13 next task: write a lazy sine function

8:13 without trying to iterate it....

8:13 (which is the first thing that comes to my mind ... :[)

8:14 :[

8:15 mattrepl: how about a recursive "echo"? =)

8:18 mauritslamers: mattrepl: always nice :) Reverb is a damped recursion anyway

8:19 hoeck: mauritslamers: you did write a lazy sine, with cycle, now you just need to generate the cycled seq from parameters

8:19 mauritslamers: hoeck: I know... but I don't see how I can generate such a lazy sine as a function :)

8:20 has to be my part-functional - part imperative mindset :)

8:21 a sine has a few parameters in this case: frequency samplerate and length

8:21 frequency and samplerate can just be put into the formula

8:21 but the length is a different matter in my mind ...

8:22 achim: hmm ... frequency and sample-rate somehow translate to a step-width

8:23 and then you have (lazy-seq value-for-step-1 (sine from-step-two one-step-less-than-before)) ;-)

8:24 well, that's cons, not lazy-seq. pseudocode! :)

8:24 mauritslamers: achim: afaik samplerate and frequency is not the stepwidth

8:25 samplerate on it's own is the stepwidth, and the duration tells us how many samples to generate

8:26 but you are right that they together determine what the minimum amount of samples is for one complete sine

8:26 which can be cycled

8:26 most of the times this kind of generation is done by iteration

8:27 calculate the number of samples, have the frequency to generate, the volume and the samplerate in the formula and just generate the number of samples needed

8:28 mmm I remember something from the videos.. repeat or something like that

8:35 achim: mauritslamers: hmm, are aou sure? suppose you're repeatedly stepping through a plain sin(x) from 0 to 2*pi to collect values for your seq. if you increase the frequency, you have to increase the step-width and if you increase the samplerate, you have to decrease the step-with

8:36 mauritslamers: achim: yep: formula is volume * sin( 2 * PI * (1/samplerate) * frequency)

8:36 ehhh.

8:36 volume * sin ( 2* PI * (1/samplerate) * frequency * counter)

8:37 that is better :)

8:37 most things can be precalculated except volume and counter

8:38 so the calculation itself ends up with something like volume * sin(sine-factor * counter)

8:39 achim: i think we actually agree, i just put it confusingly. your sine-factor is my step-width

8:39 mauritslamers: ah ok :)

9:11 shoover: durka42: http://bitbucket.org/shoover/icfp it was fun but it doesn't work :(

9:14 drewr: I wish I had time to work on that this past weekend.

9:24 shoover: heh, the one open weekend all summer for me, it was like the perfect storm

9:43 lpetit: Hi all

9:43 What happened to clojurebot ?

9:43 kotarak: vacation?

9:43 lpetit: Or maybe moderated 'cause it was a Troll ;-)

9:44 Hi Meikel

9:44 kotarak: hehe

9:44 Hi Laurent

9:44 Working on the forms stuff.

9:45 cgrand: hi Laurent!

9:45 lpetit: Hi !

9:45 If you folks are on #clojure in the middle of the work day, how come I'll do my work day anymore ! :-)

9:46 kotarak: lpetit: MTO here...

9:46 Chouser: kotarak: why's that?

9:47 lpetit: MTO ?

9:47 kotarak: economic situation, I'm not a programmer. I'm QA in electronic development of a big automotive supplier. (ABS, ESC, such things)

9:48 lpetit: mandatory time off ("Kurzarbeit")

9:48 rhickey: lpetit: I have moderated a grand total of one person in 2100, with over 19000 emails

9:49 lpetit: rhickey : it really was a (not so fun joke), sorry if you thought I was trying to pass some hidden message

9:49 rhickey: I just don't want people to get the wrong impression about moderation

9:50 lpetit: rhickey : I really appreciate the way you're able to maintain a respectful community , and I don't think you're abusing your power in any means

9:50 rhickey: It has been used extremely sparingly and with much regret

9:50 drewr: rhickey, BMFL

9:50 lpetit: I understand. Those certainly are hard decisions to take.

9:50 kotarak: M?

9:50 Chouser: Was it a difficult decision to make in this case?

9:51 * drewr appreciates the decision (though his killfile works well too)

9:51 rhickey: because I don't want people to think they can't criticize Clojure, then have, and do, and many good improvements have come about because of it

9:52 Chouser: not difficult to make, but unfortunate. I value the integrity and tone of the group very much, this was the first real degradation

9:52 Chouser: Ok. I thought the posts in question while definitely more emotionally provocative (via arrogance, unwillingness to take criticism, etc.) than necessary weren't entirely without content.

9:52 drewr: Is trolling the problem with c.l.l, or the attitude of the "upper crust" (supposedly non-trolls)?

9:53 Chouser: I'm not second-guessing your decision, just musing.

9:53 lpetit: rhickey : in the exact same time you decided to moderate, I had thought for myself "wow, what's happening with clojure ml, there's something wrong happening". Hopefully I think you made a good decision in the right timing

9:55 rhickey: Chouser: agreed, each time I tried to let it go hoping for a gentle conclusion, but 2000+ people on the list can't become subject to those kinds of diatribes and endless arguments. I am convinced c.l.l. is a serious detriment to Lisp and will not repeat that

9:55 in c.l.l., they let tolerate extremely abusive people who occasionally have some technical merit. That's not good enough

9:56 Chouser: rhickey: well, in this area as in so many others regarding Clojure, I'm glad you're the one that has to make the final decision, and I trust your judgement. Haven't been let down yet. :-)

9:57 Though having said that, I've been inspired by some recent blogs to begin compiling a list of Clojure warts.

9:58 lpetit: must go, bye

9:58 Chouser: They're hard to find, but I have 3 so far.

9:58 rhickey: I think the Clojure list is one of the best I've ever been a part of, due to everyone's mutual respect and helpfulness

9:59 Chouser: should I wait for the blog? :)

10:01 drewr: Positive comments can get out of hand too. The "I got tingly thinking about Clojure at lunch today" and "I heart Rich" messages I can do without. (Not that I don't heart rhickey... who doesn't.)

10:01 Chouser: part of the problem with the other lists I've seen is almost every item can be eliminated as incorrect, justifiable (IMO), or easily fixable (and likely to be fixed).

10:01 drewr: ha!

10:02 tingly is funny

10:03 hm. one of my three is also very fixable. See, it's hard! That's use/require.

10:03 well, I guess what I want would be cause a breaking change, so maybe that's reason enough to include it.

10:04 I think require should go away and use should not refer in all public vars (unless explicitly told to).

10:05 the other two have to do with string and character literals. :-P

10:08 drewr: Maybe the :use option for referring * should have profanity in it so people won't want to leave it in production code.

10:08 (:use [foo.bar :import-all-MY-MOMS-A-&%$@!])

10:08 cemerick: I've come to use require with a sensible :as name almost exclusively. Reminds me of my good ol' python days.

10:08 Chouser: cemerick: good for you!

10:09 unfortunately, 'require' won't let you bring in specific names, so you have to switch to 'use' which messes your indnentation and the order of the forms in your code

10:10 drewr: could just be insulting instead of profane

10:10 (:use [foo.bar :import-I-am-a-careless-programmer-all])

10:11 cemerick: the only consistent exception is one namespace we have with a metric ton of commonly-used spatial predicates

10:11 drewr: Chouser: Nice :-)

10:13 mauritslamers: question: I am trying to create a lazy sine generating function, but I just seem to be unable to get my head around it... I keep thinking imperatively...

10:13 cemerick: the most troublesome thing about use IMO is that its effects are point-in-time; e.g. A uses B, but if a new fn is added to B, it's not available in A until A re-uses B.

10:13 opqdonut: yep, we need some sort of automated reloading

10:13 imo

10:13 mauritslamers: (map #(Math/sin some-val) (range numberoftimes)) is not lazy, though it works of course :)

10:14 opqdonut: some-val?

10:15 mauritslamers: (def some-val (* 2 Math/PI (/ 1 samplefrequency) * tone-frequency * samplenumber))

10:15 :)

10:15 (of course not defined in this way in my program :) )

10:15 Chouser: samplenumber -- that's an index into the resulting seq?

10:15 mauritslamers: yep

10:16 Chouser: everything else in there is a constant?

10:17 mauritslamers: it is the body of a function which returns the number of milliseconds in sound data

10:17 Chouser: (map #(Math/sin (* 2 Math/PI (/ 1 samplefrequency) tone-frequency %) (range numberofsamples))

10:17 except I missed a )

10:17 mauritslamers: that is more or less what i had indeed :)

10:18 I was just wondering how a lazy version of that calculation would look like

10:18 Chouser: that is lazy

10:18 opqdonut: range generates a lazy sequence

10:18 mauritslamers: ah, it is?

10:18 opqdonut: map is lazy

10:18 Chouser: 'map' returns a lazy seq

10:18 mauritslamers: ah, that explains a lot!

10:18 Thanks!

10:23 next question: how could I rewrite that function in such a way that I can use (take numsamples (lazy-sine args)) on it?

10:25 I can use the function the way it is now without problems of course, but I try to learn clojure this way :)

10:27 opqdonut: change range to an infinite seq of consecutive integers

10:28 Chouser: that is, (iterate inc 0)

10:28 opqdonut: imo (range) should do that

10:28 or (range 0)

10:28 and (range 0 n) being what (range n) does now

10:28 Chouser: It already does: (range 0 Integer/MAX_VALUE)

10:28 :-)

10:28 opqdonut: ...

10:29 Chouser: (range 0 Long/MAX_VALUE)

10:29 mauritslamers: (take 10 (range 0)) => ()

10:30 would an infinite seq of integers run out of memory somewhere? I would guess that somewhere after 4 mil iterations it would break...

10:31 *out of byte-space (so to say :) )

10:31 opqdonut: yeah

10:31 of course we could use bignums

10:31 yangsx: hi, what is the way to read an integer from a file in Clojure? I'm not so good at Java to find a way

10:32 mauritslamers: opqdonut: that would be a possibility, but I rather start at 0 every time... That works out better for the sound data too

10:33 Chouser: yangsx: (read-string (slurp "tmp.clj"))

10:33 mauritslamers: or a kind of intelligent round-robin, which calculates the max value as being the minimum of samples needed for one complete phase

10:34 yangsx: Chouser: what if the file is binary?

10:36 Chouser: yangsx: hm, perhaps you can find what you need in java.nio.ByteBuffer?

10:37 shoover: (let [file (-> "blah.bin" (FileInputReader.) (DataInputReader.))]

10:38 (.readInt file))

10:40 except use with-open instead of let

10:41 cemerick: I nominate zip-filter for inclusion in core, FWIW.

10:44 yangsx: shoover: JDK6 does not have DataInputReader, but a DataInputStream

10:44 shoover: er, yeah, that. and probably FileInputStream

10:45 Chouser: cemerick: I'm using enlive in my latest project where I could have used zip-filter.

10:46 cemerick: Chouser: Noted. But then, I'm not using zip-filter for XML :-)

10:46 Chouser: ooh, really?

10:48 cemerick: Yeah. Still querying into a DOM, but it's not XML.

10:48 it's funny how people equate DOM with XML, actually

10:48 XML/HTML, that is

10:48 Chouser: so you're not using zip-filter.xml?

10:51 cemerick: no. I'm in the process of making a corollary for this particular DOM.

10:51 Chouser: cool.

10:52 cemerick: of particular interest to you may be the fact that there are multiple relationship axes...e.g. there's containment, but also spatial, semantic, and logical relationships that one may want to query on

10:53 we've only worked out the containment and spatial ones so far, but the latter two will be coming soon (hopefully).

10:54 Chouser: interesting. So are you having to deal with zip-filter's 'auto' concept?

10:55 that's the one bit of zip-filter I'm most easily embarrased by.

11:03 cemerick: Chouser: no, Just started using it this morning, so I'm still internalizing it. I've just been using children (and not children-auto), and all's been well so far.

11:03 yangsx: java.nio.ByteBuffer seems to me requiring more time reading the java API, with DataInputStream I cannot use .readInt directly, because the binary data is unsigned and Java Integer is always signed. I thus use .readByte, reorder the bytes and calculate the integer myself.

11:04 opqdonut: java.nio is a horrible mess

11:04 imo

11:05 yangsx: I'm wondering wether there is a better way (given my lack of knowledge in Java).

11:09 Chouser: yangsx: google protobuf also has some raw byte-reading functions -- not sure if it would turn out any better for you though.

11:11 rhickey: too tricky? (ref-min-history aref) gets, and (ref-min-history aref n) sets

11:12 Chouser: nope. Is good.

11:14 yangsx: Chouser: thanks, I'll have a look at it.

11:15 Chouser: yangsx: http://code.google.com/apis/protocolbuffers/docs/reference/java/com/google/protobuf/CodedInputStream.html

11:17 shoover`: Chouser: is the irc log working part time for the summer? it seems to be 9 hours behind

11:20 Chouser: shoover`: yeah, it's written inefficiently, and is syncing only once a day to spare my ancient hardware

11:20 yangsx: that's libprotobuf-java in Debian

11:20 shoover`: Chouser: fair enough

11:21 Chouser: shoover`: I've got an improved version 80% done (my inotify work is meant to support this) which when complete should sync pretty much instantly.

11:42 * Chouser wonders if the new Ref knobs are to improve the behavior of ants.clj on low-cpu-count machines.

11:49 AWizzArd: Chouser: do you think that Ants performs better on a, say, hexadeca-core machine?

11:49 cemerick: rhickey: this is deep mojo that I'm not really clear on, but shouldn't history and such be transaction-local arguments to sync, rather than being persistently tied to refs?

11:50 Chouser: AWizzArd: I'm stumped.

11:50 AWizzArd: why?

11:50 shoover`: AWizzArd: I heard it ran pretty well on 700+

11:51 rhickey: cemerick: no, history is about the ref itself, seen by all transaction using it

11:51 AWizzArd: Where did you hear that shoover`? rhickey himself was talking about 600 I think

11:53 rhickey: cemerick: a single transaction might span a mix of highly and non-contended refs, each with a different history count

11:53 shoover`: AWizzArd: from him, but 700 was the number in my head

11:56 cemerick: rhickey: I guess what I was thinking is that a ref is not necessarily contended equally among all transactions it participates in, so you'd end up always setting max history to accommodate the highest count you need for all possible transactions, rather than the ones that the ref is participating in in that moment?

11:58 rhickey: cemerick: contention is inherently about multiple transactions

11:59 a ref only used in one transaction at a time will never grow history

11:59 unless now you've asked for some with :min-history

12:01 more explanation: http://groups.google.com/group/clojure/msg/bd50b598e7aa07ea

12:03 shoover`: there are 2 different 'ant' demos, one is the graphical ants, the other is a traveling salesman solver that uses ant colony optimization. It is the latter that was run on a 600 core box.

12:05 cemerick: it's also not necessary to accommodate the highest count, you can leave it low and get retries - a perfectly acceptable tradeoff between memory use and concurrency, there's nothing wrong with: try again a few ms later when less busy

12:05 shoover`: I see

12:05 rys: A box with 600 cores, or a cluster of them with 600 total?

12:06 rhickey: rys: an Azul box

12:06 cp2: 'clojure is so slow the ants demo needs to be ran on a 600 core machine!1!11!'

12:11 rys: Oh, those Vega chips are optimised for Java

12:11 Very cool

12:17 Anniepoo: url?

12:18 ATLien: url?

12:18 Anniepoo: trying to get the lisppaste bot to give me a new paste

12:19 ATLien: ah

12:20 achim: lisppaste8: url?

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

12:21 Anniepoo: thanks

12:25 lisppaste8: Anniepoo pasted "classpath problem" at http://paste.lisp.org/display/82771

12:25 Anniepoo: I can't get compilation to work within IntelliJ

12:26 Chousuke: your classpath urls look malformed.

12:27 Anniepoo: in what way? (Short of this being a winders machine, which I'm kinda stuck with)

12:27 Chousuke: "file:///C:/Documents.../.../src/"

12:27 you can use / on windows too

12:27 also you don't need to add the pragatischool dir to the classpath

12:28 Anniepoo: yah, was trying things.

12:28 Chousuke: but add-classpath is "wrong" anyway.

12:28 Anniepoo: well, it doesn't appear there's a way to set it anywhere else

12:28 Chousuke: check if IntelliJ allows you to configure the java classpath

12:29 which it should :P

12:29 also remember to add the classes dir (the compilation results) to the classpath

12:30 Anniepoo: the slashes after the protocol don't help, same error

12:31 Chousuke: add the classes dir too (make sure it exists)

12:32 Anniepoo: that might be it

12:32 Chousuke: it'll be src/classes/

12:32 and I think you need to add the ending slashes to the directory names too

12:34 Jomyoot: Does clojure compiles to Java first or straigth to byte code?

12:35 Anniepoo: thanks

12:35 I'll try all this stuff

12:35 Chouser: Jomyoot: straight to bytecode

12:37 Jomyoot: the bytecode produced doesn't always have Java source-code equivalent.

12:37 Jomyoot: ok

12:37 In the long run.

12:37 will codes written with Clojure or Scala run faster?

12:40 Chouser: in a lot of cases you can write code in each (or in Java) that will compile to essentially the same bytecode, in which case they'll run the same speed.

12:41 Jomyoot: why is clojure not in great programming language shootout

12:43 maacl: Is there a way to use amap on a 2-dimensional array like (make-array a 8 8)?

12:44 Sorry - should have been (make-array Integer 8 8)

12:48 Chousuke: Jomyoot: no-one has bothered to submit anything, I suppose.

12:49 hm

12:50 I'm thinking of writing a simple build system in clojure.

12:51 maacl: anyone?

12:52 Chousuke: there are some, but they have dependencies on maven and ant and whatnot. I just want something that sets up the classpath easily :/

12:54 maacl: use two amaps?

12:55 ATLien: Chousuke: I believe the book "Programming Clojure" leads you through building a simple build system

12:55 Chousuke: yeah, lancet.

12:56 Or maybe I'll just work on corkscrew. hmm.

13:08 Lau_of_DK: Good evening gents

13:08 eyeris: Hi :)

13:30 Chouser: oh my. assembla attachments can be changed.

13:31 without any indication on the ticket page itself?

13:32 you can click on "details" next to the attchment to find older versions.

13:38 rhickey: Chouser: yikes

13:40 Chouser: So on #137 I may have loaded the page before Steve's 1:23 comment was there, but when I clicked the patch link I got the new patch.

13:40 Or maybe I just overlooked his comment.

13:46 rhickey: yeah, I don't like the updating with same name - better to say -rev2 or something, but patch ok'ed and moved to next release

13:51 fun: http://sdk.org.nz/2009/02/25/why-unit-testing-is-a-waste-of-time/

13:52 Anniepoo: If you see (compile 'org.pragatischool.JustOut) where would you expect to find JustOut.clj?

13:53 Chousuke: <classpath>/org/pragatischool/JustOut.clj

13:53 Anniepoo: thanks

13:56 Error: Error compiling lib '/Documents and Settings/Annie/My Documents/bizwithmike/boring/src/org/pragatischool/JustOut'

13:56 lisppaste8:url?

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

14:07 Lau_of_DK: Guys - I spent an exceptional amount of time today, bughunting in Clojure - The reason was that SLIME seemingly forces evalutation in a lot of places where Clojure wouldn't normally - Anybody have any insight into this ?

14:11 Anniepoo: I can't believe this is this complex. I'm now on my 6th hour trying to get clojure to compile a java class

14:13 cemerick: one of these days that ant plugin will see the light of day...

14:13 Chousuke: heh.

14:13 Anniepoo: the java classpath system is complex. :P

14:14 but once it clicks, it's only a moderate nuisance.

14:14 Anniepoo: no it's not. It's IntelliJ's "now you get to guess what I really mean here" system that is complex

14:14 cemerick: Anniepoo: FWIW, I've never messed around with add-classpath. using clojure.lang.Compile from the command line or an ant task is the most straightforward compilation method, IMO.

14:15 Anniepoo: I don't care HOW I do it, I just need to be able to compile

14:15 Lau_of_DK: I thought Lancet was the weapon of choice ?

14:16 shoover`: Lau_of_DK: Do you have an example of such a place where slime forces evaluation?

14:16 Lau_of_DK: shoover`: Sure, hang on

14:17 Anniepoo: I'm reluctant to abandon using an IDE.

14:17 kotarak: When we are about laziness issues: (count a-seq) should realise a-seq, no?

14:17 cemerick: Lau_of_DK: I've not used lancet yet at all. I hear it has some ant interop. Build tools will always lag everything else (once stuff works, one generally doesn't want to touch it).

14:17 Lau_of_DK: True

14:17 cemerick: Anniepoo: AOT compilation and using an IDE are orthogonal issues/choices, FWIW

14:18 Anniepoo: yes, but if it's not actually possible to compile from the IDE it loses a lot of it's value.

14:19 kotarak: Well, if the IDE is that inflexible...

14:19 Anniepoo: I've been using IntelliJ for years, It's normally not inflexible. It's always been a pain to set up the classpath with it

14:19 but never quite this bad

14:20 cemerick: Anniepoo: Compiling from an IDE is sort of a misnomer w.r.t. clojure. *loading* is the important thing -- compiling is something you only really need to do when you're ready to produce a distributable.

14:20 Chousuke: you could ask rhickey :P

14:20 Anniepoo: cemerick, in this case I am trying to write a GUI. I've got an extension to JPanel

14:21 Chousuke: are you sure you need gen-class anyway?

14:21 Lau_of_DK: shoover`: Actually, the code is in the vault at work, and Im not on the VPN right now, but it was a for loop with alot of nested maps and when we tested the code in the repl, everything worked fine, when we ran it from command-line, the for loop broke down, and the database backend got handed lazyseq@124821948 instead of the values as it had done when we had a repl going

14:21 Chousuke: use proxy?

14:21 Anniepoo: many of the callbacks need some corresponding clojure form

14:21 Chousuke: at least for JPanel a proxy will do just fine.

14:22 cemerick: Anniepoo: I'd agree with Anniepoo, chances are you're using genclass unnecessarily.

14:22 Anniepoo: how do I attach the new member variable so I can hang onto the state?

14:22 justin`: hey guys I'm new at this and struggling wit recursion. can anyone tell me how to construct a 52 card deck out of a list of 4 suits and a list of 13 ranks?

14:22 Anniepoo: I probably am

14:22 cemerick: Anniepoo: (defn make-new-panel [member-variable] (proxy [JPanel] [] ...))

14:22 Chousuke: justin`: you could use for

14:23 Anniepoo: yah, hang on, I'll paste the thing I've been working on

14:23 cemerick: member-variable could just as easily be a ref, so you can have overrides in the JPanel proxy manipulate it as necessary.

14:23 Chousuke: justin`: (for [s suits, r ranks] (card s r))

14:24 justin`: produces a lazy seq of 52 cards

14:24 justin`: Oh sweet

14:24 lisppaste8: Anniepoo pasted "proxy?" at http://paste.lisp.org/display/82783

14:24 Chouser: (for [suit '[H S D C], rank (concat '[a] (range 1 10) '[j q k])] (str rank suit))

14:24 * Chouser should look up before from his work before pasting

14:24 shoover`: Lau_of_DK: it's really hard to think of why slime would affect that, since it's just passing entire forms to clojure for evaluation. It's sounds like something wasn't reloaded when you thought it was

14:24 Anniepoo: so, this cose is 'so far so good', but I need to start keeping a model. Got stuck trying to compile cause I needed :state

14:25 Chousuke: are you sure you need :state? :)

14:25 Lau_of_DK: shoover`: Like I said - We tested for hours, reloading the repl, putting in printlns and what not, and the end result was, that with SLIME everything got called Okay - Without slime, alot of the underlying maps and such didnt get evaluated despite the fact that the main for was wrapped in doall.

14:25 Anniepoo: I need a model.

14:25 Chousuke: a global or a closed over ref ought to work just fine.

14:26 shoover`: Lau_of_DK: Sorry about your luck, sounds like a doozy

14:26 Anniepoo: I need one global for every one of these things

14:26 Lau_of_DK: It was

14:26 Anniepoo: I'm making a little browser that displays clojure as a nested set of colored panels

14:26 Lau_of_DK: And the solution was, that every single map had to be wrapped in doall....

14:26 shoover`: I'm guessing your db isn't too excited about lazyseqs

14:26 Anniepoo: it's mostly just a toy to learn clojure

14:27 cemerick: Anniepoo: presumably not -- as I msged before, a make-panel fn that closes over whatever refs you need and returns a JPanel proxy should be fine

14:27 Anniepoo: but I'm thinking some day it'll be an editor

14:27 Chousuke: (defn new-jpanel-instance [] (let [my-model (ref nil)] (proxy [...] (someOverride [] (manipulate my-model))))))

14:27 Lau_of_DK: shoover`: That was the least of our problems (since I wrote it myself), the main problem was that code simply wasnt being called

14:28 Chousuke: that way, every jpanel proxy returned by new-jpanel-instance will have its own ref it can access from the methods.

14:28 Anniepoo: makeAtomLabel is the fn, but I'm having trouble parsing "that closes over whatever refs you need"

14:28 which is probably my base problem

14:29 Chousuke: Anniepoo: (let [x 4] (fn [y] (+ y x))) <- that anonymous fn closes over x in this case

14:29 Anniepoo: hmm

14:29 Chousuke: it captures its lexical environment

14:30 shoover`: Lau_of_DK: I'm intrigued. Send an example tomorrow if you want some extra testing

14:30 Chousuke: it's a basic functional programming technique, and very useful. Worth meditating until you get it :)

14:30 cemerick: pretty critical, yeah.

14:31 Lau_of_DK: shoover`: I think I need to try and recreate some similar code, since this is commercial code - that might take a little time since Im pursuaded to toss SLIME out the window and stick with inferior-lisp

14:31 shoover`: sure

14:31 cemerick: Anniepoo: do you have the Programming in Clojure book?

14:31 Anniepoo: yes

14:31 ok, I see the trick

14:32 cemerick: Anniepoo: in that case, I'd keep to something a little simpler than UI stuff for a little while. Swing is not the simplest things to work with in and of itself.

14:33 Anniepoo: well, I'm well familiar with swing. I'm a java programmer. But the last functional programming I did was college in the 80's

14:33 cemerick: Anniepoo: my apologies :-) Hard to know who knows what.

14:34 Anniepoo: yah, np - that's where I am. 8cX All engineers are perpetual students.

14:35 ok, if you look at my paste, and search for cnt, why isn't that working? it's always 1

14:35 I thought I was 'closing over an atom'

14:35 cemerick: Anniepoo: the Little Schemer is another fantastic book, and would go along with PiC nicely

14:35 Anniepoo: kk

14:36 'captures' and 'closes over'... hmmmm

14:37 so, at the top of my makeAtomLabel I'm doing

14:37 (let [cnt (atom 0)]

14:37 Chousuke: Anniepoo: makeAtomLabel looks like it should work.

14:38 Anniepoo: yes, it works

14:38 but look at cnt

14:38 I'm trying to just count the number of times it's clicked. I'm always getting 1

14:38 Chousuke: hm.

14:40 cemerick: seems like the only way that'd happen is if each click was being registered on a new label produced by makeAtomLabel

14:41 Anniepoo: no, I don't think that's it

14:41 8cD and of course now I've messed up my project file and it won't run that either

14:43 fixed it

14:44 Chousuke: it works for me.

14:44 Anniepoo: ok, I'm an idiot.

14:44 yah, it works for me.

14:45 ok, so you see what I'm doing.

14:46 I want to eventually have you able to alt mousedown in one of the panels and tug and have it

14:46 change from horizontal to vertical

14:46 but to do that I need to hang onto state - whether it's vertical or horiz

14:47 Chousuke: you should be able to do that with an atom too, shouldn't you?

14:47 Anniepoo: yah, guess so

14:47 cemerick: Anniepoo: that becomes another atom (alongside cnt)

14:48 Anniepoo: I was trying to make some MVC pattern

14:48 Chousuke: well, you could close over a bunch of controller functions instead...

14:48 Anniepoo: ok

14:48 Chousuke: but that gets somewhat more complex.

14:48 :)

14:49 anyway, any reason you're not using the ns macro?

14:49 Anniepoo: I didn't know about it when I wrote this

14:49 now I do

14:50 us noobies are good for testing stuff nobody else actually uses 8cD

14:51 so, any way I can add another function and have it visible from outside?

14:51 like, my long range plan, if you pull on an atom and it's already vertical, eventually it'll tell it's parent to become vertical

14:52 cemerick: in-ns is widely used, but only in REPLs

14:52 Chousuke: Anniepoo: what do you mean "from outside?"

14:53 you can always return a function as a value from another function.

14:53 usually a closure :)

14:53 Anniepoo: I want to, say, be able to add some makeMeRed method to the proxy returned by makeAtomPanel

14:54 so I can say (.makeMeRed somePanel) and it turns read

14:54 red

14:54 <-- too many years of OO

14:54 Chousuke: hmm, I don't think you can do that.

14:54 not with proxy.

14:54 Anniepoo: I don't care if it's a 'real' Java method

14:55 but need some way of doing the same thing

14:55 Chousuke: does makeMeRed need access to the panel's privates? :P

14:55 Anniepoo: now you've made ME red! LOL

14:56 no, but lets say I want to know the value of cnt from outside

14:56 Chousuke: hmm

14:56 I'll gist something

14:57 Anniepoo: (cnt-of somepanel) => 6

14:59 if I defn cnt-of within the let, then how do I specify which panel I'm talking to?

14:59 All of this abandoning of OO is making me deeply uneasy. I remember how sloooow programming was before then

15:00 Chousuke: http://gist.github.com/138339

15:00 Anniepoo: I find functional programming techniques much faster than OO :)

15:01 Anniepoo: ok

15:01 Chousuke: that closure approach is very OO-like

15:01 Anniepoo: I'll believe you

15:02 Chousuke: it might not be the best approach, but it's a possibility

15:03 cemerick: Anniepoo: objects *are* closures, and vice versa.

15:03 Anniepoo: ok, so you define and return a map with the proxy and the accessor methods

15:03 Chousuke: yeah.

15:03 Anniepoo: that's not far from what I was struggling to do

15:04 shoover`: One of my favorite parts of using clojure is ripping out imperative for loops, but sometimes you do need the counter that was always there for free. Any tips for cleaning this up? The requirement is to remove duplicates while preserving the index. I wonder if I'm missing something since I have to build up a vector and then tear it apart.

15:04 (remove (fn [[i a b]] (= a b))

15:04 (map #(vector %1 %2 %3) (iterate inc 0) [:a :b :c] [:a :a :a]))

15:05 Chouser: part of what's hard going from OOP to Clojure is that you have so many more options here -- often dozens of designs with only slight differences between some of them, any of which may work fine.

15:05 Anniepoo: yah, my create code could even string the maps

15:05 Lau_of_DK: shoover`: For your inspiration: http://clj-me.blogspot.com/2009/04/counting-occurences.html

15:05 Chouser: ...but have trade offs that I'm not yet able to spot very early in the process.

15:06 so I write something, get it to to work, find some use case is a bit clumsy, am struck by a new design option, write it, repeat...

15:07 Hopefully I'm learning in the process how to make better decisions earlier in the design process next time. :-/

15:07 Chousuke: dynamic typing helps a lot with that.

15:07 you don't need to rewrite your class hierarchy :P

15:08 Chouser: yep. I had some of the same feeling when writing JavaScript code, but in Clojure there are even more powerful tools, and even more options (most of which are better than most of the JS options...)

15:08 Anniepoo: yes

15:08 prototype based class systems beat static classes hands down

15:09 I was writing ActionScript 3 for a while

15:09 and took a side detour through Groovy

15:10 Something I'd really like my toy to eventually do is eval whatever's inside a panel. So you could ctrl-alt-meta middle double click and have it show the eval instead of the form

15:11 Chousuke: that shouldn't be too difficult as long as you keep the form somewhere. :P

15:11 Anniepoo: yes

15:13 I'm going to use your 'make a map' method, and have a var back to that piece of the original form for each panel

15:14 shoover`: Lau_of_DK: inspiring yes, but it looks like I still need the map phase in order to deal with the three seqs in parallel

15:15 Anniepoo: chosuke and others, thanks for the help. I'm back on track.

15:16 Lau_of_DK: shoover`: Sorry, I didnt read from your msg that you wanted the map gone

15:17 shoover`:

15:17 Lau_of_DK: map supports 3 colls, where reduce only takes one, so I have to run through map to get a seq I can pass to remove

15:17 Lau_of_DK: hmm... I fairly sure that reduce and apply takes at least 2 seqs?

15:19 shoover`: clojure.core/reduce ([f coll] [f val coll])

15:20 this is better, no vectors + destructuring:

15:20 (remove nil?

15:20 (map #(when-not (= %2 %3) [%1 %2 %3]) (iterate inc 0) [:a :b :c] [:a :a :a]))

15:20 cemerick: Chouser: am I right in thinking that I shouldn't ever have to flatten the value returned by zip-filter/descendants?

15:21 djkthx: if i'm working with a java library that expects: List<SomeClassName>

15:21 and i have a clojure seq of SomeClassName's

15:21 how would i call the java library properly from clojure?

15:21 cemerick: djkthx: (.someMethod someLibraryObj your-clojure-seq)

15:22 That List<Classname> is just a List at runtime.

15:22 djkthx: i'm getting a "No message" error

15:22 Lau_of_DK: hehe - I love that one

15:23 djkthx: and a rather unhelpful backtrace

15:23 oh yeah

15:23 it's a good one

15:23 Chouser: cemerick: not if you're passing it to the next stage of a chain

15:23 Lau_of_DK: djkthx: Consider it Richs little Easter Egg :)

15:24 djkthx: http://www.brics.dk/automaton/doc/ is the library in question

15:29 this doesn't make sense

15:29 hmm

15:32 cemerick: djkthx: try pasting the stacktrace

15:32 djkthx: weird, i think i got it working

15:32 the lib had a static method that seems to work

15:56 cemerick: clojure.zip has some odd rough edges when one is consuming an existing tree. e.g. naive zippers (like vector-zip) end up not working with zip/children, etc.

15:58 (that is, unless I'm missing something dreadfully obvious)

16:11 Chouser: cemerick: like this? http://www.assembla.com/spaces/clojure/tickets/135

16:13 cemerick: Chouser: that's a separate issue. (tree-seq zip/branch? zip/children (zip/vector-zip [[1 2] [3 4] 5])) => NPE

16:13 Chouser: oh, so what are you referring to?

16:15 cemerick: well, there's some imbalance in the api -- zip/down et al. return nodes, but zip/children doesn't return a seq of nodes, so certain things don't work out as one would expect (e.g. using tree-seq in conjunction with a zipper)

16:19 Chouser: a quick glance at the code suggests that both vector-zip and xml-zip have a 'children' that returns a seq of nodes (not locs), compared to 'down' for which both return a loc

16:19 Is that what you mean -- returning different types from different fns?

16:26 cemerick: returning different types isn't a problem (you need to get at your nodes eventually, of course). I guess I'm just missing a loc-children (or whatever) fn that takes care of the loc bookkeeping. Certainly easy to impl, I'm just surprised I'm the first one that felt the need for it.

16:26 (Perhaps that means I'm using the thing wrong. :-) )

16:27 Chouser: I think the problem (which I didn't realize until I was well into zip-filter) is that you'd get a seq of *different trees*

16:27 this doesn't matter if you're only reading -- you can descend into each, look around, whatever. This is exactly what zip-filter automates.

16:28 cemerick: well, that's what I figured children would get me (before I looked at the code) -- a seq of subtrees

16:29 Chouser: but if you make a change in one of them, you can no longer use the others -- they're old versions of the tree.

16:29 if you want to make two changes, one in each sub-tree, how will you merge the results?

16:29 cemerick: oh, I see what you're getting at.

16:29 See, the trees I'm working with are already formed, never-gonna-change

16:29 Chouser: well, that's good -- it took me a long time to see this problem.

16:29 cemerick: so, I didn't think of the modification issue

16:30 Chouser: so zip-filter is fine in such cases, and provides a function like you're asking for.

16:30 and it's called "children" :-)

16:31 it's also the problem that caused cgrand to give up on zip-filter and do his own thing for enlive, since that's specifically about making modifications.

16:31 he can still use clojure.zip, just not zip-filter.

16:31 gotta run.

17:20 rhickey: hrm, does take-subs still need pad?

17:26 Chouser: why would it?

17:27 most of the times I've wanted take-subs it's been then fed into destructuring, where I wanted short subseqs or nils

17:27 using 'concat' for the less common cases seems sufficient.

17:29 prospero_: so if I want to forward arguments to another function, I can do something like (defmacro p [& args] `(print ~@args))

17:30 Chousuke: you don't need a macro for that.

17:30 maacl: Why would I get "No matching method found: aclone" when trying to use amap?

17:30 prospero_: is the macro necessary in this situation?

17:30 hey, beat me to it

17:30 Chousuke: (defn p [& args] (apply print args))

17:30 prospero_: oh, apply

17:33 I can't do something like (apply (. "hello" substring) 1 2), though, apparently

17:34 Chousuke: you can with reflection.

17:34 but it's a bit complicated

17:34 prospero_: I figured

17:34 do you have to get the method object?

17:35 Chousuke: http://paste.lisp.org/display/67182

17:36 prospero_: is there a performance overhead associated with that, or is that roughly what goes on under the covers anyways

17:36 rhickey: Chouser: pad with nils, e.g. becomes tedious because you can't just concat (repeat nil)

17:37 maybe padding is for partition, but still never yielding partials?

17:38 (back to yield up to partition containing last, vs all offsets contained)

17:43 hircus: http://github.com/richhickey/clojure-contrib/commit/82cf0409d0fcb71be477ebfc4da18ee2128a2ad1#comment_24628

17:43 is something wrong with the last commit to clojure-contrib?

17:44 durka42: it removes stacktrace?

17:44 * durka42 likes print-cause-trace

17:44 kotarak: hircus: at least the move of stacktrace is announced.

17:44 it's now in core.

17:44 hircus: condt, stacktrace, template, test-clojure, and walk

17:44 all of these are still mentioned in load_all.clj

17:44 kotarak: condt is removed, I think, stacktrace, template, walk and tests are in core

17:45 hircus: how about condt and template?

17:45 kotarak: load_all.clj was probably not correctly modified

17:46 hircus: I'll submit a patch, thanks

17:46 so people using Clojure 1.0 should stick to an older revision of contrib, to use test-is ?

19:45 djkthx: is there a way to have a string not have \ as an escape character?

19:46 so i don't have to do "\\" when i want a literal \?

19:51 Chousuke: Not that I know.

20:25 achim: i remember there was a discussion of a [x & xs] binding form with 'rest' semantics (instead of next). has something like this been introduced?

20:46 rhickey: achim: not yet, right now & in destructuring matches & in fn arglists - eager, and much code relies on nil from &, so it would have to be some other form (&rest?)

20:47 eyeris: I have a map of the form {:a {:x 1} :b {:y 1}}, to update :y I currently do (assoc my-map :b (assoc (:b my-map) :y 2)). Is there a common function for making these types of tiered associations?

20:53 Chousuke: eyeris: assoc-in and update-in

20:55 eyeris: Very good!

20:55 Thanks!

21:08 gstamp: No loop/recur in a catch? :-( http://pastebin.com/m642e2c1d

21:24 eyeris: gstamp I think you can have either inside the other

21:25 you just can't have a recur inside a catch where the loop is inside the try?

21:26 gstamp: got disconnected before... wans't sure if my paste made it. Basically had to move the loop.recur into a new method. Seems like a strange restriction but it's something I can live with.

21:27 eyeris: gstamp I think it has to do with garunteeing that (recur) is in the tail position.

21:28 gstamp if there was tail call optimization, you'd like just place the call in a non-tail position and erroneously think that it was being optimized away

21:29 gstamp: ok.

21:43 Chouser: djkthx: If you really want to avoid "\\" your best choice may be to use some other char and search/replace later.

21:44 djkthx: I assume your string literal is known at compile-time, in which case you can use a macro to do the replace also at compile time.

21:45 (defmacro backslash [s] (.replace s "/" "\\"))

21:45 (backslash "one/two/three") ==> "one\\two\\three"

21:51 arohner: grrr. Slime is not happy with unicode in variable names

22:19 seths: I'm looking at (drop) and (rest) and can't find the difference

22:20 except that (drop) is defined in core.clj and (rest) I am still looking for its defn

22:20 even tried macroexpand

22:20 (drop 1 '(1 2 3)) => (2 3)

22:20 (rest '(1 2 3)) => same

22:21 is rest just a simple helper based on drop?

22:26 gstamp: drop seems to use rest as part of its implementation.

22:27 jackdempsey: you can say drop 5

22:27 can't say rest 5

22:37 seths: apparently I need to spend more time on http://clojure.org/lazy

23:13 Jomyoot: what is ide of choice for clojure?

23:21 durka42: Jomyoot: a lot of people use emacs

23:21 I use vim

23:22 some people use eclipse

23:22 IntelliJ

23:22 that was not an answer to your question :)

23:23 Jomyoot: ไำสส

23:23 well intellij plugin is not complete?

23:23 its version 0.01?

23:23 :(

23:23 i use intellij

23:24 grrrt: I grew up with vi, but switched to (Aquamacs) emacs for clojure

23:24 Chouser: Common lisp was not a sufficient lisp. Clojure is.

23:25 Emacs is not a sufficient emacs. ... :-(

23:25 durka42: i learned emacs for common lisp, and vim for clojure...

23:25 FSVO "learned"

23:26 grrrt: I find myself missing ParEdit when I'm not in emacs... paredit works really well for me

23:27 I don't like the clojure/jdb emacs stuff though - I'd rather use the eclipse debugger

23:27 but that doesn't let me set breakpoints

23:28 on the other hand, I don't need to singlestep nearly as often with clojure as I do with java

23:57 durka42: is evaluation order of function arguments deterministic?

23:59 slashus2: Is it from left to right?

Logging service provided by n01se.net