]> Repositorios git - scryer-prolog.git/commitdiff
use ordsets in library(dif)
authorMark Thom <[email protected]>
Wed, 13 Mar 2019 01:13:03 +0000 (19:13 -0600)
committerMark Thom <[email protected]>
Wed, 13 Mar 2019 01:13:03 +0000 (19:13 -0600)
src/prolog/lib/dif.pl
src/prolog/machine/mod.rs

index 8153a38cc19205bb82cc0e7571463fb8c0dde5db..75dd8a17eb38d7104c0280e12a31a1e95b52e0da 100644 (file)
@@ -1,18 +1,15 @@
 :- module(dif, [dif/2]).
 
 :- use_module(library(atts)).
+:- use_module(library(ordsets)).
 
 :- attribute dif/1.
 
-non_unif_member([X \== Y | Z], V, W) :-
-    (   X == V, Y == W -> true
-    ;   non_unif_member(Z, V, W)
-    ).
-
 put_dif_att(Var, X, Y) :-
     (   get_atts(Var, +dif(Z)) ->
-       (   non_unif_member(Z, X, Y) -> true
-       ;   put_atts(Var, +dif([X \== Y | Z]))
+       ord_add_element(Z, X \== Y, NewZ),
+       (   Z == NewZ -> true
+       ;   put_atts(Var, +dif(NewZ))
        )
     ;   put_atts(Var, +dif([X \== Y]))
     ).
index 31ff4d728a46bd2ef340602e1a79c758c9e4f7db..40945f6c2733adb93cef95e29b37db658e8472e6 100644 (file)
@@ -183,11 +183,11 @@ impl Machine {
        compile_user_module(self, TERMS.as_bytes());
         compile_user_module(self, DCGS.as_bytes());
         compile_user_module(self, ATTS.as_bytes());
+        compile_user_module(self, ORDSETS.as_bytes());        
         compile_user_module(self, DIF.as_bytes());
         compile_user_module(self, FREEZE.as_bytes());
         compile_user_module(self, REIF.as_bytes());
         compile_user_module(self, ASSOC.as_bytes());
-        compile_user_module(self, ORDSETS.as_bytes());
     }
 
     pub fn new() -> Self {