You're viewing version 1.2.0 of drop-while. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

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:2199 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"}
  [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: defn lazy-seq let

Comments top

1 comment(s) for drop-while.

The description of this function is throwing me off. I think it should say: returns a sequence of items from coll dropping the initial items that evaluate to true when passed to pred, once a non-true value is encountered, the rest of the list is returned.

Log in to add a comment.