sitelogo
arg/3

relates a term and one of its arguments.

arg(+N, +CompoundTerm, -Argument)

arg/3 unifies Argument with the N-th argument of CompoundTerm.

Arguments

N                      integer (between 1 and the arity of CompoundTerm)
CompoundTerm           compound term
Argument               term

Examples

arg(1, f(a,b,c), X). Succeeds with substitution X <- a.
arg(2, f(X, g((a,h(a,b))), g(a,Z)). Succeeds with substitution Z <- h(a,b)
arg(3,f(a,b),X). Fails.

Standard

This predicate is part of the ISO-Prolog Standard.

See also

copy_term/2, functor/3, '=..'/2.


Up read on...
scroll to top managed with ubiCMS