Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Flatten tree then count
- (define (count-leaves0 t)
- (accumulate (lambda (x total) (+ total 1)) 0
- (map (lambda (children) children)
- (enumerate-tree t))))
- (define (count-leaves1 t)
- (accumulate + 0
- (map (lambda (children)
- (if (pair? children)
- (count-leaves1 children)
- 1))
- t)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement