Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
1
-
Language 2016-02-10
-
New Feature
-
Description
Add a step(iterable, n) function that takes two arguments and an optional block. The declared parameter types must be `Iterable` and `Integer[1]` (a positive integer).
If the function is called without a block, it must return a new iterable that will yield each nth element of the given argument
When a block is given, it must be called with each nth element of the given argument. The argument is then returned.
Example:
[1,2,3,4,5,6,7,8].step(3) |$x| { notice($x) } |
will result in the notices '1', '4', '7'
$c =.[1,2,3,4,5,6,7,8].step(3).map |$x| { $x * 10 } |
Will result in:
$c == [10, 40, 70] |