[Haskell-cafe] zip3, zip4 ... -> zipn?

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun Aug 12 04:02:07 EDT 2007

On Sat, Aug 11, 2007 at 09:58:05AM +0200, Frank Buss wrote:
> Is it possible to write a function like this:
> zipn n list_1 list_2 list_3 ... list_n
> which implements zip3 for n=3, zip4 for n=4 etc.? Looks like variable number
> of arguments are possible, like printf shows, so a general zipn should be
> possible, too. If it is possible, why there are functions like zip5 and not
> just zipn?

I prefer to do n-ary zips this way:

    zipApply = zipWith ($)

    x = repeat (,,) `zipApply` [1,2,3] `zipApply` ["a", "bc", "de"] `zipApply` [1.0, 1.2..]

Best regards

More information about the Haskell-Cafe mailing list