On Fri, Jan 2, 2009 at 8:09 AM, Perry Trolard <trol...@gmail.com> wrote:

>
> I did something similar using (iterate rest coll), which I called iter-
> rest:
>
> (defn iter-rest
>   "Takes the first (count coll) items from call to (iterate rest
> coll).
>   If passed function as first argument, calls it on each invocation
> of
>   rest, i.e. (iterate #(func (rest %)) coll)."
>   ([coll] (take (count coll) (iterate rest coll)))
>   ([func coll] (take (count coll) (iterate #(func (rest %)) coll))))
>
> user=> (iter-rest (range 3))
> ((0 1 2) (1 2) (2))
>
> I now realize a key difference is that, by using (count coll), iter-
> rest fully realizes anything lazy; for Andrew's lazy version above, I
> second the name "rests."
>
> Perry
> >
>
Okay, great, I'm using it and calling it "rests".  Thanks all.

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to