Loops/For with a specified step: Difference between revisions

Line 1,546:
Icon and Unicon accomplish loop stepping through the use of a generator, the ternary operator to-by, and the every clause which forces a generator to consume all of its results.
Because to-by is an operator it has precedence (just higher than assignments) and associativity (left) and can be combined with other operators.
<syntaxhighlight lang="pascalpython">
every 1 to 10 by 2 # the simplest case that satisfies the task, step by 2
 
57

edits