Match a specified argument of a compound term with another term. The integer value of the first variable indicates which argument of compound_term must be used for matching with term (the third argument). The index of the left-most argument is 1.
see also: copy_term/2 freeze/2 functor/3 get_term/2 melt/3 number_vars/3 =../2
| Examples | |
| arg(2, foo(a,b), X). | X=b |
| arg(1, test(w,r), X). | X=w |
| arg(1, foo(a,b), b). | fails |
| arg(3, foo(a,b), X). | fails, because foo has no 3 arguments |
| Exceptions | |
| N or Term is a variable | an instantiation_error exception is thrown |
| N is neither a variable nor an integer | a type_error(integer, N) exception is thrown |
| N is an integer less than zero | a domain_error(not_less_than_zero, N) exception is thrown |
| term is neither a variable nor a compound term | a type_error(compound, Term) exception is thrown |