11.3.7 arg/3 [ISO]

Synopsis

arg(+ArgNum, +Term, -Arg)

unifies Arg with the ArgNumth argument of term Term.

Arguments

ArgNum
integer, must be nonvar and positive
Term
compound, must be nonvar
Arg
term

Description

The arguments are numbered from 1 upwards.

Exceptions

instantiation_error
if ArgNum or Term is unbound.
type_error
if ArgNum is not an integer.

Examples

     | ?- arg(2, foo(a,b,c), X).
     
     X = b

See Also

functor/3, =../2, ref-lte-act.


Send feedback on this subject.