From: Markus Triska Date: Wed, 29 Nov 2023 20:24:54 +0000 (+0100) Subject: ADDED: term_si/1, true for terms X-Git-Tag: v0.9.4~93^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=8cb4dfef62cf9a39a24423fd85cb9431379dcd9f;p=scryer-prolog.git ADDED: term_si/1, true for terms 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. --- diff --git a/src/lib/si.pl b/src/lib/si.pl index bdebc956..ac28b43c 100644 --- a/src/lib/si.pl +++ b/src/lib/si.pl @@ -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