/* Example Program-2: Loop and Line input (readln()) 12/5/2003 1. Read a line of text 2. Write a content of a variable or a string literal 3. Set up a loop by a predicate 4. Demonstrate backtracking on failure to resatisfy previously satisfied sub goals. Built-in predicates are NOT to be resatisfied on backtracking such as write(), readln(), readint(). */ predicates repeat type() test clauses repeat. % A fact to be true first time around. repeat :- repeat. % A rule to be used repeatedly after the first time. type :- repeat, readln(ST), /* Read a line */ write ("\nINPUT LINE:::::"), write(ST), write(":::::\n"), ST = "END". test :- readln(X), write(":::::"), write(X), write(":::::"), nl.