Skip to content

DASpringate/SchemeR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

SchemeR: A simple lisp interpreter written in R

####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)
Added features:
  • The Eval function is wrapped in a tryCatch so typos will not crash you out of the REPL.
  • The interpreter now works with R environments instead of lists.
To do:
  • See the issues section
  • Implement Norvig's improved lispy in R

About

An implementation of a simple Scheme in R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages