#clojure log - Jun 11 2008

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

9:23 rhickey_: A new Clojure talk, oriented towards those with no prior Lisp: http://clojure.blip.tv/file/982823

9:26 grosours: hi everybody

9:26 rhickey_: hi

9:38 cgrand: reduce retains a reference to the head of the seq :-(

9:41 Is explicit looping (recur) the only way to process (very) large sequences?

9:42 rhickey_: reduce used to do that, now can leverage internal reduce of several collections

9:43 but I need to re-enable loop where collection can't do anything special, as internal reduce holds head as you saw

9:44 some sort of lazy? metric

9:44 for 'realized' collections, internal reduce is fastest

9:45 cgrand: because it may be inlined to a simple for

9:46 rhickey_: can leverage the internal structure of the collection, and eliminate reified seq objects

9:54 asbjxrn: Is there something like load-truename in clojure?

9:55 rhickey_: load-truename?

9:55 asbjxrn: I have a start.clj from which I want to load another clj file in the same directory.

9:57 In CL you have, variables *load-truename* *load-pathname* that are set accordingly when a file is loaded

9:58 so if I had a file in the same dir I could do (load (merge-pathnames *load-pathname* "foo.lisp"))

9:58 (paraphrased.... :)

9:58 cgrand: rhickey_: just being curious: wouldn't a Reducer interface be an alternative to a lazy? metric (eg (.. s getReducer (reduce f val)) )?

9:59 rhickey_: asbjxrnL nothing like that yet

9:59 asbjxrn: I guess this would be outside the scope of a small core, though ...

9:59 rhickey_: may be something in contrib?

9:59 asbjxrn: Yeah, the library stuff in contrib may be what I want. Haven'

10:00 haven't had a close look yet.

10:00 rhickey_: cgrand: yes, it's not really laziness, it's - does this support efficient internal reduce

10:01 part 2 of the talk: http://clojure.blip.tv/file/982957/

10:05 cgrand: Is it the talk you gave last week?

10:06 rhickey_: yes

10:06 all 2:48 of it

10:06 in 2 parts

14:07 Lau_of_DK: rhickey, everytime you write "Fixed -Thanks for the report" in the Googlegroup, is there an SVN or CVS I can checkout with those updates added?

14:07 rhickey: If I say fixed, it's fixed in SVN as of then

14:08 Lau_of_DK: Sweet

14:13 la_mer: rhickey: I was reading the page about the new primitive support, and noticed that you say that Clojure doesn't actual emit any bytecode for primitives at all, instead relying upon hotspot to optimize primitive operations (you say something like this again in the talk you posted most recently to blip). Are you just providing certain hints to hotspot that the numerics involved can be safely unboxed?

14:13 * la_mer knows virtually nothing about hotspot, but is curious :-)

14:14 rhickey: I emit typed calls to static methods (of clojure.lang.Numbers) that wrap simple primitive arithmetic and HotSpot inlines them. So I emit method calls only.

14:15 I do emit bytecodes for passing/returning primitives to methods

14:15 but not arithmetic

14:16 Chouser_: while you're on the topic, what tool do you use to examine the code the hotspot ends up producing?

14:18 rhickey: I only see the effect, not the code at runtime. Since the speed is identical to that of Java using primitive arithmetic, the presumption is that is what HotSpot is yielding

14:18 Chouser_: ah.

14:18 rhickey: but there is some way to get that IIRC

14:25 Lau_of_DK: How much does the term "primitive support" cover ?

14:26 rhickey: int/float/long/double

14:26 and arrays of same

14:28 Lau_of_DK: ok, thanks

14:29 Chouser, one thing you said last night didnt make sense, but it worked. Why does (.contains x y) work? I get that (. method param) works because its the syntax, but what about your variant?

14:29 cgrand: Chouser_: I remember having used -XX:+PrintCompilation

14:31 Chouser_: Java: obj.method( arg1, arg2 ) Clojure: (. obj method arg1 arg2) or (.method obj arg1 arg2)

14:31 Lau_of_DK: oh I see

14:31 Chouser_: In your case the method was static, so obj was the classname. Which always confuses me a little.

14:34 Lau_of_DK: Ok, thanks for clearing it up and emphazing :)

14:34 spell check ? :)

14:37 Chouser_: cgrand: that's cool!

14:37 It's not showing me the bytecode, but it's fun to see when stuff gets compiled.

16:47 Lau_of_DK: VIM Users: When you use VIM and Clojure - Do you have live interaction with the REPL? Like you evaluate directly into the REPL and such, or is that only in Emacs ?

16:48 Chouser_: I don't bother.

16:48 Lau_of_DK: why not?

16:49 Chouser_: Generally, I just re-run the repl on the file I'm working on.

16:49 Lau_of_DK: But then youre missing out on all the good stuff, like altering the logic while the program is running and all that

