Right, there's an awful lot of Lisp actually working...
This commit is contained in:
parent
c3b327f760
commit
1f16241af7
31 changed files with 250 additions and 97 deletions
21
resources/mexpr/apply-2.mexpr.lsp
Normal file
21
resources/mexpr/apply-2.mexpr.lsp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
;; see page 70 of Lisp 1.5 Programmers Manual; this expands somewhat
|
||||
;; on the accounts of eval and apply given on page 13. This is M-expr
|
||||
;; syntax, obviously.
|
||||
|
||||
;; apply
|
||||
;; NOTE THAT I suspect there is a typo in the printed manual in line
|
||||
;; 7 of this definition, namely a missing closing square bracket before
|
||||
;; the final semi-colon; that has been corrected here.
|
||||
|
||||
apply[fn;args;a] = [
|
||||
null[fn] -> NIL;
|
||||
atom[fn] -> [get[fn;EXPR] -> apply[expr; args; a];
|
||||
get[fn;SUBR] -> {spread[args];
|
||||
$ALIST := a;
|
||||
TSX subr4, 4};
|
||||
T -> apply[cdr[sassoc[fn; a; λ[[]; error[A2]]]]; args a]];
|
||||
eq[car[fn]; LABEL] -> apply[caddr[fn]; args;
|
||||
cons[cons[cadr[fn];caddr[fn]]; a]];
|
||||
eq[car[fn]; FUNARG] -> apply[cadr[fn]; args; caddr[fn]];
|
||||
eq[car[fn]; LAMBDA] -> eval[caddr[fn]; nconc[pair[cadr[fn]; args]; a]];
|
||||
T -> apply[eval[fn;a]; args; a]]
|
||||
3
resources/mexpr/cond-test.mexpr.lsp
Normal file
3
resources/mexpr/cond-test.mexpr.lsp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
;; from page 5
|
||||
|
||||
[eq[car[x];A]->cons[B;cdr[x]];T->x]
|
||||
3
resources/mexpr/copy.mexpr.lsp
Normal file
3
resources/mexpr/copy.mexpr.lsp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
copy[x] = [null[x] -> NIL;
|
||||
atom[x] -> x;
|
||||
T -> cons[ copy[ car[x]]; copy[ cdr[x]]]]
|
||||
3
resources/mexpr/divide.mexpr.lsp
Normal file
3
resources/mexpr/divide.mexpr.lsp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
;; page 26
|
||||
|
||||
divide[x; y] = cons[ quotient[x; y]; cons[ remainder[x; y]; NIL]]
|
||||
3
resources/mexpr/ff.mexpr.lsp
Normal file
3
resources/mexpr/ff.mexpr.lsp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
;; From page 6 of Lisp 1.5 Programmer's Manual
|
||||
|
||||
ff[x]=[atom[x] -> x; T -> ff[car[x]]]
|
||||
5
resources/mexpr/gcd.mexpr.lsp
Normal file
5
resources/mexpr/gcd.mexpr.lsp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
gcd[x;y] = [x>y -> gcd[y;x];
|
||||
rem[y;x] = 0 -> x;
|
||||
T -> gcd[rem[y;x];x]]
|
||||
|
||||
;; gcd[x;y] = [x>y -> gcd[y;x]; remainder[y;x] = 0 -> x; T -> gcd[remainder[y;x];x]]
|
||||
6
resources/mexpr/get.mexpr.lsp
Normal file
6
resources/mexpr/get.mexpr.lsp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
;; page 59; slightly modified because I don't at this stage want to
|
||||
;; assume the existence of CADR
|
||||
|
||||
get[x; y] = [null[x] -> NIL;
|
||||
eq[car[x]; y] -> car[cdr[x]];
|
||||
T -> get[cdr[x]; y]]
|
||||
5
resources/mexpr/intersection.mexpr.lsp
Normal file
5
resources/mexpr/intersection.mexpr.lsp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;; page 15
|
||||
|
||||
intersection[x;y] = [null[x] -> NIL;
|
||||
member[car[x]; y] -> cons[car[x]; intersection[cdr[x]; y]];
|
||||
T -> intersection[cdr[x]; y]]
|
||||
4
resources/mexpr/member.mexpr.lsp
Normal file
4
resources/mexpr/member.mexpr.lsp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;; page 15
|
||||
member[a; x] = [null[x] -> F;
|
||||
eq[a; car[x]] -> T;
|
||||
T-> member[a; cdr[x]]]
|
||||
7
resources/mexpr/null.mexpr.lsp
Normal file
7
resources/mexpr/null.mexpr.lsp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
null[x] = [x = NIL -> T; T -> F]
|
||||
|
||||
(SETQ NULL
|
||||
'(LAMBDA (X)
|
||||
(COND
|
||||
((EQUAL X NIL) 'T)
|
||||
(T (QUOTE F)))))
|
||||
4
resources/mexpr/prop.mexpr.lsp
Normal file
4
resources/mexpr/prop.mexpr.lsp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;; page 59
|
||||
prop[x;y;u] = [null[x] -> u[];
|
||||
eq[car[x]; y] -> cdr[x];
|
||||
T -> prop[cdr[x]; y; u]]
|
||||
4
resources/mexpr/union.mexpr.lsp
Normal file
4
resources/mexpr/union.mexpr.lsp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;; page 15
|
||||
union[x; y] = [null[x] -> y;
|
||||
member[car[x]; y] -> union[cdr[x]; y];
|
||||
T -> cons[car[x]; union[cdr[x]; y]]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue