11.3.137 \+/1   ISO

Synopsis

\+ +P

Fails if the goal P has a solution, and succeeds otherwise. Equivalent to:

call(P) -> fail ; true.

except that the use of call/1 often can be avoided.

Arguments

:P

callable, must be nonvar

Description

This is not normally regarded as a built-in predicate, since it is part of the syntax of the language. However, it is like a built-in predicate in that you can say call((\+ P)).

Cuts in P do not make sense, but are allowed, their scope being the goal P.

Comments

Remember that with prefix operators such as this one it is necessary to be careful about spaces if the argument starts with a ‘(’. For example:

| ?- \+ (P,Q).

is this operator applied to the conjunction of P and Q, but

| ?- \+(P,Q).

would require a predicate \+ /2 for its solution. The prefix operator can however be written as a functor of one argument; thus

| ?- \+((P,Q)).

is also correct.

Exceptions

Call errors (see ref-sem-exc).

See Also

ref-sem.


Send feedback on this subject.