function | since v1.9.85 | clojure.core/bounded-count | Edit |
(bounded-count n coll)
If coll is counted? returns its count, else will count at most the first n elements of coll using its seq
(defn bounded-count
{:added "1.9"}
[n coll]
(if (counted? coll)
(count coll)
(loop [i 0 s (seq coll)]
(if (and (not (nil? s)) (< i n))
(recur (inc i) (next s))
i))))