From: Ramakrishnan Muthukrishnan Date: Wed, 15 Sep 2010 18:22:05 +0000 (+0530) Subject: solution to 2.67 X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/frontends/FOOURL?a=commitdiff_plain;h=91f1f1e211d8d46eb6b5933f16fc805fbaa54607;p=sicp.git solution to 2.67 --- diff --git a/src/sicp/ex2_67.rkt b/src/sicp/ex2_67.rkt new file mode 100644 index 0000000..a740f05 --- /dev/null +++ b/src/sicp/ex2_67.rkt @@ -0,0 +1,15 @@ +#lang racket + +(require "ch2_3.rkt" + rackunit) + +;; Exercise 2.67. Define an encoding tree and a sample message: +(define sample-tree + (make-code-tree (make-leaf 'A 4) + (make-code-tree + (make-leaf 'B 2) + (make-code-tree (make-leaf 'D 1) + (make-leaf 'C 1))))) +(define sample-message '(0 1 1 0 0 1 0 1 0 1 1 1 0)) + +(check equal? (decode sample-message sample-tree) '(A D A B B C A)) \ No newline at end of file