
5 Oct
2006
5 Oct
'06
12:45 a.m.
Joel Koerwer wrote:
Let's say I want to evaluate a function of type (a->a->...->a->a), taking the arguments from a list. If know the function ahead of time, I can simply wrap it:
foo a b c d = ... wrapFoo (a:b:c:d:_) = foo a b c d
But, as an exercise, I challenged myself to write a function, multApply :: (a->a->...->a->a) -> [a] -> a, that automatically does the wrapping for any such function.
This came up a while ago (but with a list of functions of different arities, all being fed one argument). I found Scott Turner's pure Haskell 98 solution very illuminating: http://www.haskell.org/pipermail/haskell-cafe/2000-November/001332.html Regards, Tom