2010-01-20-trees - (define-struct interior (left right))...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname 2010-01-20-trees) (read- case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating- decimal #f #t none #f ())))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (define-struct interior (left right)) (define-struct leaf (value)) ( (define my-tree (make-interior (make-interior (make-leaf 5) (make-leaf 6)) (make-leaf 2))) (define (tree-sum t) (cond [(leaf? t) (leaf-value t)] [(interior? t) (+ (tree-sum (interior-left t)) (tree-sum (interior-right t)))] ))...
View Full Document

This document was uploaded on 02/12/2010.

Ask a homework question - tutors are online