EX 2.67

Tue, 2006/09/19 - 09:15 — netawater
(define (make-leaf symbol weight)
(list 'leaf symbol weight))
(list 'leaf symbol weight))
(define (leaf? object)
(eq? (car object) 'leaf))
(define (symbol-leaf x) (cadr x))
(define (weight-leaf x) (caddr x))
(define (make-code-tree left right)
(list left
right
(append (symbols left) (symbols right))
(+ (weight left) (weight right))))
(define (symbols tree)
(if (leaf? tree)
(list (symbol-leaf tree))
(caddr tree)))
(define (weight tree)
(if (leaf? tree)
(weight-leaf tree)
(cadddr tree)))
(define (left-branch tree) (car tree))
- Login to post comments
- 1025 reads
|
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |