[Haskell-cafe] Repeated function application

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Thu Feb 21 11:07:11 EST 2008


Am Donnerstag, 21. Februar 2008 16:58 schrieb Ben Butler-Cole:
> Hello
>
> I was surprised to be unable to find anything like this in the standard
> libraries:
>
> times :: (a -> a) -> Int -> (a -> a)
> times f 0 = id
> times f n = f . (times f (n-1))

times f n = (!! n) . iterate f

> […]

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list