> The procedure
>> (define (fib n)
> (cond [(or (= n 1) (= n 2)) 1]
> [else (+ (fib (- n 1)) (fib (- n 2)))]))
>> is a horrible example of recursion considering the number of recursive
> calls needed and the number of duplicated computations. That's why I could
> not withstand posting my example. :)
Well, "horrible" means different things in different contexts. My
posting was addressing the claim that the recursive definition is
"contrived." No claim was made that this is the best or most efficient
way of computing fib numbers. Issues of efficiency need to be studied,
but not while getting your first exposure to recursion.
The naive definition above is elegant, not contrived, and something
inexperienced students can understand. I would certainly not use
streams and fib numbers to teach recursion to those who are seeing it
for the first time.
Marco