[Haskell-cafe] standard function
ithika at gmail.com
Wed Jun 6 10:14:14 EDT 2007
On 06/06/07, Steffen Mazanek <haskell at steffen-mazanek.de> wrote:
> is there a function f::[a->b]->a->[b] in the libraries? Couldn't find one
> hoogle although this seems to be quite a common thing...
Possibly it's just too small to bother putting in a separate function.
> let fs = [ (*2), (+2), (2-) ]
> :t fs
> fs :: [Integer -> Integer]
> map ($5) fs
> :t map ($5)
> map ($5) :: (Num a) => [a -> b] -> [b]
> let g = \x -> map ($x)
> :t g
> g :: a -> [a -> b] -> [b]
That's essentially what you want, but we could go the extra distance.
> :t flip g
> flip g :: [a -> b] -> a -> [b]
> let h = flip g
> h fs (5)
> f fs i = map ($i) fs
More information about the Haskell-Cafe