سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top