function | since v0.0-927 | clojure.core/first | Edit |
(first coll)
Returns the first item in coll
and calls seq
on its argument.
Returns nil when coll
is nil.
(first [1 2 3])
;;=> 1
(first [])
;;=> nil
Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil.
(defn first
[coll]
(when-not (nil? coll)
(if (implements? ISeq coll)
(-first coll)
(let [s (seq coll)]
(when-not (nil? s)
(-first s))))))