Skip to content

smussell/slisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slisp

This is my little toy lisp, for now called sam lisp until I find a better name. This is a very simple lisp implementation on top of node.js. I used the following articles as a guide on how to build a simple lisp.

If you want to run it just run

npm install

It is much easier to work with if you use rlwrap, which you can install on mac via homebrew.

rlwrap node slisp.js

##Examples

###DataTypes

  • boolean #t = true, #f = false
  • string
  • number

###Multiple args

> (+ 3 2 3)
8

###Multi-line

> (def myfun (^ (n)
>   (+ 3 n)))
[Function]
> (myfun 3)
6

###Closure

> (def addx (^ (x) (^ (y) (+ x y))))
[Function]
> (def add5 (addx 5))
[Function]
> (add5 10)
15

###Conditional

> (def n 10)
10
> (if (= n 10) 1 (- 1 1))
1
> (set! n 20)
20
> (if (= n 10) 1 (- 1 1))
0

About

sam lisp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published