Hello and welcome to the golden programming language course in the previous sessions.
We talked about declaration and initialization as lysis and indecision.
We want to talk about the other nice this concept.
Iterate over a slice.
You can iterate over is nice using the following base first using faux loop, second using range and
follow third, using a blank identifier in falou and phones using for loop as buy.
Now go to the Escott program to illustrate how to use iterating over a slice.
Watching in this hamper, we want to talk about iterate over a slice by using for loop first creating
a slice.
This five column he calls this group rockets type is aimed at initialize value by 10, 20, 30, 40,
50, 60 and 70.
Now, iterate this slice using follow through the following four I call it equals zero.
I list the LEN of slice and I + +.
We put the condition here for continue to follow, so we use lean function for set the condition and
it means I less than seven now display the element of a slice in each increment, right?
FP
it's nice the square brackets and set the index I reformatted to save the projects and execute it.
Now we can see the output and we could display elements of a slice from 10 to 70 by full loop.
Now, do another example.
First clear of the last quote.
In this case, we want to iterate over this list using range in loop.
So do the following four index.
Common value Cullen equals range.
And it's nice variable here is it's nice.
And now he's been the index and value for each element of this nice if there.
Index he calls cent the and
value.
He calls her sandy and slush and and sets the very bad index and value reform at the school, save the
project and execute the code.
OK.
We can see the output we could display indexes and values of a nice elements from 10 to 17 by using
ranging for.
Now do another example.
First clear of the last code.
In this sample, we want to iterate over a slice using a blank identifier in for loop.
So do the following four underscore comma error value column equals branch in this slice validator.
Now write the value if
the value equals person and bank is this end and sets the value of the value before you make the call
and save and execute the code.
OK, we can't see the output.
We could display a slice elements from 10 to 70 by using range info look without an index.
Now, to another example, first clear last quote.
In this sandpit, we want to iterate over a slice by using faux loop as volume.
First, define the local variable as a counter for the example I call an equal zero as a counter and
right for loop flow range a slice and this fillet the value of a slice.
For the example, FP is sliced.
Yes, global markets index I.
Now, increase the counter after use print and dry eye plus plus reformat the code, save the project
and execute the program.
Now we can see the output and we could display its nice elements from 10 to 70 by using Falou as a wine
indecision.
We could iterate over a slice in several different ways in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.