On Mar 19, 2010, at 12:54 PM, Greg Fodor wrote:
> Very simple function:
>
> (defn map-filter [f coll]
> (map f (filter f (coll)))
You have an extra parenthesis before coll.
> Is there an API function for this that I am missing? For example, it
> is useful for pulling out all values in a list of maps of a certain
> key that is optional:
>
> Clojure=> (map-filter :k [{:a :b :c :d :k :found} {:a :b :c :d}
> {:a :b :c :d :k :other}])
> (:found :other)
I don't think so. But note that you can do the filter after the map, to avoid
applying f twice per element:
(defn map-filter-2 [f coll]
(filter identity (map f coll)))
-Michael
--
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
To unsubscribe from this group, send email to
clojure+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.