By giving an example of such a code given below in SIC, the author explains how to solve a factual problem To use the process: Define (fact1) (fact 1) 1 (n) (define (actual object product counter counter-count) (if (& gt; counter max- Counting product (fact-maker (counter product) (+ counter 1) maximum-count)))
And say that "It may seem disturbing that we refer to a recursive process like creating a reality, it is a repetition process. However, this process actually moves: its position is completely captured by its three state variables. , And an interpreter needs to keep track of only three variables in order to execute this process. " I do not understand What does it mean Ekk. What is the difference between recursive process and a recursive process? And why did he repeat the recurrent process after making the repetition process? A recursive process needs to maintain the position of the caller, For example, if the recursive call is in progress, if you have written: Since the parameters of the external call are no longer required, the recurring call can be translated into the assignment again: and then just jumps at the beginning of the process. (Set!
(define (fact-recurs, en) (if (& lt; n 2) 1 (* n (fact- Remember the external call to
n and wait for multiplying the inner call before multiplying it. P> Em>, the first state can be abandoned. This example code is possible because all the necessary information has been passed as a parameter in the recursive call. Variables are not required in an external call, so nothing should be kept on the stack.
(set! Product (* counter product)
No comments:
Post a Comment