####Copyright (c) David Springate 2013 #####Creative Commons Attribution 3.0 Unported License (CC BY 3.0)
This project is inspired by/ported from/ripped off of Peter Norvig's Lispy and (How to Write a (Lisp) Interpreter (in Python)) with further help from SICP. It comes in at 141 non-comment, non-blank lines and 5.3K of source code. To run the REPL, start up R and:
source(scheme.R)
schemeR()
...Then you can start scheming... e.g.
(define cube (lambda (x) (* x (* x x))))
(cube 12)
Hit Control-C to get back to R.
To test outside of the REPL, try something like:
procedure <- "(if (< (+ 123 (* 12 12)) 345) (quote yes) (quote no))"
parsed.procedure <- read(procedure)
parsed.procedure # the procedure parsed into R lists
Eval(parsed.procedure) # The result of the evaluation of the parsed procedure
global.env # List of all built-in functions
Special forms are:
(quote expr)
(if test conseq alt)
(set! var expr)
(define var expr)
(lambda (vars) expr)
(begin exprs)
- The
Eval
function is wrapped in atryCatch
so typos will not crash you out of the REPL. - The interpreter now works with R environments instead of lists.
- See the issues section
- Implement Norvig's improved lispy in R