1 00:00:05,770 --> 00:00:10,630 I hope you enjoyed this section on iterations and closures. 2 00:00:10,840 --> 00:00:16,600 In this video, we are going to go over the solution to the assignment for this section. 3 00:00:16,990 --> 00:00:22,900 The assignment was to create a vector with the values one, three, five, seven and nine. 4 00:00:23,740 --> 00:00:30,820 Then use an iterator and a closure to multiply all of the values by ten and store the result in another 5 00:00:30,820 --> 00:00:34,300 vector and then print out the vector to confirm our results. 6 00:00:35,200 --> 00:00:38,380 So let's go ahead and create our vector called VEC. 7 00:00:38,620 --> 00:00:44,170 We'll use the vector macro one, three, five, seven and nine. 8 00:00:45,160 --> 00:00:52,810 And now we're going to store our results in a result variable, which is going to be a vector of type 9 00:00:52,810 --> 00:00:53,980 I 16. 10 00:00:55,420 --> 00:00:59,110 And now we are going to create an iterator over our method. 11 00:00:59,740 --> 00:01:10,630 We are going to map the values and use a closure and multiply all the values by ten. 12 00:01:11,560 --> 00:01:16,810 And then we're going to collect the values so that we can store them in our result variable. 13 00:01:16,930 --> 00:01:19,720 So map is going to allow us. 14 00:01:21,530 --> 00:01:26,120 To execute a closure over each element yielded by the iterator. 15 00:01:26,120 --> 00:01:31,340 So in other words, the closure is executed for each element in the vector of numbers. 16 00:01:31,340 --> 00:01:38,420 So our iterator is going to provide us with this x value and now we are going to modify that x value 17 00:01:38,420 --> 00:01:43,460 by multiplying it by ten and store the result in our variable. 18 00:01:43,850 --> 00:01:46,340 So now we want to print out. 19 00:01:50,530 --> 00:01:57,010 All of our variables to make sure that we got the appropriate results. 20 00:02:05,950 --> 00:02:12,570 And we see we have one, three, five, seven, nine, and now we have ten, 30, 50, 70 and 90. 21 00:02:12,580 --> 00:02:15,850 So our solution for this is correct. 22 00:02:16,210 --> 00:02:24,160 I hope you enjoyed this assignment so that we could reinforce the learning that we gathered through 23 00:02:24,370 --> 00:02:27,340 this section of iterator and closures.