Fast-alist-clean
(fast-alist-clean alist) can be used to eliminate
"shadowed pairs" from a fast alist.
This documentation topic assumes familiarity with fast
alists; see fast-alists. See fast-alist-clean!, fast-alist-fork, and fast-alist-fork! for related utilities.
Logically, (fast-alist-clean alist) is defined as follows:
Function: fast-alist-clean
(defun fast-alist-clean (alist)
(declare (xargs :guard t))
(fast-alist-fork alist
(if (consp alist)
(cdr (last alist))
alist)))
The result is thus a corresponding fast alist, with the order reversed and
with atoms and shadowed pairs removed, as per the definition above; see fast-alist-fork for details. Moreover, if alist is not a fast alist,
then (fast-alist-clean alist) is executed in raw Lisp by calling
fast-alist-fork as indicated above.
However, if alist is a fast alist, then a special definition under the
hood provides a different handling of associated hash tables. After running
(fast-alist-clean alist) to obtain a result, cleaned-alist, the hash
table that had been associated with alist will now be associated with
cleaned-alist instead. This saves the expense of creating a new hash
table, but there is still the expense of copying the alist, as for fast-alist-fork. However, unlike fast-alist-fork, there is no need to
free the input alist.
Note that the final cdr is preserved, so that the name is preserved
for use by fast-alist-summary (also see hons-acons).