projog

3.47. once(X) - calls the goal represented by a term.

The once(X) goal succeeds if an attempt to satisfy the goal represented by the term X succeeds. No attempt is made to retry the goal during backtracking - it is only evaluated once.

Examples

?- once(repeat).

yes

?- once(true).

yes

?- once((true,true,true)).

yes

?- once((true;true;true)).

yes

?- once((fail;true;true)).

yes

?- once((true;fail;true)).

yes

?- once((true;true;fail)).

yes

?- once(fail).

no

?- once((fail;fail;fail)).

no

?- once((fail,fail,fail)).

no

?- once((true,true,fail)).

no

?- once((true,fail,true)).

no

?- once((fail,true,true)).

no