longitud([], 0).
longitud([X|Xs], N) :- longitud(Xs, N1), N is N1 + 1.
 
?- longitud([2,4,6,8], X), write('longitud: '), writeln(X).