(defn take-until "Returns a lazy sequence of successive items from coll until (pred item) returns true, including that item. pred must be free of side-effects." [pred coll] (lazy-seq (when-let [s (seq coll)] (if (pred (first s)) (cons (first s) nil) (cons (first s) (take-until pred (rest s)))))))
(take-until zero? [1 2 0 3]) => (1 2 0)
--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.
(take-until zero? [1 2 3 0 4 5 6]) => (1 2 3 0)(drop-until zero? [1 2 3 0 4 5 6]) => (4 5 6)
I am probably Wrong about this but my sense of "-upto" is that it almost sounds index-based ("take up to the third element"), while "-while" and "-until" sound much more predicate-based.
--
--