home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0963.lha
/
SIOD
/
scm
/
level-read.scm
< prev
next >
Wrap
Text File
|
1993-02-22
|
673b
|
21 lines
(define (depth tree)
(if (empty-tree? tree)
0
(max (1+ (depth (left-branch tree)))
(1+ (depth (right-branch tree))))))
(define (level-n tree n lev)
(cond ((empty-tree? tree) '())
((= lev n) (list (entry tree)))
(else (append (level-n (left-branch tree) n (1+ lev))
(level-n (right-branch tree) n (1+ lev))))))
(define (level-all tree lev max-lev)
(if (> lev max-lev)
'()
(append (level-n tree lev 0)
(level-all tree (1+ lev) max-lev))))
(define (level-read tree)
(level-all tree 0 (depth tree)))