On Oct 21, 9:14 pm, John Harrop <[email protected]> wrote:
> You probably therefore want this instead:
>
> (defn multi-filter [filters coll]
> (let [c (count filters)
> ignore (Object.)]
> (map
> (fn [i]
> (remove #(= % ignore)
> (take-nth c
> (drop i
> (mapcat #(map (fn [p e] (if (p e) e ignore)) filters (repeat c
> %)) coll)))))
> (range c))))
Good idea, thanks!
I had to modify it because it was generating a separate "merged-seq"
per filter:
(defn multi-filter [filters coll]
(let [c (count filters)
ignore (Object.)
merged-seq
(mapcat
(fn [k]
(map
(fn [p e]
(if (p e) e ignore))
filters (repeat c k)))
coll)]
(map
(fn [i]
(remove #(= % ignore)
(take-nth c
(drop i
merged-seq))))
(range c))))
Very cool (and lazy)!
- Dmitry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
-~----------~----~----~----~------~----~------~--~---