[plt-scheme] HtDP: Question on 10.1.9

From: Grant Rettke (grettke at acm.org)
Date: Thu Sep 18 23:38:37 EDT 2008

Hi folks,

Is this data definition "going overboard" for 10.1.9?

;; A controller-cent-amount is either
;; 1. (cons 1 (cons 'cent empty)) or
;; 2. (cons n (cons 'cents empty)) where n is a non-negative number
not equal to 1

;; A controller-dollar-amount is either
;; 1. (cons 1 (cons 'dollar (cons 'and controller-cent-amount))) or
;; 2. (cons n (cons 'dollars (cons 'and controller-cent-amount)))
where n is a non-negative number not equal to 1

;; A controller-result is either
;; 1. controller-cent-amount or
;; 2. controller-dollar-amount

;; controller : number -> controller-result
;; to determine the description of the amount n

It certainly made it easy to write using cond.

Best wishes,

Grant


Posted on the users mailing list.