Define a third predicate so that thirdXY says that Y is the
Define a third predicate so that third(X,Y) says that Y is the third element in the list. The predicate should fail if X has fewer than three elements in the list.
Solution
A predicate to compute the third element of a list (fails if the list has less elements).
?- third([a,b,c,d],X).
X = c
yes
?- third([a,b],X).
No
Solution: third([_,_,X|_],X).
