>>> zip [] undefined [] >>> zip undefined [] *** Exception: Prelude.undefined ...zip is capable of list fusion, but it is restricted to its first list argument and its resulting list.
>>> zip [1, 2, 3] ['a', 'b', 'c'] [(1,'a'),(2,'b'),(3,'c')]If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:
>>> zip [1] ['a', 'b'] [(1,'a')]
>>> zip [1, 2] ['a'] [(1,'a')]
>>> zip [] [1..] []
>>> zip [1..] [] []
zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]zipWith is right-lazy:
>>> let f = undefined >>> zipWith f [] undefined []zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.
>>> zipWith (+) [1, 2, 3] [4, 5, 6] [5,7,9]
>>> zipWith (++) ["hello ", "foo"] ["world!", "bar"] ["hello world!","foobar"]
zipWith3 (,,) xs ys zs == zip3 xs ys zs zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
>>> zipWith3 (\x y z -> [x, y, z]) "123" "abc" "xyz" ["1ax","2by","3cz"]
>>> zipWith3 (\x y z -> (x * y) + z) [1, 2, 3] [4, 5, 6] [7, 8, 9] [11,18,27]
>>> (+) <$> [1, 2, 3] <*> [4, 5, 6] [5,6,7,6,7,8,7,8,9]The Applicative instance of ZipList applies the operation by pairing up the elements, analogous to zipWithN
>>> (+) <$> ZipList [1, 2, 3] <*> ZipList [4, 5, 6] ZipList {getZipList = [5,7,9]}
>>> (,,,) <$> ZipList [1, 2] <*> ZipList [3, 4] <*> ZipList [5, 6] <*> ZipList [7, 8] ZipList {getZipList = [(1,3,5,7),(2,4,6,8)]}
>>> ZipList [(+1), (^2), (/ 2)] <*> ZipList [5, 5, 5] ZipList {getZipList = [6.0,25.0,2.5]}
>>> unzip [] ([],[])
>>> unzip [(1, 'a'), (2, 'b')] ([1,2],"ab")