i put this at the end of my boot.clj for added fun:

(defn iterate
  "returns a lazy seq of arg1, arg2 ... argn, (f arg1 ... argn), (f
arg2 ... argn (f arg1 ... argn)), etc."
  [f & [x & rest :as all]]
  (lazy-cons x (apply iterate f (concat rest [(apply f all)]))))


user=> (take 10 (iterate + 1 1))
(1 1 2 3 5 8 13 21 34 55)

user=> (take 4 (iterate #(* % %) 2))
(2 4 16 256)

is this good as a contrib? is there a better way to implement this?
also, this language is delightful.
--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to