-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path1.5.txt
More file actions
executable file
·50 lines (32 loc) · 785 Bytes
/
Copy path1.5.txt
File metadata and controls
executable file
·50 lines (32 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(define (p) (p))
(define (test x y)
(if (= x 0)
0
y))
(test 0 (p)) ;Test
Application: Applicative order evaluation evaluates the operand sub expressions
before evalutating the operator with the results. (p) evaluates to (p) so :
(test 0 (p))
reduces to
(test 0 (p))
which reduces to
(test 0 (p))
and so on.
(test 0 (p))
(test 0 (p))
(test 0 (p))
Compare the above to
(define z (7 + 1))
using
(test 0 z)
which reduces to
(test 0 (7+1))
(test 0 8)
(if (= 0 0) 0)
(if true 0)
0
The first expression (test 0 (p)) using applicative ordering never allows its second
operand to fully evaluate, therefor cannot continue reducing.
Normal-order:
evaluates to 0 because (p) is never needed. Normal order evaluation only
evaluates operands when ABSOLUTELY needed.