SICP Exercise 1.6 / SICP 연습문제 1.6
SICP Exercise 1.6 / SICP 연습문제 1.6
If you've run the problem does not know the answer, but only consume CPU resources.
This problem seems to be that in a study on the issue in applicative order evaluation.
The following example shows the original if statement.
문제를 실행해 보셨다면 알겠지만 CPU자원만 소모할뿐 답을 주지 않습니다.
이 문제는 applicative order evaluation에서 발생하는 문제에 대한 고찰을 하게 해주는것 같습니다.
아래 예제는 기존 if문입니다.
| (define trueMessage "it`s true") (define falseMessage "it`s false") falseMessage (if (= 3 3) trueMessage (set! falseMessage "else work!")) falseMessage -------------------------------------------- result "it`s false" "it`s true" "it`s false" | cs |
The results do not appear to differ from the stars.
However, new-if contact results are a little different.
별다를것 없는 결과물이 나옵니다.
그러나 new-if문의 결과물은 좀 다릅니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | (define (new-if predicate then-clause else-clause) (cond (predicate then-clause) (else else-clause))) (define trueMessage "it`s true") (define falseMessage "it`s false") falseMessage (new-if (= 3 3) trueMessage (set! falseMessage "else work!")) falseMessage -------------------------------------------- result "it`s false" "it`s true" "else work!" | cs |
applicate order evaluation scheme language, but the way
In the if statement looks like a crown nomal order evaluation applied.
Therefore, if the evaluation applicate order to run through the new-if newton method is applied will fall into an infinite loop.
scheme언어가 applicate order evaluation 방식이지만
if문에 있어서는 nomal order evaluation이 적용 되는것 같아보입니다.
그러므로 applicate order evaluation이 적용되는 new-if를 통해 newton method를 실행할경우 무한루프에 빠지게 됩니다.