decaf-lisp

An insanely ugly dialect of LISP.

npm install decaf-lisp
5 downloads in the last week
20 downloads in the last month

DecafLISP

A dialect of lisp, meant for the Node.js runtime. What's the use of this? Not much other than to just fool around. In fact, I only wrote it to learn compilers.

Installation

# Might require sudo
$ npm install -g decaf-lisp

Copy the code into a hello-world.lisp file.

(console-log "Hello, World!")

And then run the code.

$ decaf-lisp hello-world.lisp
# -> Hello, World!

More examples

if-statements

(if (< 5 6)
  ("5 is less than 6!")
  ("Weird..."))

If you want the above to outputed to the console, then you would simply prepend the above code with a console-log call.

(console-log (if (< 5 6)
  ("5 is less than 6!")
  ("Weird...")))

function definition

(defun myfunc (somParam)
  (console-log someParam))

; Calling the function.
(myfunc "Hello, World!")
; -> "Hello, World!"

Anonymous functions

(console-log
  ((lambda (one, two)
    (+ one two)) 1 2))
; -> "3"

Factorial function

(defun fact (n)
  (if (= n)
    1
    (* (- n 1) n)))

(console-log (fact 3))

TODO

  • command-line options
npm loves you