/* Filename: repeat.pro Author: Br. David Carlson Date: December 7, 1999 This program contains predicates that illustrates various ways of creating loops in Prolog. Submit a goal such as: infinite_loop. for_loop(6). input_loop. go. */ infinite_loop :- repeat, write('Enter a number (CTRL c to stop): '), read(X), write(X), nl, fail. go :- repeat, write('Enter a number: '), read(X), write(X), nl, X=end_of_file, !. for_loop(0) :- !. for_loop(N) :- write(N), nl, N1 is N - 1, for_loop(N1). input_loop :- getPosInt(Num), nl, write('You entered: '), write(Num), nl. getPosInt(X) :- write('Enter a postive integer: '), read(X), nl, X > 0, !. getPosInt(X) :- write('Re-enter: '), getPosInt(X).