New Lisp functions ASSOC, EFFACE, MAPLIST
This commit is contained in:
parent
41cecdc522
commit
5ee9531e6b
10 changed files with 109 additions and 34 deletions
7
resources/mexpr/assoc.mexpr.lsp
Normal file
7
resources/mexpr/assoc.mexpr.lsp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
;; Not present in Lisp 1.5(!)
|
||||
|
||||
assoc[x; l] = [null[l] -> NIL;
|
||||
and[consp[car[l]]; eq[caar[l]; x]] -> cdar[l];
|
||||
T -> assoc[x; cdr[l]]]
|
||||
|
||||
;; (ASSOC 'C (PAIR '(A B C D E F) (RANGE 1 6)))
|
||||
6
resources/mexpr/efface.mexpr.lsp
Normal file
6
resources/mexpr/efface.mexpr.lsp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
;; page 63. I'm not at all sure why an implementation using RPLACD is preferred
|
||||
;; over a pure functional implementation here.
|
||||
|
||||
efface[x; l] = [null[l] -> NIL;
|
||||
equal[x; car[l]] -> cdr[l];
|
||||
T -> rplacd[l; efface[x; cdr[l]]]]
|
||||
4
resources/mexpr/maplist.mexpr.lsp
Normal file
4
resources/mexpr/maplist.mexpr.lsp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;; page 63
|
||||
|
||||
maplist[l; f] = [null[l] -> nil;
|
||||
T -> cons[f[car[l]]; maplist[cdr[l]; f]]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue