learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-69.scm (746B)


      1 (import (srfi :64))
      2 (import (sicp solutions huffman-codes-stuff))
      3 
      4 '(make-code-tree
      5   (make-code-tree (make-leaf 'A 1)
      6                   (make-leaf 'B 1))
      7   (make-code-tree (make-leaf 'C 1)
      8                   (make-leaf 'D 1)))
      9 '(((leaf A 1) (leaf B 1) (A B) 2)
     10   ((leaf C 1) (leaf D 1) (C D) 2)
     11   (A B C D)
     12   4)
     13 
     14 (test-begin "chapter-2-exercise-69")
     15 (test-equal
     16     (make-leaf 'A 1)
     17   (generate-huffman-tree '((A 1))))
     18 (test-equal
     19     (make-code-tree (make-leaf 'A 1)
     20                     (make-leaf 'B 1))
     21   (generate-huffman-tree '((A 1) (B 1))))
     22 (test-equal
     23     sample-tree
     24   (generate-huffman-tree '((D 1)
     25                            (C 1)
     26                            (B 2)
     27                            (A 4))))
     28 (test-end "chapter-2-exercise-69")