What is the reason behind Array#zip's name?

I’m just curious I know that Array#zip generates a new array from
arguments
passed to it. What I don’t get is why it is called zip. Is it because
of
how the results are computed into the new array?

On 02/01/2011 11:54 PM, Kevin wrote:

I’m just curious I know that Array#zip generates a new array from arguments
passed to it. What I don’t get is why it is called zip. Is it because of
how the results are computed into the new array?

I think it’s inherited from a similarly named function that carries out
the same operation in some functional programming languages. I remember
first being introduced to it in Haskel, but I’m sure it’s been around
longer.

In any case, you can think of the basic operation of zip as being like a
zipper, linking pairs of elements together at the same index in each
array. The arrays have been zipped together. This has been generalized
for n arrays, but the concept is the same.

-Jeremy

Haskell happened to be the second place I have seen this particular
function
as well. What you said makes lots of sense.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs