From: Mark Thom Date: Wed, 13 Mar 2019 01:13:03 +0000 (-0600) Subject: use ordsets in library(dif) X-Git-Tag: v0.8.110~184 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=b5ad8051d83da8ac99be386a401187c151e4f56f;p=scryer-prolog.git use ordsets in library(dif) --- diff --git a/src/prolog/lib/dif.pl b/src/prolog/lib/dif.pl index 8153a38c..75dd8a17 100644 --- a/src/prolog/lib/dif.pl +++ b/src/prolog/lib/dif.pl @@ -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])) ). diff --git a/src/prolog/machine/mod.rs b/src/prolog/machine/mod.rs index 31ff4d72..40945f6c 100644 --- a/src/prolog/machine/mod.rs +++ b/src/prolog/machine/mod.rs @@ -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 {