Reputation: 6018
I've read the SO questions what does slash(/) do in prolog? and What is the meaning of predicate “simple/1” in Prolog (SWI-Prolog), but these links don't seem to help me.
I was going though some beginner tutorials on Prolog.
Phrases like Solve/4
or Go/1
confused me. What does that slash and number mean?
Upvotes: 12
Views: 3204
Reputation: 4392
As EMS and Chac explained this number denotes number of arguments. The reason why you will find this number in documentation is because predicates with same name and different arity (number of arguments) are different predicates.
So predicate:
my_predicate/3
is different predicate from:
my_predicate/4
and number is included to give clear indication about which one them is being talked about.
Upvotes: 3
Reputation: 60004
I cite from page 8 of 'Prolog: The Standard: Reference Manual' (the 2^ entry when I googled 'prolog predicate indicator').
Predicate indicator ... It's a ground term of the form Name/Arity
The ISO builtin functor/3 accesses such data
?- functor(append(a,b,c),Name,Arity).
Name = append,
Arity = 3.
Upvotes: 2
Reputation: 77404
It is the number of arguments that the function expects in its signature. Be careful of infix operators, which can accept multiple arguments even if the way they are called is by placing them in between the arguments. That is, you can think of something like ordinary addition, +
, as a binary operator. So A+B
is really the same as +(A,B)
, which means you would define +
with +/2
.
Upvotes: 16