Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 665 Bytes

README.md

File metadata and controls

25 lines (17 loc) · 665 Bytes

EVL - Meta-circular Evaluator

(in-package :evl)

(let ((kv `((+ . +) (* . *) (1- . 1-) (t . t) (= . equal))))
  (labels ((env (x &aux (res (assoc x kv)))
             (if res (cdr res) (error "EVL: undefined variable: ~a" x))))

    (print (evl '(labels ((fact (x) (if (= x 0)
                                        1
                                        (* x (fact (1- x))))))
                   (fact 7))
                #'env))))

more examples in /ex.lisp.

Resources

For a great talk on this topic see this presentation by William Byrd:

The Most Beautiful Program Ever Written (https://www.youtube.com/watch?v=OyfBQmvr2Hc)