control flow loop
Documentation for control flow loop, assembled from the following types:
From Control Flow
loop statement takes three statements in parentheses separated by
; that take the role of initializer, conditional and incrementer. The initializer is executed once and any variable declaration will spill into the surrounding block. The conditional is executed once per iteration and coerced to
False the loop is stopped. The incrementer is executed once per iteration.
loop (my = 0; < 10; ++)
The infinite loop does not require parentheses.
loop statement may be used to produce values from the result of each run of the attached block if it appears in lists:
(loop ( my = 0; ++ < 3;) ).say; # OUTPUT: «(2 4 6)␤»my = (loop ( my = 0; ++ < 3;) ); .say; # OUTPUT: «[2 4 6]␤»my = do loop ( my = 0; ++ < 3;) ; .say; # same thing
for loop, one should not rely on whether returned values are produced lazily, for now. It would probably be best to use
eager to guarantee that a loop whose return value may be used actually runs: