Wrapl, The Programming Language

Libraries/Std/Table

Types

T

A table of key/value pairs

NodeType

A single key/value pair

Functions

Collect(func @ Std.Function.T) : T

Returns a table consisting of the values returned by func as keys (and NIL as each value).

Make() : T

Returns a new table with the arguments taken as alternating key/value pairs.

New(comp @ Std.Function.T = :?, hash @ Std.Function.T = :#) : T

Returns a new table with comparison function comp and hash function hash.

comp(a, b) should return -1, 0 or -1 if a < b, a = b or a > b respectively.

hash(a) should return a Std.Integer.SmallT.

NewIdentity() : T

Returns a new table in which two keys are the same only if they are the same object.

Methods

:*(a @ T, b @ T) : T

Returns the (key, value) pairs of a where key is in b.

:+(a @ T, b @ T) : T

Returns the union of a and b. If a key exists in both a and b then the value is taken from b.

:-(a @ T, b @ T) : T

Returns the (key, value) pairs of a where key is not in b.

:@(_ @ T, _ = Std.String.T)

:[](t @ T, key)

Returns the value associated with key in t.

:compare(t @ T) : Std.Function.T

Returns the comparison function used in t.

:copy(t @ T) : T

Returns a shallow copy of t

:delete(t @ T, key) : T

Removes the key from t.

:empty(t @ T) : T

Removes all entries from t and returns it.

:hash(t @ T) : Std.Function.T

Returns the hash function used in t.

:insert(t @ T, key) : T

Inserts the pair (key, value) into t.

:items(t @ T) : NodeT

Generates the (key, value) pairs in t.

:key(node @ NodeType) : ANY

Returns key from a (key, value) pair.

:keys(t @ T) : ANY

Generates the keys in t.

:loop(t @ T, key, value)

For each (key, value) in t, generates NIL after assigning key and value.

:newv(type @ Std.Type.T, fields @ T) : ANY

Creates a new instance instance of type and for each (key, value) pair in fields, sets key(instance) <- value. Returns instance.

Each key should be a Std.Symbol.T.

:size(t @ T) : Std.Integer.SmallT

Returns the number of entries in t.

:value(node @ NodeType) : ANY

Returns value from a (key, value) pair.

:values(t @ T) : ANY

Generates the values in t.