Re: Simple recursive functions in Lisp



+ "Harold Lee" <harold3@xxxxxxxxx>:

| You can prove the correctness of a recursive program more easily.

I don't think it's any harder to prove a well-written iterative
algorithm correct than the corresponding recursion. In either case
it's typically a case of finding the proper invariant and then proving
that it is in fact invariant, and that it implies the the desired exit
condition at termination.

Spaghetti code can of course be hard to prove correct, even if it is.
Maybe the functional style makes it harder to write spaghetti code,
and if so that could be the reason it is claimed to be more easily
proved correct.

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
.