Complete `bind-args`, not that it solves the `and`/`or` problems.
catseye
13 years ago
|
0 |
|
|
1 |
-> Tests for functionality "Interpret Robin Program"
|
|
2 |
|
|
3 |
### `bind-args` ###
|
|
4 |
|
|
5 |
| (robin (0 1) ((small (0 1) *) (bind-args (0 1) *))
|
|
6 |
| (bind-args (a b) (list 1 2)
|
|
7 |
| (list a b)))
|
|
8 |
= (1 2)
|
|
9 |
|
|
10 |
| (robin (0 1) ((small (0 1) *) (bind-args (0 1) *))
|
|
11 |
| (bind-args (a b) (list 1)
|
|
12 |
| (list a b)))
|
|
13 |
? uncaught exception: (illegal-arguments (1))
|
|
14 |
|
|
15 |
| (robin (0 1) ((small (0 1) *) (bind-args (0 1) *))
|
|
16 |
| (bind-args (a b) (list 1 2 3)
|
|
17 |
| (list a b)))
|
|
18 |
? uncaught exception: (illegal-arguments (1 2 3))
|
10 | 10 |
(id-list (head args))
|
11 | 11 |
(orig-val-list (eval env (head (tail args))))
|
12 | 12 |
(expr (head (tail (tail args))))
|
13 | |
(bind-args-r (macro (self args env)
|
14 | |
(let (
|
15 | |
(id-list (eval env (head args)))
|
16 | |
(val-list (eval env (head (tail args))))
|
17 | |
)
|
18 | |
(if (empty? id-list)
|
19 | |
(if (empty? val-list)
|
20 | |
()
|
21 | |
(raise (list (literal illegal-arguments) orig-val-list))
|
22 | |
args ;ha ;no)))))
|
23 | |
(new-env (bind-args-r id-list orig-val-list))
|
|
13 |
(bind-args-r (fun (self id-list val-list env-acc)
|
|
14 |
;''This will need to be converted into a macro at some point,
|
|
15 |
but for now, this is easier.''
|
|
16 |
(if (empty? id-list)
|
|
17 |
(if (empty? val-list)
|
|
18 |
env-acc
|
|
19 |
(raise (list (literal illegal-arguments) orig-val-list)))
|
|
20 |
(if (empty? val-list)
|
|
21 |
(raise (list (literal illegal-arguments) orig-val-list))
|
|
22 |
(self self (tail id-list) (tail val-list)
|
|
23 |
(prepend
|
|
24 |
(list (head id-list) (head val-list))
|
|
25 |
env-acc))))))
|
|
26 |
(new-env (bind-args-r bind-args-r id-list orig-val-list env))
|
24 | 27 |
)
|
25 | 28 |
(eval new-env expr))))
|
26 | 29 |
)
|
19 | 19 |
doc/module/Assert.markdown \
|
20 | 20 |
doc/module/Pure.markdown \
|
21 | 21 |
doc/module/CrudeIO.markdown \
|
22 | |
doc/module/Miscellany.markdown"
|
|
22 |
doc/module/Miscellany.markdown \
|
|
23 |
doc/module/Bind-Args.markdown"
|
23 | 24 |
|
24 | 25 |
# Hack for Robin & Falderal built with the ghc from Haskell Platform on Windows
|
25 | 26 |
if [ -e bin/robin.exe ]; then
|