To display an associative list using symbols as keys a new function is required, because `ldisp!' can handle only Church Numerals. We call this new function `aldisp!'.
To search for keys in the list we need another lambda abstraction, which we call `assoc'.
(define map2 (lambda(proc l1 l2) (if (lor (nullp l1) (nullp l2)) nil (cons (proc (car l1) (car l2)) (map2 proc (cdr l1) (cdr l2)))))) |
(define aldisp! (lambda (l) (if (nullp l) nil ((lambda() (print (car (car l))) (print (cdr (car l))) (aldisp! (cdr l))))))) ; (define assoc (lambda(key alist) (if (nullp alist) false (if (equal key (car(car alist))) (car alist) (assoc key (cdr alist)))))) |
This example uses the following extensions of A++ in its original version:
Georg P. Loczewski 2004-03-05