C10 - initial
each (Sifts) | |
---|---|
Type | Corrade progressive sift |
Sift | each |
Parameters | integer |
Description | The each sift will return a strided list given a supplied number. |
Last Changes | None |
The each
sift will return a strided list given a supplied number.
Position | Type | Description | Example |
---|---|---|---|
0 | an integer | return a strided list with the given stride number | 2 |
The following sift when added to a command will return each second element in the list starting and including the first zero-indexed element:
"sift", wasListToCSV([ "each", 2 ]),
Given the input
data=a,1,b,2,c,3,d,4,e,5
the expected output is:
data=a,b,c,d,e
each
sift will return the subset where represents the length of the list , are indices of the list and is the stride. This may seem counter-intuitive for non-programmers since the selection is expected to start from ignoring indices that conventionally start at . That is, the selection formula for the subset is expected to be . In case the latter behaviour is desired, then an additional skip
sift can be used to offset the start of the list such that the selection formula for the subset becomes .For example, suppose that each second element in a list would have to be selected without accounting for zero-based indexed arrays or lists, then the sift would be:
"sift", wasListToCSV([ "skip", 1, "each", 2 ]),
similarly, for each third element in a list:
"sift", wasListToCSV([ "skip", 2, "each", 3 ]),
For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy, copyright and the plagiarism pages.