drop-while

clojure.core

  • (drop-while pred coll)
Returns a lazy sequence of the items in coll starting from the first
item for which (pred item) returns nil.

1 Example top

  • ;; Note: Documentation should be "starting from the first item for which
    ;; (pred item) returns logical false, i.e. either of the values false or nil.
    
    user=> (drop-while neg? [-1 -2 -6 -7 1 2 3 4 -5 -6 0 1])
    (1 2 3 4 -5 -6 0 1)
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2543 top

(defn drop-while
  "Returns a lazy sequence of the items in coll starting from the first
  item for which (pred item) returns nil."
  {:added "1.0"
   :static true}
  [pred coll]
  (let [step (fn [pred coll]
               (let [s (seq coll)]
                 (if (and s (pred (first s)))
                   (recur pred (rest s))
                   s)))]
    (lazy-seq (step pred coll))))
Vars in clojure.core/drop-while:
Used in 0 other vars

Comments top

No comments for drop-while. Log in to add a comment.