Zipping (computer science)

This name zip derives from the action of a zipper in that it interleaves two formerly disjoint sequences.

denote the length of the longest word which is fish;

The zip of cat, fish, be is then 4 tuples of elements: where # is a symbol not in the original alphabet.

Let x1x2... x|x|, y1y2... y|y|, z1z2... z|z|, ... be n words (i.e. finite sequences) of elements of Σ.

denote the length of the longest word, i.e. the maximum of |x|, |y|, |z|, ... .

The inverse to zip is sometimes denoted unzip.

A variation of the zip operation is defined by: where

, but destroys information about elements of the input sequences beyond

In Lisp-dialects one can simply map the desired function over the desired lists, map is variadic in Lisp so it can take an arbitrary number of lists as argument.

An example from Clojure:[1] In Common Lisp: Languages such as Python provide a zip() function.