문제

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