[Edu-sig] Re: Lisp vs Scheme vs Python

Kirby Urner pdx4d@teleport.com
Mon, 28 May 2001 10:54:42 -0700


At 12:18 PM 5/28/2001 -0500, Matthias Felleisen wrote:
>
>No recursion is not gratuitous with quicksort and fractals. It's necessary
>there. Eliminating it means you manage your own stack, and I bet you're not 
>as good at that as Guido. 

Convenient with fractals, sure, but why necessary?  What stack management?
Just iterate by adding 1 and multiply the growing product until 
term = n.

The model in mathematics, for fractals, is akin to SIGMA notation,
except using the capital letter PI, which means multiply terms 
together vs. add them.  So:

                 n
            n! = PI  j
                 j=1

That's a "primitive definition" in a math textbook, and there's 
nothing recursive about it, any more than in:

                     n
            tri(n) = SIGMA j
                     j=1

i.e. the nth triangular number, also equal to n*(n+1)/2.

>_Teaching_ recursion first, followed by abstraction (of which iterators are
>just one simple part) is not inward looking. It is _empowering_ programmers
>and _empowering_ people who wish to learn to think systematically. 

If all you have is a hammer, everything looks like a nail.  I just 
don't want recursion to be the hammer.  We have a variety of tools, 
of which recursion is one.  It should be taught -- not sure about 
first though.  By the time students get to programming, they probably
already have experience with iterative, non-recursive processing, 
so it's already too late to teach recursion before anything else.

>Of course I prefer 
>
> (map (lambda (x) (* x 2)) (build-list 10 identity))
>
>over whatever goble-dee-gook the recursive defs look like. But I thought
>this list was about teaching, empowering people with programming, and using
>programming to empower people to think (the way stupid old math used to
>do).
>
>-- Matthias

Yes, map(lambda x: x*2, range(10)) also works in Python.

So if you prefer it, would you teach students to write it this
way?  I've suspicious of curricula in which the most 
"formally correct" way to do something is out of sync with the 
practical way of doing it.  I'm not a huge fan of the Bourbaki 
school of thought, either, for much the same reason.

Kirby