========================================================== ====================================
;
; Structure and Interpretation of Computer Programs
; (Trial answer to excercises)
;
The construction and interpretation of computer programs (exercises)
;
; Created: code17 02/24/05
; Modified:
; (The content can be reproduced without changing the content)
; ========================================================== ====================================
; SICP No.1.5
; This topic is entitled Understanding questions
; (Define (p ))
;;
; Is equivalent to defining an infinite recursive function p, p as the operator, with 0 operant as the parameter. By definition
; It can be seen that (p) will be evalute as (p), and (p) and then evaluate as (p). Endless.
; P itself as a procedure is no problem, we allow defining recursive functions, but when p acts on operant
;, (P) is problematic because its evaluation is infinitely recursive. Therefore, in scheme,
; () Is not only a priority control tool, but a semantic control tool that cannot be ignored. P is a function,
; While (p) is the return value after FUNCTION p acts on its parameters (0.
;;
; Test-it:
; Welcome to MzScheme version 209, Copyright (c) 2004 PLT Scheme, Inc.
;> (Define (p ))
;> P
; # <Procedure: p>
;> (P)
; The interaction interpreter has no response here
; (Define (test x y)
; (If (= x 0)
; 0
; Y ))
; (Test 0 (p ))
;;
; Therefore, the results of the test function in the evaluation sequence of different principles can be easily inferred. In
; Under the normal-order evaluation principle, only when the value of an expression is required
; Evaluation, (test 0 (p) will be evaluate as (if (= 0 0) 0 (p )),
; Because the judgment condition is true, the final expression evaluate is 0, and the (p) value does not need to be calculated.
; To avoid infinite recursion; and under the applicative-order principle, all
; Operants must evaluate before substitution, so (p) calculation cannot be avoided, and the result is infinite recursion.
;;
; Test-it:
;> (Test 0 (p ))
; The interaction interpreter loses response here because scheme uses applicative-order evaluation
; If we define
; (Define (p)
; Is another meaning, it defines a function with 0 operant p, when it acts on its operant
;, The return value is set to itself, so that (p) is evaluate to p, then (p) is evaluate
; (P) and then evaluate as p, then (p ))))))
;;
; Test-it:
;> (Define (p)
;> P
; # <Procedure: p>
;> (P)
; # <Procedure: p>
;> (P ))
; # <Procedure: p>
;> )))))))))))))))) )))))))
; # <Procedure: p>