blob: a60419349e87a70fdd88093ca0591fc54ac42999 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# Bamboo Lisp
Embeddable & Hackable Lisp-2 Interpreter
(Work in Progress)
## Build
Debug:
```bash
git submodule init --recursive
make
```
Release:
```bash
git submodule init --recursive
make profile=release
```
## Example
### 1. Y Combinator
```lisp
(defun Y (f)
(funcall
(lambda (g) (funcall g g))
(lambda (h)
(funcall f (lambda args (apply (funcall h h) args))))))
(defun fibo-impl (self)
(lambda (n)
(if (<= n 2)
1
(+ (funcall self (- n 1)) (funcall self (- n 2))))))
(defvar fibo (Y #'fibo-impl))
(funcall fibo 10)
```
### 2. Macro
```lisp
(defmacro inc (x)
`(setq ,x (+ ,x 1)))
(defmacro for (start pred inc . body)
`(let (,start)
(while ,pred
,@body
,inc)))
(for (i 0) (< i 10) (inc i)
(show "meow"))
```
|