]> Repositorios git - scryer-prolog.git/commitdiff
remove setof/3, bagof/3 non-determinism (#270)
authorMark Thom <[email protected]>
Sat, 22 Feb 2020 22:13:01 +0000 (15:13 -0700)
committerMark Thom <[email protected]>
Sat, 22 Feb 2020 22:13:01 +0000 (15:13 -0700)
src/prolog/lib/builtins.pl
src/prolog/machine/machine_state_impl.rs

index 2ac2ec38a4b8d8c3ba37479d83799776698cf44e..6a3f091e9fe15dd90123e8e3a4c64dbc3343a03c 100644 (file)
@@ -456,7 +456,10 @@ group_by_variants([V-S|Pairs], [V-Solution|Solutions]) :-
     group_by_variants(Pairs0, Solutions).
 group_by_variants([], []).
 
-iterate_variants([V-Solution|GroupSolutions], V, Solution).
+iterate_variants([V-Solution|GroupSolutions], V, Solution) :-
+    (  GroupSolutions == [] -> !
+    ;  true
+    ).
 iterate_variants([_|GroupSolutions], Ws, Solution) :-
     iterate_variants(GroupSolutions, Ws, Solution).
 
@@ -491,7 +494,10 @@ bagof(Template, Goal, Solution) :-
     iterate_variants(GroupedSolutions, Witnesses, Solution).
 
 iterate_variants_and_sort([V-Solution0|GroupSolutions], V, Solution) :-
-    sort(Solution0, Solution).
+    sort(Solution0, Solution),
+    (  GroupSolutions == [] -> !
+    ;  true
+    ).
 iterate_variants_and_sort([_|GroupSolutions], Ws, Solution) :-
     iterate_variants_and_sort(GroupSolutions, Ws, Solution).
 
@@ -948,7 +954,7 @@ chars_or_vars([C|Cs], PI) :-
     ).
 
 can_be_codes_or_vars(Cs, _)  :- var(Cs), !.
-can_be_codes_or_vars(Cs, PI) :- 
+can_be_codes_or_vars(Cs, PI) :-
     (  string(Cs) ->
        current_prolog_flag(double_quotes, codes)
     ;  codes_or_vars(Cs, PI)
index c6db779b6c906df5faad95fb8794350445bddb0d..fbc249cd4661afa33b3299e4efcb09033b88a224 100644 (file)
@@ -2207,7 +2207,7 @@ impl MachineState {
                 (HeapCellValue::Addr(Addr::PStrLocation(..)),
                  HeapCellValue::Addr(Addr::Con(Constant::String(..))))
               | (HeapCellValue::Addr(Addr::Con(Constant::String(..))),
-                 HeapCellValue::Addr(Addr::PStrLocation(..))) 
+                 HeapCellValue::Addr(Addr::PStrLocation(..)))
                     if self.flags.double_quotes.is_chars() => {
                         continue;
                     }
@@ -3169,7 +3169,8 @@ impl MachineState {
         false
     }
 
-    pub(super) fn setup_built_in_call(&mut self, ct: BuiltInClauseType) {
+    pub(super)
+    fn setup_built_in_call(&mut self, ct: BuiltInClauseType) {
         self.num_of_args = ct.arity();
         self.b0 = self.b;