function | since v0.0-927 | clojure.core/last | Edit |
(last s)
Returns the last item in coll
in linear time.
peek
is much faster than last
for a vector.
(last [1 2 3])
;;=> 3
(last [1 2])
;;=> 2
(last [1])
;;=> 1
(last [])
;;=> nil
Return the last item in coll, in linear time
(defn last
[s]
(let [sn (next s)]
(if-not (nil? sn)
(recur sn)
(first s))))