Pixley

example program:

Status:

Result:


  

Program:


    

Depiction:

(cons (quote a) (cons (quote b) (quote ())))
(equal? (quote foo) (quote foo))
(list? (quote foo))
(let* ((a (quote b)) (c (quote d))) (cons a (cons c ())))
(let* ((a (let* ((b (quote c))) b))) a)
(let* ((a (lambda (x y) (cons x (cons y ()))))) (a (quote foo) (quote bar)))
(cond ((equal? (quote b) (quote r)) (quote foo)) (else (quote bar)))
(cond ((equal? (quote b) (quote r)) (quote foo)) ((equal? (quote b) (quote b)) (quote blah)) (else (quote bar)))
(let* ((pair (lambda (x) (cons x (cons x ()))))) (pair (quote (hi there))))
(lambda (program) (let* ((interpreter (lambda (interpret program env) (let* ((cadr (lambda (alist) (car (cdr alist)))) (null? (lambda (expr) (equal? expr (quote ())))) (find (lambda (self elem alist) (cond ((null? alist) (quote nothing)) (else (let* ((entry (car alist)) (key (car entry)) (rest (cdr alist))) (cond ((equal? elem key) entry) (else (self self elem rest)))))))) (interpret-args (lambda (interpret-args args env) (cond ((null? args) args) (else (let* ((arg (car args)) (rest (cdr args))) (cons (interpret interpret arg env) (interpret-args interpret-args rest env))))))) (expand-args (lambda (expand-args formals argvals) (cond ((null? formals) formals) (else (let* ((formal (car formals)) (rest-formals (cdr formals)) (argval (car argvals)) (rest-argvals (cdr argvals))) (cons (cons formal (cons argval (quote ()))) (expand-args expand-args rest-formals rest-argvals))))))) (concat-envs (lambda (concat-envs new-env old-env) (cond ((null? new-env) old-env) (else (let* ((entry (car new-env)) (rest (cdr new-env))) (cons entry (concat-envs concat-envs rest old-env))))))) (call-lambda (lambda (func args env) (let* ((arg-vals (interpret-args interpret-args args env))) (func arg-vals))))) (cond ((null? program) program) ((list? program) (let* ((tag (car program)) (args (cdr program)) (entry (find find tag env))) (cond ((list? entry) (call-lambda (cadr entry) args env)) ((equal? tag (quote lambda)) (let* ((formals (car args)) (body (cadr args))) (lambda (arg-vals) (let* ((arg-env (expand-args expand-args formals arg-vals)) (new-env (concat-envs concat-envs arg-env env))) (interpret interpret body new-env))))) ((equal? tag (quote cond)) (cond ((null? args) args) (else (let* ((branch (car args)) (test (car branch)) (expr (cadr branch))) (cond ((equal? test (quote else)) (interpret interpret expr env)) ((interpret interpret test env) (interpret interpret expr env)) (else (let* ((branches (cdr args)) (newprog (cons (quote cond) branches))) (interpret interpret newprog env)))))))) ((equal? tag (quote let*)) (let* ((bindings (car args)) (body (cadr args))) (cond ((null? bindings) (interpret interpret body env)) (else (let* ((binding (car bindings)) (rest (cdr bindings)) (ident (car binding)) (expr (cadr binding)) (value (interpret interpret expr env)) (new-bi (cons ident (cons value (quote ())))) (new-env (cons new-bi env)) (newprog (cons (quote let*) (cons rest (cons body (quote ())))))) (interpret interpret newprog new-env)))))) ((equal? tag (quote list?)) (list? (interpret interpret (car args) env))) ((equal? tag (quote quote)) (car args)) ((equal? tag (quote car)) (car (interpret interpret (car args) env))) ((equal? tag (quote cdr)) (cdr (interpret interpret (car args) env))) ((equal? tag (quote cons)) (cons (interpret interpret (car args) env) (interpret interpret (cadr args) env))) ((equal? tag (quote equal?)) (equal? (interpret interpret (car args) env) (interpret interpret (cadr args) env))) ((null? tag) tag) ((list? tag) (call-lambda (interpret interpret tag env) args env)) (else (call-lambda tag args env))))) (else (let* ((entry (find find program env))) (cond ((list? entry) (cadr entry)) (else (quote illegal-program-error)))))))))) (interpreter interpreter program (quote ()))))