τau /

maps

module
maps = import("maps")

maps - operations on maps and objects.

Reading a missing key gives null, which is indistinguishable from a null stored on purpose: Has answers that question, Get gives a default.

Has = fn(m, k)source

Has reports whether m holds the key k.

Get = fn(m, k, def)source

Get returns m[k], or def if the key is absent.

Keys = fn(m)source

Keys returns the keys of m. Works on objects too, where they are the names of the fields.

Values = fn(m)source

Values returns the values of m, in the same order as Keys.

Len = fn(m)source

Len returns the number of entries.

Each = fn(m, f)source

Each calls f(key, value) for every entry.

Merge = fn(a, b)source

Merge returns a new map with the entries of a and b, those of b winning.

Equal = fn(a, b)source

Equal reports whether two maps hold the same entries.