]> Repositorios git - scryer-prolog.git/commitdiff
ADDED: dif_si/2
authorMarkus Triska <[email protected]>
Sat, 22 Apr 2023 22:37:03 +0000 (00:37 +0200)
committerMarkus Triska <[email protected]>
Sat, 22 Apr 2023 22:37:14 +0000 (00:37 +0200)
Source: https://stackoverflow.com/questions/20223390/prolog-a-person-is-a-sibling-of-himself

In Scryer Prolog, this is actually not needed, since Scryer Prolog provides
dif/2 in library(dif). However, it is still useful to provide dif_si/2 for two reasons:

  1) to more easily port code from systems where only dif_si/2 is available
  2) to provide correct disequality in other systems that adopt this library

src/lib/si.pl

index a17053435a04324b034921d9f6822865ececfef8..4c3b6c65a1ec4538cea977a93f270d1d1485a656 100644 (file)
@@ -36,7 +36,8 @@
                integer_si/1,
                atomic_si/1,
                list_si/1,
-               chars_si/1]).
+               chars_si/1,
+               dif_si/2]).
 
 :- use_module(library(lists)).
 
@@ -64,3 +65,9 @@ list_si(L0) :-
 chars_si(Cs) :-
    list_si(Cs),
    '$is_partial_string'(Cs).
+
+dif_si(X, Y) :-
+   X \== Y,
+   ( X \= Y -> true
+   ; throw(error(instantiation_error,dif_si/2))
+   ).