Chipmunk is a Lisp interpreter with partial support for compiling to JavaScript. It's implemented in TypeScript and runs on Node.js. The goal is to someday achieve self-hosting.
Print the factorials of the numbers 1 to 10:
(do
(def factorial (lambda (x)
(if (= x 0)
1
(* x (factorial (- x 1))))))
(print-line (map factorial (range 10))))
; prints "[1 1 2 6 24 120 720 5040 40320 362880]"See the documentation for a list of functions
First, install dependencies:
npm installTo start a Chipmunk REPL:
npm run chipmunkTo run a Chipmunk program (any extra arguments are available to the program as
argv):
npm run chipmunk -- examples/game-of-life.chip
npm run chipmunk -- examples/factorial.chip 10To compile a Chipmunk program to JavaScript and run it:
npm run compile -- examples/game-of-life.chip
node examples/game-of-life.jsTo run tests:
npm test