Skip to content

clojure.core/take-last

View this page on ClojureDocs

Type: function Added: Clojure 1.1 Examples: 2 Runnable: 1
([n coll])

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.

Examples

by gstamp on
by tomdl89 on . May have evaluation errors.

Note by reborg

Unlike "drop-last" (but like "last"), "take-last" is not lazy:

(def bomb (take-last 1 (range))) ;; infinite evaluation, never returns
(def lazy-bomb (drop-last 1 (range))) ;; good, but don't use!

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.