Guest User

Untitled

a guest
Sep 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. (define (super-duper source count)
  2. (define (next-super source left)
  3. (if (zero? left)
  4. (super-duper (cdr source) count)
  5. (cons (super-duper (car source) count) (next-super source (- left 1)))))
  6.  
  7. (if (pair? source)
  8. (cons (super-duper (car source) count) (next-super source (- count 1)))
  9. source))
  10.  
  11. (display(super-duper '((x y) t) 3))
  12.  
  13. (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))
  14. ->> 2576420
  15.  
  16. (define (leaf-count Tree)
  17. (cond ((null? Tree) 0)
  18. ((not (pair? Tree)) 1)
  19. (else (+ (leaf-count (car Tree))
  20. (leaf-count (cdr Tree))))))
Add Comment
Please, Sign In to add comment