]> Repositorios git - scryer-prolog.git/commitdiff
add character_si/1 and use it to correct chars_si/1
authorMarkus Triska <[email protected]>
Thu, 3 Aug 2023 20:27:13 +0000 (22:27 +0200)
committerMarkus Triska <[email protected]>
Thu, 3 Aug 2023 20:27:13 +0000 (22:27 +0200)
This addresses #1947.

src/lib/si.pl

index 4c3b6c65a1ec4538cea977a93f270d1d1485a656..910cad5b54013e7669d74e540a695bb82fdff661 100644 (file)
@@ -36,6 +36,7 @@
                integer_si/1,
                atomic_si/1,
                list_si/1,
+               character_si/1,
                chars_si/1,
                dif_si/2]).
 
@@ -62,9 +63,15 @@ list_si(L0) :-
    ;  throw(error(instantiation_error, list_si/1))
    ).
 
-chars_si(Cs) :-
-   list_si(Cs),
-   '$is_partial_string'(Cs).
+character_si(Ch) :-
+   functor(Ch,Ch,0),
+   atom(Ch),
+   atom_length(Ch,1).
+
+chars_si(Chs) :-
+   \+ \+ length(Chs,_),
+   \+ ( once(length(Chs,_)), member(Ch,Chs), nonvar(Ch), \+ character_si(Ch) ),
+   \+ ( member(Ch,Chs), \+ character_si(Ch) ). % for the instantiation error
 
 dif_si(X, Y) :-
    X \== Y,