

Task

Demonstrate a   for-loop   where the step-value is greater than one.



Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges


 
   every 1 to 10 by 2                       # the simplest case that satisfies the task, step by 2
 
   every 1 to 10                            # no to, step is by 1 by default
   every EXPR1 to EXPR2 by EXPR3 do EXPR4   # general case - EXPRn can be complete expressions including other generators such as to-by, every's do is optional
   steps := [2,3,5,7]                       # a list
   every i := 1 to 100 by !steps            # . more complex, several passes with each step in the list steps, also we might want to know what value we are at
   every L[1 to 100 by 2]                   # as a list index
   every i := 1 to 100 by (k := !steps)     # . need () otherwise := generates an error
   every 1 to 5 to 10                       # simple case of combined to-by - 1,..,10, 2,..10, ..., 5,..,10
   every 1 to 15 by 2 to 5                  # combined to-by
   every (1 to 15 by 2) to 5                # . made explicit
 
   every writes( (TO_BY_EXPR) | "\n", " " ) # if you want to see how any of these work
 