Modification of the basic if expression in Scheme. Why does it go into an infinite loop?
问题 In Scheme, I modified the basic 'if' command as: (define (modified-if predicate then-clause else-clause) (if predicate then-clause else-clause)) And then I defined a simple factorial generating program using the modified version of if: (define (factorial n) (modified-if (= n 0) (* n (factorial (- n 1))))) Now, when I call the above function, it goes into an infinite loop. Why does that happen? 回答1: Scheme has eager evaluation. This means that, unless you're using a special form (like if ) or