Of course, it's pretty simple. I'm not giving a straight answer because this looks like homework and anyway it's trivial to write. Fill-in the blanks:
(define (length lst)
(if <???> ; if the list is empty
<???> ; return 0
(<???> ; otherwise add 1 and
(length <???>)))) ; advance the recursion over the rest of the list
Notice that only cdr
is used. We're not interested in the actual contents of the list, so we can ignore car
.