I'm writing a bunch of very simple LISP elements, one of which is
a function that count the number of ocurrences of an element
in a list with normal recursion (it's a piece of cake),
but in my Computer Language class I'm required to do it with tail recursion
(define (cuenta lista elemento)
(if (pair? lista elemento) (+ (cuenta car(lista) elemento)
(cuenta cdr(lista) elemento) )
if (equal? lista elemento) 1 0 )))
In tail recursion, how do I accumulate the results of the partial
solutions
Any help or ideas shall be appreciated,
Rafael Algara Torre
ITESM, Monterrey Mexico.