diff --git a/02-trees/main.rkt b/02-trees/main.rkt index baee183..d4c28bf 100644 --- a/02-trees/main.rkt +++ b/02-trees/main.rkt @@ -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)]