function | since v0.0-927 | clojure.core/take-last | Edit |
(take-last n coll)
Returns a sequence of the last n
items in coll
.
Depending on the type of collection, take-last
may be no faster than linear
time. For vectors, please use subvec
.
Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec.
(defn take-last
[n coll]
(loop [s (seq coll), lead (seq (drop n coll))]
(if lead
(recur (next s) (next lead))
s)))