counted?

added
1.0

ns
clojure.core

type
function

(counted? coll)

Returns true if coll implements count in constant time

                user=> (counted? [:a :b :c])
true

user=> (counted? '(:a :b :c))
true

user=> (counted? {:a 1 :b 2 :c 3})
true

user=> (counted? #{:a :b :c})
true

user=> (counted? "asdf")
false

user=> (counted? (into-array Integer/TYPE [1 2 3]))
false
            
                ;; Lazy sequences are not counted?
(counted? (map inc (range 5)))
;;=> false