Skip to content

shiroyasha/lisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lisp

Following the tutorial from Build Your Own Lisp.

Building from source

Install dependencies:

sudo apt-get install libedit-dev

Clone the source code:

git clone https://github.com/shiroyasha/lispy ~/lispy

Build binary:

cd ~/lispy
make

Run lispy:

cd ~/lispy
./lispy

Examples

Arithmetic:

> + 1 2
3

> * 1 2
2

> * (+ 1 2) (- 10 8)
6

Lists:

> { 1 2 3 }
{1 2 3}

> head {1 2 3}
1

> tail {1 2 3}
{2 3}

> join {1 2 3} {5 6 7}
{1 2 3 5 6 7}

> eval {+ 1 2}
3

Variables:

> def {a b c d} 1 90 20 87
()

> a
1

> (+ b c)
110

Functions:

> fun {add-together a b} {+ a b}
()

> add-together 32 18
50

Macros (fun fact: 'fun' is actually a macro defined in the language):

> def {fun} (\ {args body} {def (list (head args)) (\ (tail args) body)})
()

> fun {my-function a b c} {* a b c}
()

> my-function 1 2 3
6

About

Toy lisp interpreter written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages