clojure.core/filter¶
Returns a lazy sequence of the items in coll for which (pred item) returns logical true. pred must be free of side-effects. Returns a transducer when no collection is provided.
Examples¶
Note by brunchboy¶
Although the documentation states that the predicate must be free of side effects, it would be more accurate to say that you should not rely on filter to induce side effects that may be caused by the predicate, nor on the timing of when the predicate will be evaluated, because of the lazy and chunked nature of filter.
Note by mattiasw2¶
Note that filtering a map will not create a map. If you want to do a lookup on the result, you need to surround the call to filter with (into {} (filter ...))
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.