shortcut for for comprehension

2009-04-20 Thread Michael Hunger
Is it possible to use :while to shortcut a for macro when a certain number of yiels have happened? e.g. (for [x (range 1000) :when (= (rem x) 1) :while (number of yields <= 10)] so i want only the first 10 results. Or should I just use (take 10 ) on the for ? Michael --~--~-~--~~

Re: Help Improving Game Of Life in clojure

2009-04-19 Thread Michael Hunger
Thanks for the great feedback. Michael Am 19.04.2009 11:33 Uhr, schrieb Timothy Pratley: > Hi Michael, > > Larry recently posted something similar > http://groups.google.com/group/clojure/browse_thread/thread/773e628953b40d9f > Which generated also quite a lot of discussion which you might also

Help Improving Game Of Life in clojure

2009-04-18 Thread Michael Hunger
As I'm currently trying to learn clojure I wrote a game of life to get a feeling for the concepts. It would be great if some of you could point out areas for improvement or unused idioms or patterns. Thanks alot Michael here is the code: (ns gol) (comment "a board only contains the coordinate

Re: #(%) error in map

2009-04-18 Thread Michael Hunger
I think my misconception was not the missing identiy fun but rather that the first element in the list is the function that is evaluated. so #(%) is trying to evaluate whatever % evaluates to, e.g. (1) and therefore there is the java.lang.ClassCastException: java.lang.Integer cannot be cast to

#(%) error in map

2009-04-18 Thread Michael Hunger
I tried to use an anonymous function in map but it didn't work. user=> (map #(%) '(1 2 3)) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn but with a normal anonymous function it works as expected: user=> (map (fn [x] x) '(1 2 3)) (1 2 3) Thanks Michael P.S