[plt-scheme] HtDP: Another question on 10.1.9

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Sep 20 09:15:16 EDT 2008

In HtDP, the word "natural" is a technical word. It means

  if your INPUT data definition has a self-reference in the Nth  
clause for the Kth field
  then your template has a recursion in the Nth cond clause for the  
Kth field.

For Part II, N is usually 1 or 2 and K is also usually 1 or 2.

Try this:

An RD is one of:
  -- 'doll
  -- (cons RD empty)

Problem: design a function that counts the number of cons layers  
around 'doll.

-- Matthias

On Sep 19, 2008, at 11:44 PM, Grant Rettke wrote:

> On Fri, Sep 19, 2008 at 7:29 PM, Carl Eastlund <cce at ccs.neu.edu>  
> wrote:
>> On Fri, Sep 19, 2008 at 10:51 AM, Grant Rettke <grettke at acm.org>  
>> wrote:
>>> I followed (abused?) a recipe by using cond and having the first
>>> clause handle any amount under 100. It looks like this:
>>> (cond
>>>    [(< n 100) <cents part goes here>]
>>>    [else (cons <dollar amount and natural recusion occur here>)])
>> Natural recursion?  What's so natural about it?
> You don't need to do all of the work at once, you handle the part that
> you need and let the function do the rest of it. In this case, the
> rest is everything under 100. Is this a valid approach if there is
> only one recursive step?
> Or were you just giving me a hard time with your reply?
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.