Except your version of filter doesn't do any filtering on the rest in
the case where the first satisfies the predicate.

On Sat, Dec 6, 2008 at 7:43 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
> If you use a definition of filter like this in your test, I think it will
> succeed:
>
> (defn filter-iter
>  [pred coll]
>  (when (seq coll)
>    (if (pred (first coll))
>      [(first coll) (rest coll)]
>      (recur pred (rest coll)))))
>
> (defn filter
>  "Returns a lazy seq of the items in coll for which
>  (pred item) returns true. pred must be free of side-effects."
>  [pred coll]
>  (let [result (filter-iter pred coll)]
>    (when result
>      (lazy-cons (result 0) (result 1)))))
>
> --Steve
>
>

--~--~---------~--~----~------------~-------~--~----~
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