1 (* Copyright (C
) 1999-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
4 * MLton is released under a BSD
-style license
.
5 * See the file MLton
-LICENSE for details
.
7 (*-------------------------------------------------------------------*)
9 (*-------------------------------------------------------------------*)
11 structure Iterate
: ITERATE
=
14 fun iterate(start
, isTerm
,next
) =
15 let fun loop s
= if isTerm s
then s
else loop(next s
)
19 fun whileDo(test
, f
) = iterate((),not
o test
, f
)
21 fun repeatUntil(f
, test
) = (f() ; iterate((), test
, f
))