arg(+ArgNum, +Term, -Arg)
unifies Arg with the ArgNumth argument of term Term.
integer, must be nonvar and positive
compound, must be nonvar
The arguments are numbered from 1 upwards.
if ArgNum or Term is unbound.
if ArgNum is not an integer, or Term is not compound.
if ArgNum is an integer less than zero.
| ?- arg(2, foo(a,b,c), X). X = b