I hope you enjoyed this section on iterations and closures.
In this video, we are going to go over the solution to the assignment for this section.
The assignment was to create a vector with the values one, three, five, seven and nine.
Then use an iterator and a closure to multiply all of the values by ten and store the result in another
vector and then print out the vector to confirm our results.
So let's go ahead and create our vector called VEC.
We'll use the vector macro one, three, five, seven and nine.
And now we're going to store our results in a result variable, which is going to be a vector of type
I 16.
And now we are going to create an iterator over our method.
We are going to map the values and use a closure and multiply all the values by ten.
And then we're going to collect the values so that we can store them in our result variable.
So map is going to allow us.
To execute a closure over each element yielded by the iterator.
So in other words, the closure is executed for each element in the vector of numbers.
So our iterator is going to provide us with this x value and now we are going to modify that x value
by multiplying it by ten and store the result in our variable.
So now we want to print out.
All of our variables to make sure that we got the appropriate results.
And we see we have one, three, five, seven, nine, and now we have ten, 30, 50, 70 and 90.
So our solution for this is correct.
I hope you enjoyed this assignment so that we could reinforce the learning that we gathered through
this section of iterator and closures.