I recently saw some Clojure or Scala (sorry I’m not familiar with them) and they did zip on a list or something like that. What is zip and where did it come from ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Zip is when you take two input sequences, and produce an output sequence in which every two elements from input sequences at the same position are combined using some function. An example in Haskell:
Input:
Output:
The above is a more generic definition; sometimes,
zipspecifically refers to combining elements as tuples. E.g. in Haskell again:Input:
Output:
And the more generic version is called “zip with”. You may consider “zip” as a special case of “zipWith”: