Paul  Mooser <taron...@gmail.com> writes:

Hi Paul,

> If you search for "filter" and "StackOverflowError" in this group, you
> will find people discussing related issues.

Thanks, I've found some explanation by Meikel Brandmeier who explains
the layering issue.  But do we really have to live with that?

I mean, replacing the filter/remove with a list comprehension solved the
issue for me.  And it's easy to define filter in terms of for.

--8<---------------cut here---------------start------------->8---
user> (defn philter [pred coll]
        (for [x coll :when (pred x)] x))
#'user/philter
user> (filter even? (take 10 (iterate inc 0)))
(0 2 4 6 8)
user> (philter even? (take 10 (iterate inc 0)))
(0 2 4 6 8)
--8<---------------cut here---------------end--------------->8---

I've tried benchmarking filter vs. philter with seqs of different sizes,
and there seems to be no difference.  So why not simply do it that way?

Bye,
Tassilo

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