RosettaCodeData/Task/Loops-For-with-a-specified-step/Icon/loops-for-with-a-specified-step.icon
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
1,018 B
Text

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