Substitute an alist into a tree
(Sublis alist tree) is obtained by replacing every leaf of
tree with the result of looking that leaf up in the association list
alist. However, a leaf is left unchanged if it is not found as a key in
Leaves are looked up using the function assoc. The guard
for (sublis alist tree) requires (eqlable-alistp alist). This guard ensures that the guard for assoc will be met for each
lookup generated by sublis.
Sublis is defined in Common Lisp. See any Common Lisp documentation
for more information.
(defun sublis (alist tree)
(declare (xargs :guard (eqlable-alistp alist)))
(cond ((atom tree)
(let ((pair (assoc tree alist)))
(cond (pair (cdr pair)) (t tree))))
(t (cons (sublis alist (car tree))
(sublis alist (cdr tree))))))
- memoized version of SUBLIS which uses fast-alists.