projects
/
lambda.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refine again
[lambda.git]
/
topics
/
week7_combinatory_evaluator.mdwn
diff --git
a/topics/week7_combinatory_evaluator.mdwn
b/topics/week7_combinatory_evaluator.mdwn
index
9c3ac87
..
34c4e1c
100644
(file)
--- a/
topics/week7_combinatory_evaluator.mdwn
+++ b/
topics/week7_combinatory_evaluator.mdwn
@@
-365,14
+365,14
@@
wait until we have Continuation Passing Style transforms.
The answer to the first question (Can we adjust the OCaml evaluator to
exhibit lazy behavior?) is quite simple:
The answer to the first question (Can we adjust the OCaml evaluator to
exhibit lazy behavior?) is quite simple:
- let rec reduce_
lazy
(t : term) : term = match t with
+ let rec reduce_
try3
(t : term) : term = match t with
| I -> I
| K -> K
| S -> S
| App (a, b) ->
| I -> I
| K -> K
| S -> S
| App (a, b) ->
- let t' = App (reduce_
lazy
a, b) in
+ let t' = App (reduce_
try3
a, b) in
if (is_redex t') then let t'' = reduce_if_redex t'
if (is_redex t') then let t'' = reduce_if_redex t'
- in reduce_
lazy
t''
+ in reduce_
try3
t''
else t'
There is only one small difference from `reduce_try2`: instead of setting `t'` to `App
else t'
There is only one small difference from `reduce_try2`: instead of setting `t'` to `App
@@
-381,9
+381,9
@@
There is only one small difference from `reduce_try2`: instead of setting `t'` t
subexpression at all. Ever! The only way to get evaluated is to
somehow get into functor position.
subexpression at all. Ever! The only way to get evaluated is to
somehow get into functor position.
- # reduce3 (App(App(K,I),skomega));;
+ # reduce
_try
3 (App(App(K,I),skomega));;
- : term = I
- : term = I
- # reduce3 skomega;;
+ # reduce
_try
3 skomega;;
C-c C-cInterrupted.
The evaluator now has no trouble finding the normal form for `KIΩ`,
C-c C-cInterrupted.
The evaluator now has no trouble finding the normal form for `KIΩ`,