(define (enumerate-interval low high)
(if (> low high)
'()
(cons low (enumerate-interval (+ low 1) high))))
(define (enumerate-tree tree)
(cond ((null? tree) '())
((not (pair? tree)) (list tree))
(else (append (enumerate-tree (car tree))
(enumerate-tree (cdr tree)))))
(display (enumerate-tree (list 1 (list 2 (list 3 4) 5)))))
(newline)
(enumerate-tree (list 1 (list 2 (list 3 4) 5)))
KGRlZmluZSAoZW51bWVyYXRlLWludGVydmFsIGxvdyBoaWdoKQogICAgICAgIChpZiAoPiBsb3cgaGlnaCkKICAgICAgICAgICAgICAgICcoKQogICAgICAgICAgICAgICAgKGNvbnMgbG93IChlbnVtZXJhdGUtaW50ZXJ2YWwgKCsgbG93IDEpIGhpZ2gpKSkpCgooZGVmaW5lIChlbnVtZXJhdGUtdHJlZSB0cmVlKQogICAgICAgIChjb25kICgobnVsbD8gdHJlZSkgJygpKQogICAgICAgICAgICAgICgobm90IChwYWlyPyB0cmVlKSkgKGxpc3QgdHJlZSkpCiAgICAgICAgICAgICAgKGVsc2UgKGFwcGVuZCAoZW51bWVyYXRlLXRyZWUgKGNhciB0cmVlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChlbnVtZXJhdGUtdHJlZSAoY2RyIHRyZWUpKSkpKQoKCihkaXNwbGF5IChlbnVtZXJhdGUtdHJlZSAobGlzdCAxIChsaXN0IDIgKGxpc3QgMyA0KSA1KSkpKSkKKG5ld2xpbmUpCihlbnVtZXJhdGUtdHJlZSAobGlzdCAxIChsaXN0IDIgKGxpc3QgMyA0KSA1KSkpCg==