Newsgroups: comp.lang.dylan,comp.lang.lisp,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!uunet!news.claremont.edu!paris.ics.uci.edu!csulb.edu!csus.edu!netcom.com!NewsWatcher!user
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Recursion where iteration would do
Message-ID: <hbaker-2803950742320001@192.0.2.1>
Sender: hbaker@netcom6.netcom.com
Organization: nil
References: <18426.9503201324@subnode.aiai.ed.ac.uk> <1995Mar23.150306.4307@VFL.Paramax.COM> <3l1r10$2ib@Yost.com> <3l25ju$2ns@Yost.com> <3l40l1$cpg@agate.berkeley.edu>
Date: Tue, 28 Mar 1995 15:38:44 GMT
Lines: 44
Xref: glinda.oz.cs.cmu.edu comp.lang.dylan:3900 comp.lang.lisp:17228 comp.lang.scheme:12433

In article <3l40l1$cpg@agate.berkeley.edu>, bh@anarres.CS.Berkeley.EDU
(Brian Harvey) wrote:

> yost@Yost.com (Dave Yost) writes:
> >David Lee Matuszek <dave@gvls1.vfl.paramax.com> wrote:
> >>Sadly, every textbook that I know of teaches just the opposite: that to
> >>understand recursion, you have to step through multiple levels.  This is
> >>Wrong.
> >
> >Using recursion when iteration would do has always bothered me...
> >When I look at iteration code, I know right away not to expect
> >anything more complex than a simple linear iteration.
> 
> In _Simply Scheme_, we take pains to teach that in understanding a recursion
> one should take the lower levels on faith.
> 
> Since beginners often find this mysterious, we introduce the idea by first
> artificially writing the one recursive procedure
>         (define (foo L) (... (foo (cdr L)) ...))
> as several separate procedures, one for each size argument:
>         (define (foo5 L) (... (foo4 (cdr L)) ...))
> but working up from the base case.  This means that at each step, everything
> is firmly grounded in things we already know to work.  Then we observe that
> all but one of the foo_n procedures are identical, and this leads us to the
> recursive form.

This is a very good approach for budding Computer Scientists.

The nice thing about this teaching technique is that it leads directly
to an understanding of the Y combinator and the 'least-fixed-point' lattice
theory of approximations to functions.

E.g., the Y combinator lazily produces foo5 'just-in-time' when foo5 is
required.

(See ftp://ftp.netcom.com/pub/hb/hbaker/ForthStack.html & .ps.Z for more
about Y combinators.)

The continuous functional approach shows that the recursive function is
the mathematical limit of foo1, foo2, foo3, ...

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
