This is a utility for introducing abbreviations into Nqthm output.

advertisement
This is a utility for introducing abbreviations into Nqthm output.
Here is how to use this facility.
ADD AN ABBREVIATION:
Examples:
(abb '(1 2 3 4 5 6 7 8 9 10) @10-numbers)
(abb (append x y) app-x-y)
(abb term val)
ABB causes the given term (which may be presented in ordinary
user-level syntax) to be printed by Nqthm as val whenever it is
encountered. In the example above, '(1 2 3 4 5 6 7 8 9 10) would be
printed as @10-numbers.
REMOVE AN ABBREVIATION:
Examples:
(remove-abb '(1 2 3 4 5 6 7 8 9 10)).
(remove-abb (append x y))
REMOVE-ABB causes the given term (which may be presented in ordinary
user-level syntax) to no longer be abbreviated.
REMOVE ALL ABBREVIATIONS:
(clear-abbs)
DISPLAY ALL ABBREVIATIONS:
(show-abbs)
Note: Any term may be abbreviated. In order to place a restriction
on which terms may be abbreviated, change the function
translate-and-filter as shown below. An example is given below the
actual definition in which only quoted objects may be abbreviated.
Technical point: abbreviation works outside-in, so if term A is a
subterm of term B and both have abbreviations, Nqthm will print the
abbreviation of A when A is encountered outside-in.
;;; current version of translate-and-filter
(defun translate-and-filter (form)
(translate form))
;;; The following version of translate-and-filter makes the
;;; restriction that only quoted terms (explicit values) may be
;;; abbreviated.
(defun translate-and-filter (form)
(let ((term (translate form)))
(if (quotep term)
term
(er soft (form term)
|Abbreviations| |are| |allowed| |only| |on| |explicit| |values|
|,|
|but| (!ppr form nil) |translates| |to| (!ppr term (quote
|.|))))))
Download