Ben Butler-Cole writes:
times :: (a -> a) -> Int -> (a -> a)
times f 0 = id
times f n = f . (times f (n-1))
Am I missing something more general
...I can't help feeling that there must be a way to get rid of the explicit recursion.
How would you implement times?

Anything against (apart an auxiliary list, and "x" not curried away) times n f x = (iterate f x)!!n Jerzy Karczmarczuk

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

Reply via email to