Functions -
lang.table
filter |
Selects the members from a table for which a function returns true.
|
forEach |
Applies a function to each member of a table.
|
get |
Returns the member of table
t with key k .
|
hasKey |
Tests whether
t has a member with key k .
|
iterator |
Returns an iterator over a table.
|
keys |
Returns a list of all the keys of table
t .
|
length |
Returns number of members of a table.
|
map |
Applies a function each member of a table and returns a table of the result.
|
nextKey |
Returns the next available integer key.
|
reduce |
Combines the members of a table using a combining function.
|
remove |
Removes a member of a table.
|
removeAll |
Removes all members of a table.
|
removeIfHasKey |
Removes a member of a table with a given key, if the table has member with the key.
|
toArray |
Returns a list of all the members of a table.
|
Parameters
- t table
-
the table
-
func
function(Type) returns (boolean)
-
a predicate to apply to each member to test whether it should be included
-
Return Type
(table) new table containing members for which
func
evaluates to true
func
is applied to each member of t
.
Parameters
- t table
-
the table
-
func
function(Type) returns (())
-
a function to apply to each member
t
with key k
.
This for use in a case where it is known that the table has a specific key,
and accordingly panics if t
does not have a member with key k
.
Parameters
- t table
-
the table
- k null
-
the key
-
Return Type
(Type) member with key
k
t
has a member with key k
.
Parameters
- t table
-
the table
- k null
-
the key
-
Return Type
(boolean) true if
t
has a member with keyk
entries
function can be used to iterate over the keys and members together.
The keys
function can be used to iterator over just the keys.
Parameters
- t table
-
the table
-
Return Type
(T2) a new iterator object that will iterate over the members of
t
t
.
Parameters
- t table
-
the table
-
Return Type
(null[]) a new list of all keys
Parameters
- t table
-
the table
-
Return Type
(int) number of members in
t
Parameters
- t table
-
the table
-
func
function(Type) returns (Type1)
-
a function to apply to each member
-
Return Type
(table) new table containing result of applying
func
to each member
Parameters
- t table
-
the table with a key of type int
-
Return Type
(int) an integer not yet used as a key This is maximum used key value + 1, or 0 if no key used XXX should it be 0, if the maximum used key value is < 0? Provides similar functionality to auto-increment
Parameters
- t table
-
the table
-
func
function(Type1, Type) returns (Type1)
-
combining function
- initial Type1
-
initial value for the first argument of combining
func
-
Return Type
(Type1) result of combining the members of
t
usingfunc
Parameters
- t table
-
the table
- k null
-
the key
-
Return Type
(Type) the member of
t
that had keyk
This removed the member oft
with keyk
and returns it. It panics if there is no such member.
Parameters
- t table
-
the table
Parameters
- t table
-
the table
- k null
-
the key
-
Return Type
(Type?) the member of
t
that had keyk
, or()
ift
does not have a keyk
Ift
has a member with keyk
, it removes and returns it; otherwise it returns()
.