
9 Dec
2004
9 Dec
'04
3:57 p.m.
On Thu, Dec 09, 2004 at 10:02:39AM -0500, Jan-Willem Maessen - Sun Labs East wrote:
And I thought that most programmers used "zipWith", which has to be prefix.
You can also use zipWith to simulate zipN, for any N (however, the following code uses infix notation): Prelude> let l = words "Haskell is great" Prelude> let zwApply = zipWith ($) Prelude> repeat (,,) `zwApply` [1..] `zwApply` l `zwApply` map length l [(1,"Haskell",7),(2,"is",2),(3,"great",5)] Prelude> map (,,) l `zwApply` [1..] `zwApply` map length l [("Haskell",1,7),("is",2,2),("great",3,5)] I found it useful recently, when I needed zip functions for Trees - this way I didn't have to define functions for 3 trees, 4 trees, and so on. Best regards, Tomasz