APL: Evaluator for a Subset of Scheme
2 days ago
- #Metacircular Evaluator
- #Scheme Evaluation
- #APL
- This is an APL function 'lisp' that evaluates a subset of Scheme expressions. It can optionally return the parse tree (AST) when the left argument 'eval' is 0.
- It supports special forms like lambda (with alias '\\'), quote, cond, and else, along with primitive functions such as +, -, *, =, write, and display.
- The implementation represents Lisp structures in APL: atoms as numbers, symbols as character vectors, lists as vectors, and closures as 4-vectors containing 'closure', environment, parameters, and body.
- Examples demonstrate expression evaluation, lambda application, quoted expressions, and a mini REPL session. It includes advanced examples like the Y combinator for recursive functions (factorial, Fibonacci, Ackermann).
- A helper function 'pchk' is provided to check parenthesis depth. The function is inspired by the metacircular evaluator from SICP and is part of a collection of tools.