clojure.core/array-map¶
Constructs an array-map. If any keys are equal, they are handled as if by repeated uses of assoc.
Examples¶
Note by Jacolyte¶
The definition is kind of short, IMO. More descriptively, array-map creates a mapping with arrays being the keys and the values. It doesn't seem like array-map cares whether or not the keys/values are arrays, although it doesn't seem to like sequences.
Note by steveminer¶
An array-map maintains the insertion order of the keys. Look up is linear, which is not a problem for small maps (say less than 10 keys). If your map is large, you should use hash-map instead.
When you assoc onto an existing array-map, the result is a new array-map with the new key as the first key. The rest of the keys are in the same order as the original. Functions such as seq and keys will respect the key order.
Note that assoc will decide to return a hash-map if the result is too big to be efficient.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.