Controlling the number of answers given for a relation query

We start with a simple example (a comment has been added to the interpreter interaction to highlight a particular line).
| ?? age_of(P,A).

P = roger : man
A = 110 : age
...
P = tom : man
A = 26 : age
...
P = june : woman
A = 23 : age
...
P = bill : man
A = 40 : age
...
P = mary : woman
A = 40 : age
.. %% Note .. was entered by user
P = rose : woman
A = 40 : age
...
P = penny : woman
A = 1 : digit

Unlike in Prolog where answers are printed one at a time and a semi-colon is used to get the next answer, in qulog interpreter the first five answers are printed and a .. is used to get the next batch of answers. Notice that the interpreter displays the inferred type next to each answer term.

We can change the number of answers produced at a time as follows using the special interpreter query action set_num_answers. This, and several queries below, are only for use in the interpreter and is not available for use in rules.

| ?? set_num_answers(3).

success

| ?? age_of(P,A).

P = roger : man
A = 110 : age
...
P = tom : man
A = 26 : age
...
P = june : woman
A = 23 : age

We can set the number of solutions back to the default:

| ?? set_num_answers(5).

success

We can constrain the query in a couple of ways as illustrated below. Say we wanted to know the people who have ages over 39 then we could use the query

P = roger : man
A = 110 : age
...
P = bill : man
A = 40 : age
...
P = mary : woman
A = 40 : age
...
P = rose : woman
A = 40 : age

What if we didn't care about the age and didn't want to clutter the interpreter output with this information then we use either of the following queries.

| ?? P :: age_of(P,A) & A>39.

P = roger : man
...
P = bill : man
...
P = mary : woman
..
P = rose : woman

| ?? exists A age_of(P,A) & A>39.

P = roger : man
...
P = bill : man
...
P = mary : woman
...
P = rose : woman

What if we wanted the answers to this particular query to appear two at a time but didn't want to globally change the number of answers printed. The following query will do.

| ?? 2 of P :: age_of(P,A) & A>39.

P = roger : man
...
P = bill : man
.. %% user input
P = mary : woman
...
P = rose : woman
..
no more solutions