22 Arrays (Part 2)

Let's bring in our code from last time:

Now let's add a function to add vectors!

Now let's test our new function!

Yay! It seems to work well! But we can simplify this code using ideas from higher-order functions.

We can use Array.init, which gives us a way to initilize a new array with values:

There's still some ugliness in having to deal with these lengths. We can do this in an even better way using Array.map2. It is a version of map that takes in two arrays.