repeat/0

succeeds always.

repeat

repeat/0 succeeds repeatedly and indefinitely. The difference to true/0 is that it can be backtracked.

Loops which are defined with repeat/0 should be finished with a Cut ('!'/0), because otherwise the loop can be repeated.
If a predicate, called after repeat/0, always fails, you can have an indefinite loop. If repeat/0 follows after a conjunction (','/2) the part left of it won't be backtraced any more.

Examples

repeat, write('indefinitely'), nl, fail. Writes indefinitely 'indefinitely' to the current outputstream.
repeat,!. Succeeds.
repeat,!,fail. Fails.

Standard

This predicate is part of the ISO-Prolog Standard.

See also

abort/0, break/0, call/1, fcall/1, catch/3, ','(conjunction)/2, '!'(cut)/0, ';'(disjunction)/2, fail/0, true/0, halt/0/1, '->'(if-then)/2, ';'(if-then-else)/2, '\+'(not provable)/1, once/1, throw/1.


Darueber read on...