funpow : int -> ('a -> 'a) -> 'a -> 'a

Iterates a function a fixed number of times.

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.

funpow n f x fails if any of the n applications of f fail.

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".