## iterate.api
# Compiled by:
#
src/lib/std/standard.lib### "The road to wisdom?
### well, it's plain
### and simple to express:
### To err,
### and err,
### and err again
### But less,
### and less
### and less.
### -- Piet Hein
api Iterate {
#
iterate: (X -> X) -> Int -> X -> X;
#
# iterate f count init = f (f(...f (f(init))...)) (count times)
# iterate f 0 init = init
# raises BAD_ARG if count < 0
repeat: ((Int, X) -> X) -> Int -> X -> X;
#
# repeat f count init
# = #2 (iterate (fn (i, v) => (i+1, f (i, v))) count (0, init))
forloop: ((Int, X) -> X) -> (Int, Int, Int) -> X -> X;
#
# for f (start, stop, inc) init
# "for loop"
# implements f(...f (start+2*inc, f (start+inc, f (start, init)))...)
# until the first argument of f > stop if inc > 0
# or the first argument of f < stop if inc < 0
# raises BAD_ARG if inc <= 0 and start < stop or if inc >=0 and
# start > stop.
};
## COPYRIGHT (c) 1993 by AT&T Bell Laboratories. See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.