List Length
List Length Function using Prolog Source Code
The following code returns the length of a given list
CODE
length([],0).
length([H|T],R+1) :- length(T,R).
RESULT
?- length([a,b,c],Z).
Z = 3
Yes
The following code returns the length of a given list
CODE
length([],0).
length([H|T],R+1) :- length(T,R).
RESULT
?- length([a,b,c],Z).
Z = 3
Yes