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

Jules Bean jules at jellybean.co.uk
Wed Feb 21 11:09:26 EST 2007

Gene A wrote:
> Well this is not very sexy, no monads or anything, but I kinda believe 
> in Keep It Simple:
> Prelude> let revApply a f = f a
> Prelude> let rMap a fs = map (revApply a) fs
> Prelude> rMap 2 [(*4),(^2),(+12),(**0.5)]
> [8.0,4.0,14.0,1.4142135623730951]

Note that revApply here is precisely flip ($).

And ($a) is the same as flip ($) a.

So this reduces to one of the earlier examples rather quickly.

It is possible to argue 'it's nice to give revApply a name'. It's also 
possible to argue 'taking a section of $ is even better than naming 

Beauty in the eye of the beholder...


More information about the Haskell-Cafe mailing list