Re: [Seed7-users] The `range' function
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Thomas M. <tho...@gm...> - 2022-06-14 05:56:02
|
On Mon, 13 Jun 2022 21:08:00 +0200 Duke Normandin <dukeof...@gm...> wrote: > In your manual, you have the following examples: > > for number range [] (0, 1, 2, 3, 5, 8, 13, 20, 40, 100) do > for innerPlanet range {"Mercury", "Venus", "Earth", "Mars"} do > for letter range "the quick brown fox jumps over the lazy dog" do > > Is it correct to think of `range' to mean: "to the length of"? > for number "to the length of" [] (0, 1, 2, .... 20, 40,100) do I don't know what you mean with "to the length of". There is no 'range' function. Instead the keyword 'range' is part of the for-loop. In case of for number range [] (0, 1, 2, 3, 5, 8, 13, 20, 40, 100) do write(number <& " "); end for; writeln; The program actually writes the line: 0 1 2 3 5 8 13 20 40 100 So number gets all the values from the array one by one. Internally this for-loop has some index into the array (to the array element that is currently assigned to number). But this for loop does not show you the index. If you have more questions just ask. Regards Thomas |