All ready to implement property lists, not yet done.

This commit is contained in:
Simon Brooke 2023-04-02 03:45:40 +01:00
parent 5ee9531e6b
commit b61e7c3e8c
16 changed files with 225 additions and 125 deletions

View file

@ -1,7 +1,22 @@
;; Not present in Lisp 1.5(!)
;; Page 12 of the manual; this does NOT do what I expect a modern
;; ASSOC to do!
;; Modern ASSOC would be:
;; assoc[x; l] = [null[l] -> NIL;
;; and[consp[car[l]]; eq[caar[l]; x]] -> cdar[l];
;; T -> assoc[x; cdr[l]]]
;; In the Lisp 1.5 statement of ASSOC, there's no account of what should happen
;; if the key (here `x`) is not present on the association list `a`. It seems
;; inevitable that this causes an infinite run up the stack until it fails with
;; stack exhaustion. Consequently this may be right but I'm not implementing it!
;; assoc[x; a] = [equal[caar[a]; x] -> car[a];
;; T -> assoc[x; cdr[a]]]
;; Consequently, my solution is a hybrid. It returns the pair from the
;; association list, as the original does, but it traps the end of list
;; condition, as a modern solution would.
assoc[x; l] = [null[l] -> NIL;
and[consp[car[l]]; eq[caar[l]; x]] -> cdar[l];
and[consp[car[l]]; eq[caar[l]; x]] -> car[l];
T -> assoc[x; cdr[l]]]
;; (ASSOC 'C (PAIR '(A B C D E F) (RANGE 1 6)))