Applying a list of functions in Haskell

后端 未结 3 1066
遥遥无期
遥遥无期 2021-01-13 04:43

I wrote a function that applies a list of functions to an item.

applyAll :: [a -> b] -> a -> [b]
applyAll [] _ = []
applyAll (f:fs) x = (f x) : (a         


        
3条回答
  •  情话喂你
    2021-01-13 05:33

    This function actually already exists as a special case of a monadic function:

    applyAll :: [a -> b] -> a -> [b]
    applyAll = sequence
    

提交回复
热议问题