langur

hashes

These could also be called hashes, maps, or associative lists. There is no guaranteed order of elements.

Hash literals are built with an h token and a comma-delimited key/value pair list, using a colon between each key and value. They are enclosed with curly braces.

h{1: "first", 2: "second"} h{"abc": 123, "def": 789}

Hashes may use strings or numbers for keys. Different key types may be used in the same hash.

Indexing a hash with 1.0 is the same as indexing with 1. (Numbers are simplified for hash keys.)

Hashes may contain any other langur data structures, and they may be mixed freely.

Hashes may be appended with the concatenation operator (tilde). Concatenation overwrites values for existing keys in the left operand with values having the same keys in the right operand.

h{1: "first", 2: "second"} ~ h{3: "third", 2: "new second"}

To add hashes together, but error out on duplicate keys, use the more() function.

more h{1: "first", 2: "second"}, h{3: "third", 2: "new second"} # throws exception because key 2 in each hash

The keys(), haskey(), map(), more(), and less() functions may be useful in dealing with hashes.