Another Tree Recursion Example
Counting the number of atoms in an embedded list
(define count
(lambda (l)
(cond ((null? l) 0)
((atom? (car l))
(add1 (count (cdr l))))
(else (+ (count (car l))
(count (cdr l)))))))
Previous slide
Next slide
Back to first slide
View graphic version