[Haskell-cafe] Mission: To take args from a list... generally

tpledger at ihug.co.nz tpledger at ihug.co.nz
Thu Oct 5 00:45:26 EDT 2006


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


More information about the Haskell-Cafe mailing list