Hi

 user=> (def primes

>   (cons 2
>     (filter
>       (fn isprime[n]
>
>         (every?
>           #(pos? (mod n %))
>           (take-while #(<=(* % %)n) primes)))
>       (iterate inc 3))))
> user=> (take 50 primes)
> (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 
> 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 
> 197 199 211 223 227 229)
>
 
 Is it really necessary to call 'take-while' ? The version without it

(def primes
  (cons 2
    (filter
      (fn isprime? [n]
        (every? #(pos? (mod n %)) primes))
      (iterate inc 3))))

works for me as well. Is it safe to use this version or is using 
'take-while' for some reason necessary ?

maclo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to