2

I am teaching myself Prolog and have been given a handful of examples.

One of which uses the dynamic/1 built-in directive:

:- dynamic(items/1).

I get the idea of dynamic. That one can modify predicates via the assert, and retract predicates.

However, the program also uses the following in places:

:- dynamic(location/2).

What is the difference between the two /1 and /2, is their also a /3 .... /n?

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Andrew S
  • 2,847
  • 3
  • 33
  • 50

1 Answers1

2

In Prolog, predicates are identified by their name (or functor) and their number of arguments (or arity). Thus, items/1 denotes a predicate with functor items and arity 1 while location/2 denotes a predicate with functor location and arity 2. Two predicates with the same functor but different arities are different predicates.

Paulo Moura
  • 18,373
  • 3
  • 23
  • 33