Re: Matlab for Lisp programmers?

2009-09-12 Thread Max Suica
I've been playing with matlab, and I'm liking it... the built in documentation on the language is actually excellent, and the language itself is pretty clean if you're used to java/c/algol type languages. I like especially the built in syntax for matrix and tensor operations, and the fact that

Re: Clojure in Computing in Science and Engineering

2009-06-18 Thread Max Suica
On Jun 18, 2:00 am, Konrad Hinsen konrad.hin...@laposte.net wrote: The July/August issue of the IEEE magazine Computing in Science and   Engineering has an introduction to functional programming for   scientists that uses Clojure for the examples. It is already   available (a bit in advance

Re: accum

2009-06-17 Thread Max Suica
Wrexsoul, please mate, these are good guys. Remember the beauty and tradition of the language you're learning. It's a lisp and gives you the power to effortlessly create almost any abstraction you can imagine. Not being convinced of the beauty of this, open you mind a bit and humble yourself some

Re: breaking early from a tight loop

2009-06-14 Thread Max Suica
Laurent, I think this is a close variant of the early exiting reduce function you proposed: (defn reduce-bail [f pred? val col] (let [s (seq col)] (if s (if (pred? val) (recur f pred? (f val (first s)) (next s)) val)

Re: breaking early from a tight loop

2009-06-14 Thread Max Suica
On Jun 14, 5:04 am, Max Suica max.su...@gmail.com wrote: (defn interesting? [pixels in-range? count]   (let [p-count (reduce-bail (fn [c p] (if (in-range? p) (inc c) c)) (partial count) 0 pixels)]   [( = count yummy-pix-count) p-count])) Shoot: s/[( = count yummy-pix-count) p-count

Re: breaking early from a tight loop

2009-06-14 Thread Max Suica
A lazy right fold[1] allows short-circuiting, so here's one attempt: Wow, that made my head explode. Some points: 1) That's not exatly foldr, as (foldr + 0 [range 100]) ought to work 2) Foldr is not tail recursive nor can you really call an anamorphism lazy 3) Never the less you did it,

Re: breaking early from a tight loop

2009-06-14 Thread Max Suica
I'm sorry, folds are catamorphisms, while stuff like (repeatedly f) or (repeat n x) are anamorphisms, and can certainly be lazy. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: Wish: (- x) should be legal

2009-06-05 Thread Max Suica
Oh! Sweet : ) On Jun 4, 6:29 pm, Stephen C. Gilardi squee...@mac.com wrote: On Jun 4, 2009, at 5:56 PM, Max Suica wrote: But (- x identity) = (identity x) = x, so what our friend ozzi suggest sounds pretty on the level. If (identity x) is not equivalent to evaluating x, then, well

Re: Help with Math Question

2009-06-04 Thread Max Suica
I'm not sure how you're compositing your colors, but the function you're using is not associative or commutative (I checked at lunch, mmm), so I don't think you can reverse order. It's: a + b = (b1 + a1 (1 - b2), a2) Your function might need to be something like a + b = (b1*(1 - a2) + a1 (1

Re: Wish: (- x) should be legal

2009-06-04 Thread Max Suica
But (- x identity) = (identity x) = x, so what our friend ozzi suggest sounds pretty on the level. If (identity x) is not equivalent to evaluating x, then, well, that's not the identity function :) --~--~-~--~~~---~--~~ You received this message because you are

Re: You know you've been writing too much Clojure when...

2009-06-02 Thread Max Suica
people in math discussions raise their eyebrow at my new comma-less tuple and set notation: (a_1 a_2 ... a_n a_(n+1) .. ) in R^|N| {1 2 3 4 5} = {a in N+ | a 6} Haskel hated it that time I wrote: fold:: (b a b) b [a] or sum x y zs = fold (+) 0 x:y:zs, where: sum 1 2 3 4 5 6 7 = haskell

Re: Currying / Partial Application macro

2009-05-31 Thread Max Suica
On May 31, 1:55 am, Daniel Lyons fus...@storytotell.org wrote: On May 30, 2009, at 7:25 PM, kinghajj wrote: On May 30, 1:19 pm, Daniel Lyons fus...@storytotell.org wrote: You can't have both partial application and variable arity functions. Uh, yeah you can. Haskell can have variadic

Re: Currying / Partial Application macro

2009-05-29 Thread Max Suica
Bleh, I've been completely wrong about what currying does. Here's a correct definition: (defn curry [f] (fn [a] (fn [b] (f a b)) So curry basically takes a fn f that normally operates on a pair, and creates an fn that partially applies f to an argument. That function in turn will complete

Re: Currying / Partial Application macro

2009-05-28 Thread Max Suica
Hey, here's a hacked together curry function that does it somewhat like haskell, in pseudo-code. Can you guys help me correct it? (defn curry [f args1] (cond (= (arity f ) (count args)) (apply f args1) (fixed? (arity f) (fn [ args2] (curry (apply partial f args1) args2)

Re: Clojure equivalent to Ruby's ERB

2009-05-27 Thread Max Suica
I think you could do a hack using macros and eval at runtime in order to expand them into your code, but I think one of the fellas in the chat room said to be wary if that's the only approach I can see to a problem, because it's easy to screw up, and not entirely good practice. Btw, does clojure

Re: ANN: Full, continuously updated documentation for clojure.contrib

2009-05-24 Thread Max Suica
Hey, is there such a wiki/doc for core clojure? The wiki for clojure- contrib's project page is so nice, but clojure's wiki has very little. Heh, I've been using clj-doc to make my own reference for it, but the wiki is a lot prettier. It would be nice to generate one for core. I've looked at the