11

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?

Community
  • 1
  • 1
Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130

3 Answers3

15

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.

ely
  • 74,674
  • 34
  • 147
  • 228
3

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.

Davorin Ruševljan
  • 4,353
  • 21
  • 27
2

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.
CapelliC
  • 59,646
  • 5
  • 47
  • 90