slightly cleaner version of drop-while, could use yield-from when ready
This commit is contained in:
parent
399ea1889a
commit
9d2ad4b4ff
@ -63,12 +63,11 @@
|
|||||||
(defn drop-while [pred coll]
|
(defn drop-while [pred coll]
|
||||||
"Drop all elements of `coll` until `pred` is False"
|
"Drop all elements of `coll` until `pred` is False"
|
||||||
(let [[citer (iter coll)]]
|
(let [[citer (iter coll)]]
|
||||||
(let [found false]
|
(for [val citer]
|
||||||
(for [val citer]
|
(if (not (pred val))
|
||||||
(if (not (pred val))
|
(do (yield val) (break))))
|
||||||
(setv found true))
|
(for [val citer]
|
||||||
(if found
|
(yield val))))
|
||||||
(yield val))))))
|
|
||||||
|
|
||||||
(defn empty? [coll]
|
(defn empty? [coll]
|
||||||
"Return True if `coll` is empty"
|
"Return True if `coll` is empty"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user