W Wrapl, The Programming Language

Libraries Agg.Table

Types

T

A table of Key/Value pairs

NodeType

A single Key/Value pair

Functions

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

Returns a table consisting of the values returned by func(args) 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 intersection of a and b, i.e. those (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 difference of a and b, i.e. those (Key, Value) pairs of a where Key is not in b.

:"."(_ @ T, _)

:"="(_ @ T, _ @ T, _ @ Agg.ObjectTable.T)

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

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

Returns the Hash function used in t.

:"[]"(t @ T, Key, default)

Returns the Value associated with Key in t.

If Key is not present, a new pair (Key, default) is created and default is returned.

:"[]"(t @ T, Key)

Returns the Value associated with Key in t.

:check(t @ T, Key, default)

Returns the Value associated with Key in t.

If Key is not present, a new pair (Key, default) is created and the call fails.

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

Returns the comparison function used in t.

:copy(t @ T) : T

Returns a shallow copy of t

:deffun(t @ T, default)

Sets the default function to create a Value when a Key is not present

:defval(t @ T, default)

Sets the default Value to return when a Key is not present

:delete(t @ T, Key) : T

Removes the Key from t.

:empty(t @ T) : T

Removes all entries from t and returns it.

:find(table @ T, Value) : ANY

Generates the all keys in table which has Value Value.

:in(Key, table @ T)

Returns Key if it is a Key in table, fails otherwise.

:insert(_ @ 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

value+

Generates the keys in t while assigning the corresponding value to value.

:keys(t @ T) : ANY

Generates the keys in t.

:list(t @ T, func @ Std.Function.T) : T

Returns the list func(Key, Value) running over all pairs in t.

:loop(t @ T, Key+, Value+)

For each (Key, Value) in t, generates NIL after assigning Key and Value.

:map(t @ T, func @ Std.Function.T) : T

Returns a copy of t with the same keys, but with values returned by calling func(Key, Value)

:missing(t @ T, Key)

If Key is present in t then fail, after assigning the current Value to var if provided.

Otherwise, inserts the pair (Key, NIL) into t and returns an assignable reference.

:modify(t @ T, Key, mod @ Std.Function.T) : T

Modifies the Value associated with Key, t[Key] <- mod($).

Uses the default Value of t if Key is not present and a default has been set.

: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.

:remove(t @ T, Value) : T

Removes the first Key found with Value Value.

:remove_all(t @ T, func @ Std.Function.T) : T

Removes the first (Key, Value) pair for which func(Key, Value) succeeds.

:remove_if(t @ T, func @ Std.Function.T) : T

Removes the first (Key, Value) pair for which func(Key, Value) succeeds.

: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, key+) : ANY

Generates the values in t while assigning the corresponding key to key.

:values(t @ T) : ANY

Generates the values in t.