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 revApply'.

Beauty in the eye of the beholder...

Jules
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to