ptrash <ptr...@web.de> writes:

> 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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to