Skip to content

clojure.core/reverse

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 3 Runnable: 2
([coll])

Returns a seq of the items in coll in reverse order. Not lazy.

Examples

by gstamp on
by rosineygp on
by Crowbrammer on . May have evaluation errors.

Note by gstamp

If you've got a vector rseq is a good option instead of reverse.

Note by Crowbrammer

For vectors, rseq is to reverse what peek is to last. rseq reverses in constant time (!) where reverse is in linear time, as it appears to pull everything into a new seq, one at a time instead of ... reversing the keys? I don't know the implementation details, but I do know that rseq is magnitudes faster than reverse for vectors and sorted maps.

See also


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