Hello and welcome to the golden programming language course in the previous session, we talked about
create a slice using an array.
In this session, we want to talk about the author slices concepts.
Create a slice using already existing slice.
It is also be allowed to create a slice from the given the slice for creating a slice from the giving
a slice.
First, you need to specify the lower and upper bound, which means a slice can take elements from the
given a slice, it starting from the lower bound to the upper bound.
It does not include the elements, all from the upper bound syntax newest slice.
Column equals the slice thin and Escobar kids love column high.
These syntax will return and you will slice the default value of the lower bound is zero, and the default
value of the upper bound is the total number of the elements present in the given a slice.
Now go to this school to illustrate how to create a slice from existing a slice.
First, create a slice as a main slice for the example name a slice Cullen equals the square bracket
and tight end and initialize value 10, 20, 30, 40, 50, 60 and set and now create other slices from
the given a slice first by Vicky Ward declaration via the slice one equals main slice this square bracket
and defined lower and upper bound one column five.
Go to the next line and create other slices by shorthand declaration.
For the example, Slices two column equals main a slice.
The square brackets zero column and in the next line is slice three column equals main slice the square
brackets and column six and slice for column equals main slice a square brackets and just sit columns.
And for the example, Slice five column equals main slice and set the lower end all per pound for the
example to column for now displayed as slices by the following code.
First main slice if p.
I mean, the slice and said the as main a slice go to the next line and display the other slices if
P is slice from Colin, said a slice.
Well, and it's nice to call in this slice too and display this slice three Slice three column that
slice three and display this slice for
set the variable Slice four and the end healthy.
This Slice five column and sets the variable slice fine.
Reformat the code, save the project and execute the code.
Now we can see the output.
First, we bring the main Islamist, which contains the values from 10 to 17.
And then it's nice von, which restores the first index of the main east, lies to the 5th index of
the main US lies and contains the values 20 to 50, then this list to which contains the index zero
to the end index of the main east lies and hold the value 10 to 70.
Now Slide three is contains the zero index of the main east lies to the six index of the main as and
holds the values 10 to 60.
Now, force is lies that holds on the values of the main slice.
And finally, this bias, which towards the second index of the main east, lies to the fault in index
of the main stones and contains the values 30 to 40.
OK, now we could define the slices using existing a slice in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.