From 91f1f1e211d8d46eb6b5933f16fc805fbaa54607 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com> Date: Wed, 15 Sep 2010 23:52:05 +0530 Subject: [PATCH] solution to 2.67 --- src/sicp/ex2_67.rkt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/sicp/ex2_67.rkt 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 -- 2.45.2