Functions

'map
I

Applies a function to each member of a table and returns a table of the result.

add
I

Adds a member to a table.

filter
I

Selects the members from a table for which a function returns true.

forEach
I

Applies a function to each member of a table.

get
I

Returns the member of an table with a particular key.

hasKey
I

Tests whether a table has a member with a particular key.

iterator
I

Returns an iterator over a table.

keys
I

Returns a list of all the keys of a table.

length
I

Returns number of members of a table.

nextKey
I

Returns the next available integer key.

put
I

Adds a member to a table value, replacing any member with the same key value.

reduce
I

Combines the members of a table using a combining function.

remove
I

Removes a member of a table.

removeAll
I

Removes all members of a table.

removeIfHasKey
I

Removes a member of a table with a given key, if the table has member with the key.

toArray
I

Returns a list of all the members of a table.

'map

function 'map(table<MapType>  t,  function(MapType) returns (MapType1) func) returns table<MapType1> key<never> 
Isolated Function

Applies a function to each member of a table and returns a table of the result.

Parameters

  • t table<MapType>
  • the table

  • func function(MapType) returns (MapType1)
  • a function to apply to each member

Return Type

(table<MapType1> key<never> )

new table containing result of applying function func to each member

add

function add(table<MapType>  t, MapType val)
Isolated Function

Adds a member to a table.

It will be added as the last member. It panics if parameter val has the same key as an existing member of parameter t, or if parameter val is inconsistent with the inherent type of t.

Parameters

  • t table<MapType>
  • the table

filter

function filter(table<MapType> key<KeyType>  t,  function(MapType) returns (boolean) func) returns table<MapType> key<KeyType> 
Isolated Function

Selects the members from a table for which a function returns true.

The resulting table will have the same keys as the argument table.

Parameters

  • t table<MapType> key<KeyType>
  • the table

  • func function(MapType) returns (boolean)
  • a predicate to apply to each member to test whether it should be included

Return Type

(table<MapType> key<KeyType> )

new table containing members for which function func evaluates to true

forEach

function forEach(table<MapType>  t,  function(MapType) returns (() ) func) returns () 
Isolated Function

Applies a function to each member of a table.

The function func is applied to each member of parameter t.

Parameters

  • t table<MapType>
  • the table

  • func function(MapType) returns (() )
  • a function to apply to each member

Return Type

(() )

get

function get(table<MapType> key<KeyType>  t, KeyType k) returns MapType
Isolated Function

Returns the member of an table with a particular key.

This for use in a case where it is known that the table has a specific key, and accordingly panics if parameter t does not have a member with key parameter k.

Parameters

  • t table<MapType> key<KeyType>
  • the table

Return Type

(MapType)

member with key parameter k

hasKey

function hasKey(table<MapType> key<KeyType>  t, KeyType k) returns boolean
Isolated Function

Tests whether a table has a member with a particular key.

Parameters

  • t table<MapType> key<KeyType>
  • the table

Return Type

(boolean)

true if parameter t has a member with key parameter k

iterator

function iterator(table<MapType>  t) returns object {
    public isolated function next() returns record {|
        MapType value;
    |}?;
} 
Isolated Function

Returns an iterator over a table.

The iterator will iterate over the members of the table not the keys. The 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<MapType>
  • the table

Return Type

(object { public isolated function next() returns record {| MapType value; |}?; } )

a new iterator object that will iterate over the members of parameter t

keys

function keys(table<map<any|error>> key<KeyType>  t) returns KeyType[ ]
Isolated Function

Returns a list of all the keys of a table.

Parameters

  • t table<map<any|error>> key<KeyType>
  • the table

Return Type

(KeyType[ ])

a new list of all keys

length

function length(table<map<any|error>>  t) returns int
Isolated Function

Returns number of members of a table.

Parameters

  • t table<map<any|error>>
  • the table

Return Type

(int)

number of members in parameter t

nextKey

function nextKey(table<MapType> key<int>  t) returns int
Isolated Function

Returns the next available integer 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<MapType> key<int>
  • the table with a key of type int

Return Type

(int)

an integer not yet used as a key

put

function put(table<MapType>  t, MapType val)
Isolated Function

Adds a member to a table value, replacing any member with the same key value.

If parameter val replaces an existing member, it will have the same position in the order of the members as the existing member; otherwise, it will be added as the last member. It panics if parameter val is inconsistent with the inherent type of parameter t.

Parameters

  • t table<MapType>
  • the table

reduce

function reduce(table<MapType>  t,  function(Type, MapType) returns (Type) func, Type initial) returns Type
Isolated Function

Combines the members of a table using a combining function.

The combining function takes the combined value so far and a member of the table, and returns a new combined value.

Parameters

  • t table<MapType>
  • the table

  • initial Type
  • initial value for the first argument of combining function func

Return Type

(Type)

result of combining the members of parameter t using function func

remove

function remove(table<MapType> key<KeyType>  t, KeyType k) returns MapType
Isolated Function

Removes a member of a table.

This removed the member of parameter t with key parameter k and returns it. It panics if there is no such member.

Parameters

  • t table<MapType> key<KeyType>
  • the table

Return Type

(MapType)

the member of parameter t that had key parameter k

removeAll

function removeAll(table<map<any|error>>  t) returns () 
Isolated Function

Removes all members of a table.

This panics if any member cannot be removed.

Parameters

  • t table<map<any|error>>
  • the table

Return Type

(() )

removeIfHasKey

function removeIfHasKey(table<MapType> key<KeyType>  t, KeyType k) returns MapType?
Isolated Function

Removes a member of a table with a given key, if the table has member with the key.

If parameter t has a member with key parameter k, it removes and returns it; otherwise it returns ().

Parameters

  • t table<MapType> key<KeyType>
  • the table

Return Type

(MapType?)

the member of parameter t that had key parameter k, or () if parameter t does not have a key parameter k

toArray

function toArray(table<MapType>  t) returns MapType[ ]
Isolated Function

Returns a list of all the members of a table.

Parameters

  • t table<MapType>
  • the table

Return Type

(MapType[ ])

an array whose members are the members of parameter t