Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shiroyasha/lisp
Toy lisp interpreter written in C
https://github.com/shiroyasha/lisp
Last synced: about 2 months ago
JSON representation
Toy lisp interpreter written in C
- Host: GitHub
- URL: https://github.com/shiroyasha/lisp
- Owner: shiroyasha
- Created: 2016-11-04T16:37:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-13T03:24:06.000Z (about 8 years ago)
- Last Synced: 2024-08-03T18:16:59.083Z (6 months ago)
- Language: C
- Homepage:
- Size: 301 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- AwesomeInterpreter - lisp
README
# Lisp
Following the tutorial from [Build Your Own Lisp](http://www.buildyourownlisp.com/).
## Building from source
Install dependencies:
``` bash
sudo apt-get install libedit-dev
```Clone the source code:
``` bash
git clone https://github.com/shiroyasha/lispy ~/lispy
```Build binary:
``` bash
cd ~/lispy
make
```Run lispy:
``` bash
cd ~/lispy
./lispy
```## Examples
Arithmetic:
``` lisp
> + 1 2
3> * 1 2
2> * (+ 1 2) (- 10 8)
6
```Lists:
``` lisp
> { 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:
``` lisp
> def {a b c d} 1 90 20 87
()> a
1> (+ b c)
110
```Functions:
``` lisp
> fun {add-together a b} {+ a b}
()> add-together 32 18
50
```Macros (fun fact: 'fun' is actually a macro defined in the language):
``` lisp
> 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
```