
8 Dec
2007
8 Dec
'07
3:27 p.m.
On 8 Dec 2007, ryanbloor@hotmail.com wrote:
Function A is a function that passes its input into B Function B is a function that does something once.
How do I make it so function A is done multiple times without adding a third function?
By this, do you mean that you have functions f, g f :: a -> a g :: a -> b and you want b . f . f . f . ... . f where there are n applications of f? If so, then g . (!! n) . iterate f will do the trick. Alternatively, you can produce the infinite list, as in: map (^2) . iterate succ $ 0 -- [0,1,4,9,16,25,36,49,64,81 ... Jed