Let's talk about zip.
How can we use zip.
Well let's create a new function and the zip function works kind of like a zipper.
We need to lists or to iterate balls and we can zip them together.
Let me show you what I mean.
Let's say I have my list and then your list and this your list will have 10 20 and 30.
Make sure that it's a list.
There you go and in here with the zip function I can simply run zip and in here I give it as many it
troubles as I want.
In our case two edibles.
So I'm going to give it my list and your list.
Let's close that out.
Add one more bracket and in fact click Run
what just happened here.
Zip like a zipper takes the two it dribbles and grabs the first item from each and zips them together
like a zipper.
So 1 and 10 get added to a couple together then two and 20 get added to topple together and then three
and 30 get added to a couple together.
What if this was a couple like this and I click Run does it matter.
It's an ignorable it's going to zip the items together.
Now this may not seem that useful to you now.
It's actually a very important function that because it's so generic can be used in so many different
things.
For example if we had from a database we collected all the user names from one column in a database
and then maybe from another part of the database we collect all of the phone numbers and they were all
in the same order.
Well we can combine these into a temple using zip that has the user name and the phone numbers attached
to them and create a whole new data structure and if I had a another list here let's say their list
and this one has five four and three I can add again their list as well.
And if I click Run you see that I can keep zipping things together.
So zip iterate over each one of these lists or data structures and zip them together once again noticing
that we don't modify any of our current data.
Instead we create a whole new one.
Very very nice.
What about reduce.
Let's find out more in the next video.