ADDED: "f" to enumerate the next 5 solutions, similar to GUPU.

This commit is contained in:
Markus Triska
2022-03-02 21:02:19 +01:00
parent a38f7c8524
commit 9f864574de
2 changed files with 13 additions and 3 deletions

View File

@@ -224,9 +224,10 @@ predicates it defines. For example, with the program shown above:
; What = pure_world. ; What = pure_world.
``` ```
Press `SPACE` to show further answers, if any exist. Press `RETURN` or Press `SPACE` to show further answers, if any exist. Press `RETURN`
 `.` to abort the search and return to the toplevel prompt. or `.` to abort the search and return to the
Press `h` to show a help message. toplevel prompt. Press `f` to see the next 5 answers, and
`a` to see all answers. Press `h` to show a help message.
To quit Scryer Prolog, use the standard predicate `halt/0`: To quit Scryer Prolog, use the standard predicate `halt/0`:

View File

@@ -174,6 +174,7 @@ instruction_match(Term, VarList) :-
submit_query_and_print_results_(Term, VarList) :- submit_query_and_print_results_(Term, VarList) :-
'$get_b_value'(B), '$get_b_value'(B),
bb_put('$report_all', false), bb_put('$report_all', false),
bb_put('$report_n_more', 0),
'$call'(Term), '$call'(Term),
write_eqs_and_read_input(B, VarList), write_eqs_and_read_input(B, VarList),
!. !.
@@ -316,6 +317,10 @@ write_eqs_and_read_input(B, VarList) :-
read_input(ThreadedGoals, NewVarList) :- read_input(ThreadedGoals, NewVarList) :-
( bb_get('$report_all', true) -> ( bb_get('$report_all', true) ->
C = n C = n
; bb_get('$report_n_more', N), N > 1 ->
N1 is N - 1,
bb_put('$report_n_more', N1),
C = n
; get_single_char(C) ; get_single_char(C)
), ),
( C = w -> ( C = w ->
@@ -338,6 +343,9 @@ read_input(ThreadedGoals, NewVarList) :-
; C = a -> ; C = a ->
bb_put('$report_all', true), bb_put('$report_all', true),
nl, write('; '), false nl, write('; '), false
; C = f ->
bb_put('$report_n_more', 5),
nl, write('; '), false
; read_input(ThreadedGoals, NewVarList) ; read_input(ThreadedGoals, NewVarList)
). ).
@@ -346,6 +354,7 @@ help_message :-
write('SPACE, "n" or ";": next solution, if any\n'), write('SPACE, "n" or ";": next solution, if any\n'),
write('RETURN or ".": stop enumeration\n'), write('RETURN or ".": stop enumeration\n'),
write('"a": enumerate all solutions\n'), write('"a": enumerate all solutions\n'),
write('"f": enumerate the next 5 solutions\n'),
write('"h": display this help message\n'), write('"h": display this help message\n'),
write('"w": write terms without depth limit\n'), write('"w": write terms without depth limit\n'),
write('"p": print terms with depth limit\n\n'). write('"p": print terms with depth limit\n\n').