Right now, I want to talk a little bit about iRace, so let us dig into it.
Let's say you have multiple data.
Instead of defining them separately, you could just bag them all in an array.
That is the main purpose of having it.
All right.
So instead of defining boolean inputs, one billion and Bittu billion, input three, well, how about
we define an array with a certain size and we initialize it?
That would be great.
So how do we define an array?
We need to define its type.
So what kind of type it will contain inside it.
So let's say we are containing all on the booleans.
Right.
So here we are defining the type.
It could be anything.
Then we have input and we have then two brackets and we have this size inside it.
Then you can initialize it or not.
So in my case, I am initializing everything to zero inside, meaning input one, two, three, equal
to zero.
So instead of writing these three lines, we can just delete these three lines and just write this one
line now to access every element and change its value and maybe read its value.
We put the name of the array bracket, the index, meaning which element are we accessing?
And we, by the way, we start indexing starting from zero.
So we are saying input zero equals one.
That's a great meaning that this element here really called one.
If you want to change this element, well, the index is one for it because we start from zero.
So this is zero one two.
OK, so let's change this value.
It's called inputs, the name of the array then bracket.
And we put the index, which is this one.
This is one.
And we equal to whatever value we want.
In our case, these are booleans.
So they can only take a value between zero and one.
So they can only take two value, zero or one.
Let's say we want to change this one.
We just put the name of the array brackets, the index, which is two in this case.
And then what does it equal to now?
How about we utilize photobooks with array?
Let's say that I want to print all of the elements of an array.
It's not really practical to go through your print input zero.
So you'll give it one and two.
That's really not practical.
OK, so let's say that I want to turn all of this inputs to one at once.
OK, I don't want to go indexed by index, but I just want to do it with a couple of lines.
What I would do is I would start a formula in the range between zero and do so as long as the condition
is less or equal to is satisfied.
I'm going to keep looping whenever this is not satisfied, meaning whenever I equals the three, I'm
going to break out of this loop.
OK, so I'm saying that my inputs array I remember I here with a counter so in every little bit changing
between zero one two.
So what I'm doing here actually is input zero is equal zero that you are looking again.
Inputs one equals one.
We are looping again.
Inputs two equals one and we are breaking out of it.
And every time I said an input to a value, I am saying, hey, the print, the array index, meaning
I am a printing inputs zero inputs one inputs two.
So I am printing the content of this array right here.
Right.
I have said everything to one in every loop iteration, meaning I'm going to print one one one right
here.
Right.
So this is how you change the value of multiple elements and print them with a couple of lines using
for this loop could have 200 elements.
Your array could have 200 elements.
It's not really practical to go element by element that to change its value, especially if you want
to change it to a one target value, to a one constant value of what you can do is just loop over everything
you put the counter in instead of the index and you assign it to whatever you want.
The same thing on your printing.
You just put the array and the eye, which is the counter, and let it loop and change the index and
do multiple operations at once.