ClojureDocs

导航

名称空间

drop-while

clojure.core

自 1.0 起可用 ()
  • (drop-while pred)
  • (drop-while pred coll)
Returns a lazy sequence of the items in coll starting from the
first item for which (pred item) returns logical false.  Returns a
stateful transducer when no collection is provided.
2 Examples
;; 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)
(def my-vec [1 2 3 4 5 6])

(drop-while #(> 3 %) my-vec)
;;(3 4 5 6)

(drop-while #(>= 3 %) my-vec)
;;(4 5 6)

;;Returns a lazy sequence of the items in coll starting from the
;;first item for which (pred item) returns logical FALSE
See Also

Returns a lazy sequence of successive items from coll while (pred item) returns logical true. pred...

Added by pauldoo

Returns a vector of [(take-while pred coll) (drop-while pred coll)]

Added by dansalmo

Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is...

Added by huahaiy
1 Note
    By , created 14.8 years ago

    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.