[plt-scheme] HtDP: Another question on 10.1.9

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Sat Sep 20 10:42:19 EDT 2008

On Sat, Sep 20, 2008 at 7:34 AM, Grant Rettke <grettke at acm.org> wrote:
> On Sat, Sep 20, 2008 at 9:13 AM, Carl Eastlund <cce at ccs.neu.edu> wrote:
>> To be less
>> cryptic, if you read your purpose statement, and apply it to the
>> recursive call, does it make sense?
> No.
>> Are you really solving a smaller
>> instance of the same problem, or are you just solving a smaller
>> problem?
> A smaller problem.
>> The former is recursion; the latter is not (and suggests
>> either inlining or a helper function).
> Thanks, Carl and Matthias..

Glad to help.

For future reference, what I described is a way to tell after the fact
whether what you wrote makes sense as recursion, but what Matthias
described is the part of the design recipe that tells you whether to
use it or not before you even start.  Focus on what he said (and
what's in the book) for figuring out how to apply recursion, and
you'll find you can always answer what I asked with "yes".

Carl Eastlund

Posted on the users mailing list.