The Lambda class is a collection of methods to support functional programming. It is ideally used with 'using Lambda' and then acts as an extension to Iterable types.

On static platforms, working with the Iterable structure might be slower than performing the operations directly on known types, such as Array and List.

If the first argument to any of the methods is null, the result is unspecified.

Static methods

staticarray<A> (it:Iterable<A>):Array<A>

Creates an Array from Iterable it.

If it is an Array, this function returns a copy of it.

staticexists<A> (it:Iterable<A>, f:A ‑> Bool):Bool

Tells if it contains an element for which f is true.

This function returns true as soon as an element is found for which a call to f returns true.

If no such element is found, the result is false.

If f is null, the result is unspecified.

staticfilter<A> (it:Iterable<A>, f:A ‑> Bool):List<A>

Returns a List containing those elements of it for which f returned true.

If it is empty, the result is the empty List even if f is null.

Otherwise if f is null, the result is unspecified.

staticfind<T> (it:Iterable<T>, f:T ‑> Bool):Null<T>

Returns the first element of it for which f is true.

This function returns as soon as an element is found for which a call to f returns true.

If no such element is found, the result is null.

If f is null, the result is unspecified.

statichas<A> (it:Iterable<A>, elt:A):Bool

Tells if it contains elt.

This function returns true as soon as an element is found which is equal to elt according to the == operator.

If no such element is found, the result is false.

staticlist<A> (it:Iterable<A>):List<A>

Available on neko, js-node, php

Creates a List form Iterable it.

If it is a List, this function returns a copy of it.

staticmap<A, B> (it:Iterable<A>, f:A ‑> B):List<B>

Available on neko, js-node, php

Creates a new List by applying function f to all elements of it.

The order of elements is preserved.

If f is null, the result is unspecified.