This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- The meta-circular interpreter from section 5 of Reynolds's Definitional | |
| -- Interpreters for Higher Order Programming Languages | |
| -- (http://www.cs.uml.edu/~giam/91.531/Textbooks/definterp.pdf) | |
| data EXP | |
| = CONST Const | |
| | VAR Var | |
| | APPL Appl | |
| | LAMBDA Lambda | |
| | COND Cond |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cons = fn (a, b) -> fn x -> x.(a, b) end end | |
| car = fn (p) -> p.(fn (q, _) -> q end) end | |
| cdr = fn (p) -> p.(fn (_, q) -> q end) end | |
| each = fn (list, func) -> | |
| iter = fn (list, func, next) -> | |
| (fn (a, nil) -> func.(a) | |
| (a, b) -> func.(a); next.(b, func, next) | |
| end).(car.(list), cdr.(list)) | |
| end | |
| iter.(list, func, iter) |
OlderNewer