Functions

'map
I

Applies a function each member of a map and returns a map of the result.

entries
I

Returns a map containing [key, member] pair as the value for each key.

filter
I

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

forEach
I

Applies a function to each member of a map.

get
I

Returns the member of a map with given key.

hasKey
I

Tests whether a map value has a member with a given key.

iterator
I

Returns an iterator over a map.

keys
I

Returns a list of all the keys of a map.

length
I

Returns number of members of a map.

reduce
I

Combines the members of a map using a combining function.

remove
I

Removes a member of a map.

removeAll
I

Removes all members of a map.

removeIfHasKey
I

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

toArray
I

Returns a list of all the members of a map.

'map

function 'map(map<Type> m,  function(Type) returns (Type1) func) returns map<Type1>
Isolated Function

Applies a function each member of a map and returns a map of the result.

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

Parameters

  • func function(Type) returns (Type1)
  • a function to apply to each member

Return Type

(map<Type1>)

new map containing result of applying function func to each member

entries

function entries(map<Type> m) returns map<[string, Type]>
Isolated Function

Returns a map containing [key, member] pair as the value for each key.

Parameters

Return Type

(map<[string, Type]>)

a new map of [key, member] pairs

filter

function filter(map<Type> m,  function(Type) returns (boolean) func) returns map<Type>
Isolated Function

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

Parameters

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

Return Type

(map<Type>)

new map containing members for which function func evaluates to true

forEach

function forEach(map<Type> m,  function(Type) returns (() ) func) returns () 
Isolated Function

Applies a function to each member of a map.

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

Parameters

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

Return Type

(() )

get

function get(map<Type> m, string k) returns Type
Isolated Function

Returns the member of a map with given key.

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

Parameters

Return Type

(Type)

member with parameter k key

hasKey

function hasKey(map<Type> m, string k) returns boolean
Isolated Function

Tests whether a map value has a member with a given key.

Parameters

Return Type

(boolean)

true if parameter m has a member with key parameter k

iterator

function iterator(map<Type> m) returns object {
    public isolated function next() returns record {|
        Type value;
    |}?;
} 
Isolated Function

Returns an iterator over a map.

The iterator will iterate over the members of the map not the keys. The function entries can be used to iterate over the keys and members together. The function keys can be used to iterator over just the keys.

Parameters

Return Type

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

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

keys

function keys(map<any | error> m) returns string[ ]
Isolated Function

Returns a list of all the keys of a map.

Parameters

Return Type

(string[ ])

a new list of all keys

length

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

Returns number of members of a map.

Parameters

Return Type

(int)

number of members in parameter m

reduce

function reduce(map<Type> m,  function(Type1, Type) returns (Type1) func, Type1 initial) returns Type1
Isolated Function

Combines the members of a map using a combining function.

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

Parameters

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

Return Type

(Type1)

result of combining the members of parameter m using function func

remove

function remove(map<Type> m, string k) returns Type
Isolated Function

Removes a member of a map.

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

Parameters

Return Type

(Type)

the member of parameter m that had key parameter k

removeAll

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

Removes all members of a map.

This panics if any member cannot be removed.

Parameters

Return Type

(() )

removeIfHasKey

function removeIfHasKey(map<Type> m, string k) returns Type?
Isolated Function

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

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

Parameters

Return Type

(Type?)

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

toArray

function toArray(map<Type> m) returns Type[ ]
Isolated Function

Returns a list of all the members of a map.

Parameters

Return Type

(Type[ ])

an array whose members are the members of parameter m