Say I have a list of functions
functions = [f, g, h]
each with type a -> a
I also have a list of values, like numbers, but everything should work here.
vals = [1,2,3]
I want to apply each function in functions to the corresponding value in vals
My first instinct is to use lambda and zipWith like:
zipWith (\fv -> fv) functions vals
But frankly, it looks ugly, and not what I expect in such a nice language like Haskell. A functional application function sounds like a solution. Does something like this exist? Am I missing something, and is there a much nicer solution to my problem? I actually wrote this construct for the Project Euler solution. It works, but I don't like it.
haskell higher-order-functions
Juan pablo santos
source share