I think they were referring to the fact that the value of F(n) can be
calculated faster that to calculate all the values between F(0) and
F(n). Unfortunately, that's not what the question was.
Yep. And it's Rather Less Suboptimal to adapt an iterative or tail-
recursive single-value calculation to print all the preceding values as
well than to do the same with a closed-form calculation.
(I'd actually thought RH was referring to the suboptimality of an
iterative or recursive solution that only passes around one value at
a time. That would have been Rather Suboptimal.)
I like your lisp code
.
It wasn't lisp. Well, it might have been lisp, but it wasn't Lisp.
(At least, I don't think so.) If I'm not mistaken, Common Lisp puts
functions and ordinary values in different namespaces and gives you a hoop
to jump through to call a function through an ordinary name (as opposed
to through a name used to define a function), which Scheme doesn't.
For bonus points, what was the bug? (It's a fairly simple one, you
should be able to find it by careful inspection even if you don't know
the language, and it'll show up pretty obviously if you try to run it.)
dave
(you really thought I'd post a bug-free homework solution, even in the
wrong language?)