[ Term Manipulation | Reference Manual | Alphabetic Index ]
Succeeds if Arity is the arity of Term.
- Prolog term.
- Variable or integer.
If Term is instantiated, its arity (number of arguments) is unified
with Arity. For compound terms, this is the number of arguments,
for atomic terms it is 0. As usual, non-empty lists are considered
compound terms with arity 2.
Note that (like all predicates that return a number as their last
argument), this predicate can be used as a function inside arithmetic
..., (I > arity(Term) -> writeln(error), fail ; arg(I, Term, Arg) ).
Modes and Determinism
- (4) instantiation fault
- Term is uninstantiated (non-coroutine mode only).
arity(f(1,2),A). (gives A=2).
arity(,A). (gives A=0).
arity("s",A). (gives A=0).
arity(33,A). (gives A=0).
arity(_,A). (Error 4).
=.. / 2, arg / 3, functor / 3