22
Looks like there is also a zip3 (doc) and a zip4 (doc) function in Haskell. But the zipn seems to be complicated because of the strong type system. Here is a good discussion I've found during my research.
GHC also supports parallel list comprehensions:
{-# LANGUAGE ParallelListComp #-}
[(x,y) | x <- [1..3]
| y <- ['a'..'c']
]
==> [(1,'a'),(2,'b'),(3,'c')]
I just tested it up to 26 parallel variables, which should be enough for all practical purposes.
It's a bit hacky (and non-standard) though, so in case you're writing something serious, ZipList may be the better way to go.
If all your data is of the same type you could do:
import Data.List (transpose)
zipAllWith :: ([a] -> b) -> [[a]] -> [b]
zipAllWith _ [] = []
zipAllWith f xss = map f . transpose $ xss
zipAll = zipAllWith id
Example:
> zipAll [[1, 2, 3], [4, 5, 6], [7, 8]]
[[1,4,7],[2,5,8],[3,6]]