[Seed7-users] for
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Thomas M. <tho...@gm...> - 2012-10-02 09:18:45
|
On Mon, 1 Oct 2012 00:37:48 +0200, Renato Lenzi <re...@gm...> wrote: > I don't fully understand the for sintax, that is i don't understand > how i can change the increment of the parameter. For example in C# i > can write: > > for (int x = 0; int < 10; x++) > { > ...... > } > > but also: > > for (int x = 0; x < 10; x+=2) or > for (int x = 0; x < 10; x+=3) etc.... > > this way i can modifying the amplitude of iterations. > Looking at the for declarations in Seed7 manual i guess i have to > change the amplitude inside the body of the loop. Is there another > way? A look at the for declarations in the Seed7 manual shows me, that I forgot to explain the for-step-statement. Your C# examples can be written in Seed7 with: for x range 0 to 9 step 2 do ... end for; for x range 0 to 9 step 3 do ... end for; In the first loop x will have the values 0, 2, 4, 6, 8. In the second loop x will have the values 0, 3, 6, 9. For-step-statements with downto are also possible: # Here x will have the values 10, 8, 6, 4, 2. for x range 10 downto 0 step 2 do ... end for; # Here x will have the values 10, 7, 4, 1. for x range 10 downto 0 step 3 do ... end for; I hope that this descriptions help you. I will add a more detailed description of the for-step-statement to the manual, as soon as I have time to do it. Regards, Thomas Mertes |