[Haskell-cafe] Map list of functions over a single argument

Dougal Stanton ithika at gmail.com
Tue Feb 20 10:05:08 EST 2007


Quoth Paul Moore, nevermore,
> >Prelude> map ($ 3) [(*2),(+1),div 1]
> >[6,4,0]
> 
> Cool. I told you I was missing something! :-)

I suppose this would fit your original idea if you wanted that
particular type signature. (Warning: not tested.)

> f :: a -> [a -> b] -> [b]
> f c fs = map ($ c) fs
>
> mapF :: [a -> b] -> a -> [b]
> mapF = flip f

Aren't higher order functions just dreamy... ? ;-)

-- 
Dougal Stanton


More information about the Haskell-Cafe mailing list