take-while

functionsince v0.0-927 clojure.core/take-whileEdit
(take-while pred)
(take-while pred coll)

Details:

Returns a lazy sequence of successive items from coll while (pred item) returns 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 successive items from coll while
(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 take-while
  ([pred]
     (fn [rf]
       (fn
         ([] (rf))
         ([result] (rf result))
         ([result input]
            (if (pred input)
              (rf result input)
              (reduced result))))))
  ([pred coll]
     (lazy-seq
       (when-let [s (seq coll)]
         (when (pred (first s))
           (cons (first s) (take-while pred (rest s))))))))