#python #sicp
Treating a
recursive call as a functional abstraction has been called a recursive leap
of faith. We define a function in terms of itself, but simply trust that the
simpler cases will work correctly when verifying the correctness of the
function.
If you want to change selection, open document below and click on "Move attachment"
1.7 Recursive Functionsputation, it is often
clearer to think about recursive calls as functional abstractions. That is, we
should not care about how fact(n-1) is implemented in the body of fact ;
we should simply trust that it computes the factorial of n-1 . <span>Treating a
recursive call as a functional abstraction has been called a recursive leap
of faith. We define a function in terms of itself, but simply trust that the
simpler cases will work correctly when verifying the correctness of the
function. In this example, we trust that fact(n-1) will correctly compute
(n-1)! ; we must only check that n! is computed correctly if this
assumption holds. In this way, verifying the corre Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details