The design of Motoko strives to minimize built-in operations, and whenever possible, to instead implement array operations as Motoko functions in a standard library module dedicated to extending that type’s suite of supported operations.
Applies an array of functions to an array of arguments. The arrays must be of equal length.
public func apply<A, B>(fs : [A -> B], xs : [A]) : [B]
Applies a function to each array element to produce an array of all results.
public func bind<A, B>(xs : [A], f : A -> [B]) : [B]
Folds left over the array.
public func foldl<A, B>(f : (B, A) -> B, initial : B, xs : [A]) : B
Folds right over the array.
public func foldr<A, B>(f : (A, B) -> B, initial : B, xs : [A]) : B
Converts an array of arrays into a single (flattened) array.
public func join<A>(xs : [[A]]) : [A]
Maps each array element by the given mapping function.
public func map<A, B>(f : A -> B, xs : [A]) : [B]