From 9f864574de79d0cf26ad5ae72c47365daba193e9 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Wed, 2 Mar 2022 21:02:19 +0100 Subject: [PATCH] ADDED: "f" to enumerate the next 5 solutions, similar to GUPU. --- README.md | 7 ++++--- src/toplevel.pl | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 105069ac..f2135168 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,10 @@ predicates it defines. For example, with the program shown above: ; What = pure_world. ``` -Press `SPACE` to show further answers, if any exist. Press `RETURN` or - `.` to abort the search and return to the toplevel prompt. -Press `h` to show a help message. +Press `SPACE` to show further answers, if any exist. Press `RETURN` +or `.` to abort the search and return to the +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`: diff --git a/src/toplevel.pl b/src/toplevel.pl index 72e59886..90e0a3a8 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -174,6 +174,7 @@ instruction_match(Term, VarList) :- submit_query_and_print_results_(Term, VarList) :- '$get_b_value'(B), bb_put('$report_all', false), + bb_put('$report_n_more', 0), '$call'(Term), write_eqs_and_read_input(B, VarList), !. @@ -316,6 +317,10 @@ write_eqs_and_read_input(B, VarList) :- read_input(ThreadedGoals, NewVarList) :- ( bb_get('$report_all', true) -> 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) ), ( C = w -> @@ -338,6 +343,9 @@ read_input(ThreadedGoals, NewVarList) :- ; C = a -> bb_put('$report_all', true), nl, write('; '), false + ; C = f -> + bb_put('$report_n_more', 5), + nl, write('; '), false ; read_input(ThreadedGoals, NewVarList) ). @@ -346,6 +354,7 @@ help_message :- write('SPACE, "n" or ";": next solution, if any\n'), write('RETURN or ".": stop enumeration\n'), write('"a": enumerate all solutions\n'), + write('"f": enumerate the next 5 solutions\n'), write('"h": display this help message\n'), write('"w": write terms without depth limit\n'), write('"p": print terms with depth limit\n\n'). -- 2.54.0