Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    decaf-lisppublic

    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

    Keywords

    none

    install

    npm i decaf-lisp

    Downloadsweekly downloads

    15

    version

    0.0.10

    license

    none

    last publish

    collaborators

    • avatar