Acton standard libraryTypes
array
array.tolk standard library file
This module provides additional methods for builtin array type.
Definitions
array<T>.each
fun array<T>.each(self, f: (T -> void)): voidCalls f for every element in the array.
val nums: array<int> = [1, 2, 3];
nums.each(fun(x: int) {
println(x);
});array<T>.map
fun array<T>.map<U>(self, f: (T -> U)): array<U>Returns a new array with f applied to every element.
val nums: array<int> = [1, 2, 3];
val doubled = nums.map<int>(fun(x: int): int { return x * 2; });
// [2, 4, 6]array<T>.filter
fun array<T>.filter(self, f: (T -> bool)): array<T>Returns a new array containing only elements for which f returns true.
val nums: array<int> = [1, 2, 3, 4];
val even = nums.filter(fun(x: int): bool { return x % 2 == 0; });
// [2, 4]Last updated on