Question

Example:

conditions([-on(a, b)]).

I have searched tirelessly but fruitlessly for the meaning of this and the + prefix. You are my last hope.

Was it helpful?

Solution

No context is provided, so I'm supposing this might come from something in documentation.

If you read the introductory material in the Prolog manual (SWI, Gnu, or whichever) they describe teh conventions. The +, -, and ? are used as a convention in documentation to indicate whether an variable is an input or an output or a variable (either). For example, from the Gnu Prolog manual:

+: the argument must be instantiated.

-: the argument must be a variable (will be instantiated if the built-in predicate succeeds).

?: the argument can be instantiated or a variable.

So, for example, atom_length/2 is described as;

atom_length(+atom, ?integer)

Which means you must provide atom (it can't be a variable) and integer can either be a variable (in which case atom_length will provide a value) or it can be instantiated (in which case atom_length will indicate whether your query is true or false)`.

You don't normally use the - or + in your code in this sense, unless you really intend to have it there as part of your term. Considering the given example, it looks like it may have been an intended part of the term:

conditions([-on(a, b)]).

The list parameter consists of a term, when spelled out fully, is -(on(a,b)) (-/1 with parameter that's on/2). The - here doesn't provide any function, it just adds structure (the structure being a term with name - and parameter on(a,b)).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top