Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 95d9943dfb
Fetching contributors…

Cannot retrieve contributors at this time

15 lines (11 sloc) 0.432 kb
(ns examples.lazy-index-of-any)
(defn logging-seq [coll]
(when-let [s (seq coll)]
(do (println "Iterating over" (first s))
(cons (first s) (logging-seq (rest s)))))))
(defn indexed [s] (map vector (iterate inc 0) s (logging-seq s)))
(defn index-filter [pred coll]
(when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx)))
(defn index-of-any [pred coll]
(first (index-filter pred coll)))
Jump to Line
Something went wrong with that request. Please try again.