git @ Cat's Eye Technologies Robin / da3b87d
Complete `bind-args`, not that it solves the `and`/`or` problems. catseye 13 years ago
3 changed file(s) with 35 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
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))
1010 (id-list (head args))
1111 (orig-val-list (eval env (head (tail args))))
1212 (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))
2427 )
2528 (eval new-env expr))))
2629 )
1919 doc/module/Assert.markdown \
2020 doc/module/Pure.markdown \
2121 doc/module/CrudeIO.markdown \
22 doc/module/Miscellany.markdown"
22 doc/module/Miscellany.markdown \
23 doc/module/Bind-Args.markdown"
2324
2425 # Hack for Robin & Falderal built with the ghc from Haskell Platform on Windows
2526 if [ -e bin/robin.exe ]; then