Documentation last/2
available from version beta

last/2

Last element of a list.

Description

last( ?list, ?last )

last(List, Last) is true if and only if Last is the last element on the list List.

Examples

published on 2017-12-13
?- last([1,2,3], 3).
%  true.

?- last([1,2,3], 4).
%  false.

?- last(List, 3).
% List = [3] ;
% List = [_2, 3] ;
% List = [_2, _6, 3] ;
% List = [_2, _6, _10, 3] ;
% ...

?- last([1,2,3], Last)
% Last = 3.

Implementation