Methods

eachΒΆ

each(arr:Arr, n:Int, cb:Fun)

Process each N elements of an Array at a time. Throws InvalidArgument if number of items in arr is not divisible by n. cb is called as cb(eltI, ..., eltJ) where I is multiple of n and J is I+n-1
Source: stdlib.ngs:1097

arr

Items to iterate in chunks of n

n

Number of items in chunk

cb

Function to be called with values from arr

Returns

arr

Example

[1,2,3,4].each(2, F(a, b) echo("$a - $b"))  # Outputs: "1 - 2" and on the next line "3 - 4"