[Haskell-cafe] Re: Map list of functions over a single argument
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)]
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