1.0.0 • Published 4 years ago

minilisp v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

minilisp

Small minimalistic LISP interpreter

npm install minilisp

Usage

const minilisp = require('minilisp')

// Define your functions.
// Notice all values/statements are functions that can be resolved lazily.
const lisp = minilisp(function (name) {
  if (name === '+') {
    return function (a, b) {
      return a() + b()
    }
  }
  if (name === '-') {
    return function (a, b) {
      return a() - b()
    }
  }
})

// Compile your program
const prog = lisp(`
  (+ 1 (- 3 2))
`)

// And run it
console.log(prog()) // prints 2!

License

MIT