Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (super-duper source count)
- (define (next-super source left)
- (if (zero? left)
- (super-duper (cdr source) count)
- (cons (super-duper (car source) count) (next-super source (- left 1)))))
- (if (pair? source)
- (cons (super-duper (car source) count) (next-super source (- count 1)))
- source))
- (display(super-duper '((x y) t) 3))
- (leaf-count (super-duper '(a (b (c (d (e f g (h i) j k) l m n o) p q ) r (s t (u v) w ) x y) z) 10))
- ->> 2576420
- (define (leaf-count Tree)
- (cond ((null? Tree) 0)
- ((not (pair? Tree)) 1)
- (else (+ (leaf-count (car Tree))
- (leaf-count (cdr Tree))))))
Add Comment
Please, Sign In to add comment