Skip to content

clojure.core/set

View this page on ClojureDocs

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

Returns a set of the distinct elements of coll.

Examples

by MrHus on
by boxie on . May have evaluation errors.

Note by icefox

The documentation doesn't mention the order, is it undefined?

{:a :b :c :d}

-> #{:d :a :b :c}

Note by venantius

Sets are a core data structure that by definition do not store elements in a sorted order. The actual order will ultimately be determined by the specific hashing function underpinning the data structure.

Note by dhbarnett

Is the order guaranteed to be consistent if so is it not ordered (just not asc/desc)?

Note by bfontaine

Sets are not ordered, so there’s not guarantee on their “order”.

See also


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