% CPSC 312
% Author: Steven Wolfman
% Released into the public domain

% my_length(List, N) is true when N is the length of List,
% where List is a list represented as the constant empty
% if it is empty and cons(X, Y) otherwise, where X is any
% element and Y is itself a list.
my_length(empty, 0).
my_length(cons(_, Rest), N) :- my_length(Rest, M), N is M+1.