We define a predicate ** integer_with_two_digit_square/1**
to produce a positive integer that has a square which
is greater than or equal to 10 and less than 100.

Here is the definition ofinteger_with_two_digit_square(X):-int(X),

test_square(X).

test_square(X):-

Y is X*X,

Y

>=10,Y

<100.

The goalint(1).int(2).

int(3).

int(4).

int(5).

On backtracking, this will generate a new solution forint(1).int(N):-

int(N1),

N is N1 +1.

The usual way out is to ensure that once we have found the solution we want then wecommitourselves to that solution and forbid backtracking from ever seeking another solution. Again, the usual solution is to place a cut (!/0) after the test. This results in:and the example demonstrates the (usually necessary) fix to stop a program using theinteger_with_two_digit_square(X):-int(X),

test_square(X),!.

generate --- testschema fromovergenerating. However, our solution now provides for only one solution to be generated!

Mon May 24 20:14:48 BST 1999