#clojure logs

2008-06-11

09:23rhickey_A new Clojure talk, oriented towards those with no prior Lisp: http://clojure.blip.tv/file/982823
09:26grosourshi everybody
09:26rhickey_hi
09:38cgrandreduce retains a reference to the head of the seq :-(
09:41cgrandIs explicit looping (recur) the only way to process (very) large sequences?
09:42rhickey_reduce used to do that, now can leverage internal reduce of several collections
09:43rhickey_but I need to re-enable loop where collection can't do anything special, as internal reduce holds head as you saw
09:44rhickey_some sort of lazy? metric
09:44rhickey_for 'realized' collections, internal reduce is fastest
09:45cgrandbecause it may be inlined to a simple for
09:46rhickey_can leverage the internal structure of the collection, and eliminate reified seq objects
09:54asbjxrnIs there something like load-truename in clojure?
09:55rhickey_load-truename?
09:55asbjxrnI have a start.clj from which I want to load another clj file in the same directory.
09:57asbjxrnIn CL you have, variables *load-truename* *load-pathname* that are set accordingly when a file is loaded
09:58asbjxrnso if I had a file in the same dir I could do (load (merge-pathnames *load-pathname* "foo.lisp"))
09:58asbjxrn(paraphrased.... :)
09:58cgrandrhickey_: just being curious: wouldn't a Reducer interface be an alternative to a lazy? metric (eg (.. s getReducer (reduce f val)) )?
09:59rhickey_asbjxrnL nothing like that yet
09:59asbjxrnI guess this would be outside the scope of a small core, though ...
09:59rhickey_may be something in contrib?
09:59asbjxrnYeah, the library stuff in contrib may be what I want. Haven'
10:00asbjxrnhaven't had a close look yet.
10:00rhickey_cgrand: yes, it's not really laziness, it's - does this support efficient internal reduce
10:01rhickey_part 2 of the talk: http://clojure.blip.tv/file/982957/
10:05cgrandIs it the talk you gave last week?
10:06rhickey_yes
10:06rhickey_all 2:48 of it
10:06rhickey_in 2 parts
14:07Lau_of_DKrhickey, 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:07rhickeyIf I say fixed, it's fixed in SVN as of then
14:08Lau_of_DKSweet
14:13la_merrhickey: 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:14rhickeyI 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:15rhickeyI do emit bytecodes for passing/returning primitives to methods
14:15rhickeybut not arithmetic
14:16Chouser_while you're on the topic, what tool do you use to examine the code the hotspot ends up producing?
14:18rhickeyI 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:18Chouser_ah.
14:18rhickeybut there is some way to get that IIRC
14:25Lau_of_DKHow much does the term "primitive support" cover ?
14:26rhickeyint/float/long/double
14:26rhickeyand arrays of same
14:28Lau_of_DKok, thanks
14:29Lau_of_DKChouser, 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:29cgrandChouser_: I remember having used -XX:+PrintCompilation
14:31Chouser_Java: obj.method( arg1, arg2 ) Clojure: (. obj method arg1 arg2) or (.method obj arg1 arg2)
14:31Lau_of_DKoh I see
14:31Chouser_In your case the method was static, so obj was the classname. Which always confuses me a little.
14:34Lau_of_DKOk, thanks for clearing it up and emphazing :)
14:34Lau_of_DKspell check ? :)
14:37Chouser_cgrand: that's cool!
14:37Chouser_It's not showing me the bytecode, but it's fun to see when stuff gets compiled.
16:47Lau_of_DKVIM 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:48Chouser_I don't bother.
16:48Lau_of_DKwhy not?
16:49Chouser_Generally, I just re-run the repl on the file I'm working on.
16:49Lau_of_DKBut then youre missing out on all the good stuff, like altering the logic while the program is running and all that
16:50Chouser_Well, I sometimes drop a new function into the running repl. That's two mouse strokes.
16:50Lau_of_DKok - Maybe I should just give Vim a twirl
16:50Lau_of_DKIm just used to Emacs by now
16:50Chouser_I'm not claiming my setup it The Best, I'm just telling you what I currently do.
16:51Lau_of_DKBut Im not sure that the clojure-mode and clojure-swank stuff is fully complete
16:51Lau_of_DKI think its acting a bit weird sometimes
16:51Lau_of_DKCompared to something like SBCL, which is just rock solid in this regard
16:58Lau_of_DKAnybody else got that impression?
17:00Lau_of_DKAlright, you guys arent editor reviewers, I got that, lets talk shop
17:00Lau_of_DKLets 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:10Lau_of_DKNo its not for Euler
17:11Chouser_:-) ok, ok.
17:11Lau_of_DKBut there was a lexical permutation problem that I never managed to solve, which posed a similar problem
17:11Lau_of_DKBut I'm really interested in how you do these kind of combinations
17:11Lau_of_DKThis is for a Mastermind solver
17:13Chouser_(def s [:A :B :C :D :E :F]) (for [x1 s x2 s x3 s ...] (prn x1 x2 x3 ...))
17:18Lau_of_DKI think thats a little weird..
17:18Lau_of_DKWhy didnt I think of that?
17:19Chouser_non-repeating combinations are a little more interesting.
17:19Lau_of_DKhow so ?
17:20Chouser_well, the choice for x1 reduces the selection for x2, so it's a little trickier.
17:20Lau_of_DKYea, fortunately, I dont need that now
17:20Lau_of_DK:)
17:20Lau_of_DKBut thanks alot Chouser, you opened my mind a little bit there
17:20Chouser_So what's weird about the "for"?
17:21Lau_of_DKI just imagined that they would all execute in sequence
17:21Lau_of_DKa a a
17:21Lau_of_DKb b b
17:21Lau_of_DKc c c
17:21Lau_of_DKd d d
17:21Lau_of_DK...
17:22Chouser_yeah, the way that "for" sorta nests the sequences surprised me too the first time. But it sure is handy.
17:22Lau_of_DKyea - I remember one time though, where I got the opposite result - dont remember what I did
17:22Lau_of_DKbut thats why I didnt try it
17:22Lau_of_DKI think that was mapping 2 sequences
17:24Chouser_(for [x1 s x2 s x3 s] [x1 x2 x3]) vs. (for [[x1 x2 x3] (map list s s s)] [x1 x2 x3])
17:25Lau_of_DKuser> (map (fn [a b] (list a b)) (range 5) (range 5))
17:25Lau_of_DK((0 0) (1 1) (2 2) (3 3) (4 4))
17:25Lau_of_DKyea, or that type of thing
17:26Chouser_right.
17:26Chouser_(map list (range 5) (range 5))
17:26Lau_of_DKShowing off, will be punished :)
17:26Chouser_;-)
17:28Lau_of_DKOk Chouser, you might recent me for this
17:29Lau_of_DKBut if I want to change def s [:a ...] to an "inifinite" (its not its 1296) stream of lazy-cons...
17:29Lau_of_DKCan you hint me to how I go about it?
17:32Chouser_a stream of what? where are you getting your 1296 data items?
17:32Lau_of_DKif you count all the combinations, its 1296
17:33Lau_of_DKI just need to have a stream I can walk through
17:33Lau_of_DKSo I wanted to do something like when we do fibs
17:34Chouser_This is a lazy seq: (for [x1 s x2 s x3 s] [x1 x2 x3])
17:35Lau_of_DKOh thats right - Unless I force it with doall
17:35Lau_of_DKThanks... :)
17:09Chouser_(defn comb [r m p] (if (> m 0) (mapcat #(comb (disj r %) (dec m) (conj p %)) r) [p]))
17:09Chouser_(comb #{1 2 3 4 5} 3 [])
17:21Lau_of_DKwow
17:21Lau_of_DKthats REALLY nasty Chouser
17:25Lau_of_DKThats going in my toolbox
17:25Lau_of_DKWhen does your tutorial site launch Chouser ?
17:25Chouser_It's here, live, right now. ;-)
17:26Lau_of_DKHehe, cheap skank
17:26Chouser_Lau_of_DK: are you in Europe?
17:26Lau_of_DKDenmark to be exact
17:28Chouser_hm, that won't work if any of the items are duplicated.
17:28Chouser_...since a set can't hold dups.
17:29Lau_of_DKright, then it just discards it
17:30Lau_of_DKWhy 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:31Chouser_There's a little thing in Chicago next Friday -- just wondered how close you are.
17:32Chouser_To which the answer is "not very".
17:32Lau_of_DKtrue
17:58Lau_of_DKI gotta hit the sack - Again Chouser, you've been a great help, thanks! :)