]> Repositorios git - scryer-prolog.git/commitdiff
ADDED: term_si/1, true for terms
authorMarkus Triska <[email protected]>
Wed, 29 Nov 2023 20:24:54 +0000 (21:24 +0100)
committerMarkus Triska <[email protected]>
Wed, 29 Nov 2023 20:25:09 +0000 (21:25 +0100)
One use case is to ensure that once/1 is safe to use:

    term_si(Goal),
    once(Goal)

In such cases, Goal is ground and can yield at most one solution,
therefore once/1 does not remove any solutions.

src/lib/si.pl

index bdebc956da6085db6beb45ce3e249357264bd222..ac28b43c4c0af8a49e49917b8665effe8882070b 100644 (file)
@@ -37,6 +37,7 @@
                atomic_si/1,
                list_si/1,
                character_si/1,
+               term_si/1,
                chars_si/1,
                dif_si/2]).
 
@@ -68,6 +69,11 @@ character_si(Ch) :-
    atom(Ch),
    atom_length(Ch,1).
 
+term_si(Term) :-
+   (   ground(Term) -> acyclic_term(Term)
+   ;   throw(error(instantiation_error, term_si/1))
+   ).
+
 chars_si(Chs0) :-
    '$skip_max_list'(_,_, Chs0,Chs),
    ( nonvar(Chs) -> Chs == [] ; true ), % fails for infinite lists too