funpow : int -> ('a -> 'a) -> 'a -> 'a
- SYNOPSIS
-
Iterates a function a fixed number of times.
- DESCRIPTION
-
funpow n f x applies f to x, n times, giving the result f (f ... (f
x)...) where the number of f's is n. funpow 0 f x returns x. If n is
negative, it is treated as zero.
- FAILURE CONDITIONS
-
funpow n f x fails if any of the n applications of f fail.
- EXAMPLE
-
Apply tl three times to a list:
# funpow 3 tl [1;2;3;4;5];;
val it : int list = [4; 5]
Apply tl zero times:
# funpow 0 tl [1;2;3;4;5];;
val it : int list = [1; 2; 3; 4; 5]
Apply tl six times to a list of only five elements:
# funpow 6 tl [1;2;3;4;5];;
Exception: Failure "tl".