Skip to content

camiha/lisp-ts

Repository files navigation

lisp-ts

Tiny Lisp interpreter. written in TypeScript.

Setup

  • set node version: 16 >=
  • npm install for install dependencies
  • npm start for run repl

REPL

basic operations

  lisp-ts> (+ 1 (- 2 (* 3 (/ 4))))
  -9

  lisp-ts> (&& (|| false true) (> 1 0))
  true

setq

  lisp-ts> (setq x 5)
  true

  lisp-ts> x
  5

  lisp-ts> (+ x x)
  10

defun

  lisp-ts> (defun fn (x) (* x x))
  true

  lisp-ts> (fn 2)
  4

recursive function

  lisp-ts> (defun fact (n) (if (== n 0) 1 (* n (fact (- n 1)))))
  true

  lisp-ts> (fact 5)
  120

Todo

  • add environment scope

Respect

Create interpreter is one of awesome experience in my programming life.
thanks for next articles and all lisp programmers.