If these are pure functions, then you can use ($) or "apply":
execute functions argument = map ($argument) functions -- execute [id,(1+),(1-)] 12 => [12,13,-11]
There is no guarantee that this will happen in sequence, but you will get a list of return values.
If these are actions that are impure, then what you want is called sequence_ :
sequence_ [putStr "Hello", putStr " world", putStrLn "!"]
sequence_ pretty easy to write yourself:
sequence_ [] = return () sequence_ (action:actions) = action >> sequence_ actions
There is also a sequence (without underscore) that launches a bunch of actions and returns their results:
main = do ss <- sequence [readFile "foo.txt", readFile "bar.txt", readFile "baz.txt"] -- or ss <- mapM readFile ["foo.txt", "bar.txt", "baz.txt"]
source share