\section{Utility functions} These are utility functions for use in other modules or for the user interacting with LISP. They all seem to be related to hash tables for the moment. <>= <> <> <> <> @ <>= (in-package max) @ <>= ; Show a hash table in HenZo's cheesy format (defun show-ht (ht) (format t "~%") (format t "Hash Table~%") (format t "----------~%") (maphash #'(lambda (addr val) (format t "~a : ~a~%" addr val)) ; this.. ht ; ...onto each element in this ) (format t "~%") ) @ <>= ; Returns a copy of hash-table ht (defun copy-hash (ht) (let ((newhash (make-hash-table :size (hash-table-size ht) :test (hash-table-test ht)))) (maphash #'(lambda (key val) (setf (gethash key newhash) val) ) ht ) newhash ) ) @ Use the second of two values returned from gethash, which indicates whether the looked-up item exists in the hash. <>= ; Return T if an item is in a hash table, NIL otherwise (defun hash-exists (item ht) (nth-value 1 (gethash item ht)) )