[plt-scheme] HtDP: Question on 10.1.9

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Sep 19 10:08:31 EDT 2008

  	
Here I am responding to myself -)

This problem is a bit of a "look ahead" or "cheat" given to where I  
am posing it.

Why? In general, it's a "parsing" problem and as such deserves a  
"structural output" recipe. PLAI is the correct place to look for  
this. For "freshmen" it's too challenging.

** The structure of the INPUT does not help you at all when you solve  
this problem.

** The structure of the OUTPUT though suggests an organization and  
arithmetic operations that help.

So yes, DATA Defs are good simply because they help you wrap your  
head around the problem. But they do not suggest a template in the  
sense of HTDP.

-- Matthias






On Sep 19, 2008, at 8:19 AM, Matthias Felleisen wrote:

>
> 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
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.