A virtual sequence is defined for iterating over integers from zero.
<iota> ( n -- iota )
For example, calling
<iota> on the integer 3 produces a sequence containing the elements 0, 1, and 2. This is very useful for performing counted loops using words such as
each :
USING: sequences prettyprint ; 3 <iota> [ . ] each0
1
2
A common idiom is to iterate over a sequence, while also maintaining a loop counter. This can be done using
each-index ,
map-index and
reduce-index .
Combinators that produce new sequences, such as
map , will output an array if the input is an instance of
<iota> .
More elaborate counted loops can be performed with
Numeric ranges .
This documentation was generated offline from a
load-all
image. If you want, you can also
browse the documentation from within the UI developer tools . See
the Factor website
for more information.
Factor 0.101 x86.64 (2285, heads/master-efda6dad2f, Nov 20 2024 16:02:37)