[plt-scheme] HtDP: Question on 10.1.9
I wouldn't bother with two definitions.
On Sep 18, 2008, at 11:38 PM, Grant Rettke wrote:
> 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
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme