$ reduce(@|&, &closure)

Applies &closure to the first two elements of the specified array or closure. The resulting value is then applied to the next value of the specified array or closure, so on and so forth. Returns one value.


@|& - this argument can be an array or a closure. if an array is specified the array is considered done when it returns $null.

&closure - the function to apply to each element of the specified array or closure.


A single scalar value that is a reduction of the specified closure or array.


@a = @(99, 8, 7, 65, 100, 33); # calculate the minimum value of @a $min = reduce({ return iff($1 < $2, $1, $2); }, @a); println("The minimum value of @a is: $min");

The minimum value of @a is: 7

See Also