Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;teil 2
- (define code
- (lambda (tree message)
- (if (empty? message)
- empty
- (append (code-symbol tree (first message))
- (code tree (rest message))))))
- (define code-symbol
- (lambda (tree symbol)
- (cond ((empty? (first (node-symbols tree))) (violation "Symbol nicht im Tree"))
- ((help-symbolsearch (node-symbols tree) symbol)
- (cond ((help-symbolsearch (node-symbols (node-left tree)) symbol) (cons 0 (code-symbol (node-left tree) symbol)))
- ((help-symbolsearch (node-symbols (node-right tree)) symbol) (cons 1 (code-symbol (node-left tree) symbol))))))))
- (define help-symbolsearch
- (lambda (s symbol)
- (cond ((empty? (first s)) (violation "Symbol nicht im Tree"))
- ((string=? (first s) symbol) #t)
- (else (help-symbolsearch (rest s) symbol)))))
Add Comment
Please, Sign In to add comment