<INTERFACE> The <CD/Iterate/ structure <PP> The <STRREF NOLINK/Iterate/ structure provides wrappers for simple forms of iteration. <SPEC> <VAL>iterate<TY>('a -> 'a) -> int -> 'a -> 'a <RAISES> <PROTOTY> iterate <ARG/f/ <ARG/cnt/ <ARG/a/ </PROTOTY> invokes the function <ARG/f/ <ARG/cnt/ times, starting with the value <ARG/a/, and using the result of one iteration as the argument in the next. Recursively, we have `iterate f cnt v = iterate f (cnt-1) (f v) iterate f 0 v = v` Raises the <VAL>repeat<TY>((int * 'a) -> 'a) -> int -> 'a -> 'a <RAISES> <PROTOTY> repeat <ARG/f/ <ARG/cnt/ <ARG/a/ </PROTOTY> is similar to <CD/iterate/ except that the function <ARG/f/ is also passed the iteration index. In particular, it is equivalent to: `#2(iterate (fn (i,v) => (i+1,f(i,v))) cnt (0,init))` <SPEC> <VAL>for<TY>((int * 'a) -> 'a) -> (int * int * int) -> 'a -> 'a <RAISES> <PROTOTY> for <ARG/f/ (<ARG/start/, <ARG/stop/, <ARG/inc/) <ARG/a/ </PROTOTY> provides more control over the range and step-size involved in the interation. Recursively, we have `for f (start,stop,inc) a = for f (start+inc,stop,inc) (f(start,a))` halting when <MATH/<ARG/start/ &GREATER; <ARG/stop// for negative <ARG/inc/ and halting when <MATH/<ARG/stop/ &GREATER; <ARG/start// for positive <ARG/inc/. If <ARG/inc/ is zero, <ARG/start/ and <ARG/~TOP/ must be equal, and we have `for f (start,stop,0) a = f(start,a)` Raises </INTERFACE>