
21 Feb
2008
21 Feb
'08
11:06 a.m.
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