[Haskell-cafe] Mapping a list of functions
rendel at Mathematik.Uni-Marburg.de
Thu Jun 17 15:14:26 EDT 2010
Martin Drautzburg wrote:
> The standard map function applies a single function to a list of arguments.
> But what if I want to apply a list of functions to a single argument.
So your list of arguments is actually a list of functions. But since
functions are first-class values, that shouldn't be a problem. You
simply have to write a appropriate function to map over that list of
map (\f -> f a b c) listOfFunctions
The lambda expression (\f -> f a b c) denotes a function which takes a
function f, and applies it to some values a, b and c. That's exactly the
function you want to map over the list of functions.
Alternatively, you might want to look into list comprehensions:
[f a b c | f <- listOfFunctions]
More information about the Haskell-Cafe