Lably
Skip to content

Zipping (computer science)

  • 6 min read
  • 4 chapters

Related on Lably

Through Computer science, Function (computer programming) and Tuple

Example

Given the three words cat, fish and be where |cat| is 3, |fish| is 4 and |be| is 2. Let ℓ denote the length of the longest word which is fish; ℓ=4. The zip of cat, fish, be is then 4 tuples of elements:

(c,f,b)(a,i,e)(t,s,#)(#,h,#)

where # is a symbol not in the original alphabet. In Haskell this truncates to the shortest sequence ℓ_, where ℓ_=2:

<span id="mwKg"></span><span class="nf" id="mwKw">zip3</span><span class="w" id="mwLA"> </span><span class="s" id="mwLQ">"cat"</span><span class="w" id="mwLg"> </span><span class="s" id="mwLw">"fish"</span><span class="w" id="mwMA"> </span><span class="s" id="mwMQ">"be"</span> <span class="c1" id="mwMg">-- [('c','f','b'),('a','i','e')]</span>

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Clothing and fashion