[Haskell-beginners] Does this function already exist in one of
the standard modules?
Felipe Lessa
felipe.lessa at gmail.com
Sat Aug 8 16:38:23 EDT 2009
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.
More information about the Beginners
mailing list