
7 Jun
2009
7 Jun
'09
7:26 p.m.
ptrash
I want to make something like a counter. I have written a recursive method which for example runs x times and counts how many times it runs, and also count some other thinks. Add the end I want a statistic about certain thinks returned by the method.
Keep in mind that a function's result depends only on its parameters, so any state you want to retain must be part of the parameters. So you might be looking for something like: iterateN x f y = if x == 0 then y else iterateN (x-1) f (f y) -k -- If I haven't seen further, it is by standing in the footprints of giants