Logo

Programming-Idioms

History of Idiom 50 > diff from v78 to v79

Edit summary for version 79 by GeoffChurch:
New Prolog implementation by user [GeoffChurch]

Version 78

2022-02-23, 18:24:32

Version 79

2022-02-23, 21:04:22

Idiom #50 Make an infinite loop

Write a loop that has no end clause.

Ouroboros eating its own tail

Idiom #50 Make an infinite loop

Write a loop that has no end clause.

Ouroboros eating its own tail
Extra Keywords
unbounded,unlimited,never,ouroboros,uroboros
Extra Keywords
unbounded,unlimited,never,ouroboros,uroboros
Code
?- repeat, false.

% repeat/0 is built-in, but could be defined like this:
repeat.
repeat :- repeat.
Comments bubble
`repeat/0` succeeds an infinite number of times, and each time is immediately foiled by false/0. The default execution strategy just tries clauses in order from left to right so this induces an infinite loop.