
8 Aug
2009
8 Aug
'09
4:38 p.m.
On Sat, Aug 08, 2009 at 03:01:34PM -0500, I. J. Kennedy wrote:
Does this function already exist in one of the standard modules? It computes f(f(f(...f(x))). I suspect it is a common function, but I can't find it, even using Hoogle.
applyMany :: Int -> (a -> a) -> a -> a applyMany 0 f x = x applyMany n f x = applyMany (n-1) f (f x)
applyMany n f x = iterate f x !! n -- Felipe.