16:50 Chouser_: Well, I sometimes drop a new function into the running repl. That's two mouse strokes.

16:50 Lau_of_DK: ok - Maybe I should just give Vim a twirl

16:50 Im just used to Emacs by now

16:50 Chouser_: I'm not claiming my setup it The Best, I'm just telling you what I currently do.

16:51 Lau_of_DK: But Im not sure that the clojure-mode and clojure-swank stuff is fully complete

16:51 I think its acting a bit weird sometimes

16:51 Compared to something like SBCL, which is just rock solid in this regard

16:58 Anybody else got that impression?

17:00 Alright, you guys arent editor reviewers, I got that, lets talk shop

17:00 Lets say I want to generate a stream of all possible combinations of "ABCDEF" in sets of 4, ie ABCD or AAAB or ABAB and so on - Any ideas on how to attack that?

17:10 * Chouser_ smells projecteuler

17:10 Lau_of_DK: No its not for Euler

17:11 Chouser_: :-) ok, ok.

17:11 Lau_of_DK: But there was a lexical permutation problem that I never managed to solve, which posed a similar problem

17:11 But I'm really interested in how you do these kind of combinations

17:11 This is for a Mastermind solver

17:13 Chouser_: (def s [:A :B :C :D :E :F]) (for [x1 s x2 s x3 s ...] (prn x1 x2 x3 ...))

17:18 Lau_of_DK: I think thats a little weird..

17:18 Why didnt I think of that?

17:19 Chouser_: non-repeating combinations are a little more interesting.

17:19 Lau_of_DK: how so ?

17:20 Chouser_: well, the choice for x1 reduces the selection for x2, so it's a little trickier.

17:20 Lau_of_DK: Yea, fortunately, I dont need that now

17:20 :)

17:20 But thanks alot Chouser, you opened my mind a little bit there

17:20 Chouser_: So what's weird about the "for"?

17:21 Lau_of_DK: I just imagined that they would all execute in sequence

17:21 a a a

17:21 b b b

17:21 c c c

17:21 d d d

17:21 ...

17:22 Chouser_: yeah, the way that "for" sorta nests the sequences surprised me too the first time. But it sure is handy.

17:22 Lau_of_DK: yea - I remember one time though, where I got the opposite result - dont remember what I did

17:22 but thats why I didnt try it

17:22 I think that was mapping 2 sequences

17:24 Chouser_: (for [x1 s x2 s x3 s] [x1 x2 x3]) vs. (for [[x1 x2 x3] (map list s s s)] [x1 x2 x3])

17:25 Lau_of_DK: user> (map (fn [a b] (list a b)) (range 5) (range 5))

17:25 ((0 0) (1 1) (2 2) (3 3) (4 4))

17:25 yea, or that type of thing

17:26 Chouser_: right.

17:26 (map list (range 5) (range 5))

17:26 Lau_of_DK: Showing off, will be punished :)

17:26 Chouser_: ;-)

17:28 Lau_of_DK: Ok Chouser, you might recent me for this

17:29 But if I want to change def s [:a ...] to an "inifinite" (its not its 1296) stream of lazy-cons...

17:29 Can you hint me to how I go about it?

17:32 Chouser_: a stream of what? where are you getting your 1296 data items?

17:32 Lau_of_DK: if you count all the combinations, its 1296

17:33 I just need to have a stream I can walk through

17:33 So I wanted to do something like when we do fibs

17:34 Chouser_: This is a lazy seq: (for [x1 s x2 s x3 s] [x1 x2 x3])

17:35 Lau_of_DK: Oh thats right - Unless I force it with doall

17:35 Thanks... :)

17:09 Chouser_: (defn comb [r m p] (if (> m 0) (mapcat #(comb (disj r %) (dec m) (conj p %)) r) [p]))

17:09 (comb #{1 2 3 4 5} 3 [])

17:21 Lau_of_DK: wow

17:21 thats REALLY nasty Chouser

17:22 * Chouser_ bows

17:25 Lau_of_DK: Thats going in my toolbox

17:25 When does your tutorial site launch Chouser ?

17:25 Chouser_: It's here, live, right now. ;-)

17:26 Lau_of_DK: Hehe, cheap skank

17:26 Chouser_: Lau_of_DK: are you in Europe?

17:26 Lau_of_DK: Denmark to be exact

17:28 Chouser_: hm, that won't work if any of the items are duplicated.

17:28 ...since a set can't hold dups.

17:29 Lau_of_DK: right, then it just discards it

17:30 Why did you ask my location Chouser ? Because if you're thinking of coming over to teach me some tricks personally, I'll buy you a whole cup of coffee

17:31 Chouser_: There's a little thing in Chicago next Friday -- just wondered how close you are.

17:32 To which the answer is "not very".

17:32 Lau_of_DK: true

17:58 I gotta hit the sack - Again Chouser, you've been a great help, thanks! :)

Logging service provided by n01se.net