Is there a library function available in Haskell to compose a function with itself n times?
For example I have this function:
func :: a ->
Here's a version that has complexity O(log n) instead of O(n) (to build the function, not to apply it):
composeN 0 f = id composeN n f | even n = g | odd n = f . g where g = g' . g' g' = composeN (n `div` 2) f