Updated again.
This commit is contained in:
+3
-1
@@ -21,13 +21,15 @@
|
||||
; Tree t -> Bool
|
||||
; Determines whether a Tree is a binary search tree.
|
||||
(define (bst? t)
|
||||
(local [; Convenient form of greater than.
|
||||
(local [; <2: U{Num, Sym}, Num, U{Num, Sym} → Bool
|
||||
; Convenient form of greater than. Slightly hack.
|
||||
(define (<2 a b c)
|
||||
(cond [(and (symbol? a) (symbol? c)) #t]
|
||||
[(symbol? a) (< (- b 1) b c)]
|
||||
[(symbol? c) (< a b (+ b 1))]
|
||||
[else (< a b c)]))
|
||||
|
||||
; recurse: t: Tree, lower: Num, upper: Num → Bool
|
||||
; Recursively checks left & right with lower & upper bounds.
|
||||
(define (recurse t lower upper)
|
||||
(cond [(symbol? t) (symbol=? t 'end)]
|
||||
|
||||
Reference in New Issue
Block a user