member/2 has signature
member(?Elem, ?List) and denotes
Elem is a member of
List. This predicate can be used to access variables in a list, where different solutions are retrieved through backtracking.
?- member(X, [1,2,3]). X = 1 ; X = 2 ; X = 3. ?- member(X,[Y]). X = Y. ?- member(X,Y). Y = [X|_G969] ; Y = [_G968, X|_G972] ; Y = [_G968, _G971, X|_G975] ; Y = [_G968, _G971, _G974, X|_G978] ...
When the indices you need to access are small, pattern matching can be a good solution, e.g.:
third([_,_,X|_], X). fourth([_,_,_,X|_], X).