filter

functionsince v0.0-927 clojure.core/filterEdit
(filter pred)
(filter pred coll)

Details:

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.


See Also:


Source docstring:
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.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn filter
  ([pred]
    (fn [rf]
      (fn
        ([] (rf))
        ([result] (rf result))
        ([result input]
           (if (pred input)
             (rf result input)
             result)))))
  ([pred coll]
   (lazy-seq
    (when-let [s (seq coll)]
      (if (chunked-seq? s)
        (let [c (chunk-first s)
              size (count c)
              b (chunk-buffer size)]
          (dotimes [i size]
              (when (pred (-nth c i))
                (chunk-append b (-nth c i))))
          (chunk-cons (chunk b) (filter pred (chunk-rest s))))
        (let [f (first s) r (rest s)]
          (if (pred f)
            (cons f (filter pred r))
            (filter pred r))))))))