repeat/0¶
repeat* is iso
Succeeds repeatedly.
In the next example, repeat
is used as an efficient way to implement a loop. The next example reads all terms in a file: ```
a :- repeat, read(X), write(X), nl, X=end_of_file, !.
the loop is effectively terminated by the cut-goal, when the test-goal `X=end` succeeds. While the test fails, the goals `read(X)`, `write(X)`, and `nl` are executed repeatedly, because backtracking is caught by the `repeat` goal.
The built-in `repeat//00` could be defined in Prolog by:
repeat. repeat :- repeat. ```
The predicate between//33 can be used to iterate for a pre-defined number of steps.