(load "2.33.txt") ; for accumulate (define (count-leaves t) (accumulate + 0 (map (lambda (n) (if (list? n) (count-leaves n) 1)) t))) ; 1 ]=> (count-leaves '()) ; ; ;Value: 0 ; ; 1 ]=> (count-leaves '(1 2 3)) ; ; ;Value: 3 ; ; 1 ]=> (count-leaves '(1 (2 3) (((4) 5) 6 7) 8)) ; ; ;Value: 8