From e44c2574e34a089217ebe2b59bccba9cc10bbd0f Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 26 Jun 2011 22:43:39 -0600 Subject: [PATCH] Add formatting options to print-hash-table --- hash.lisp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hash.lisp b/hash.lisp index 98e9439..fb4c4fa 100644 --- a/hash.lisp +++ b/hash.lisp @@ -19,6 +19,23 @@ ;;; hashs +(defun print-hash (h &key (stream *standard-output*) + key-transform-fn value-transform-fn + (prefix "") (divider " -> ") (terminator "~%")) + (maphash #'(lambda (k v) + (format stream "~A~S~A~S~%" + prefix + (if key-transform-fn + (funcall key-transform-fn k) + k) + divider + (if value-transform-fn + (funcall value-transform-fn v) + v) + (when terminator (format stream terminator))) + h) + h) + (defun print-hash (h &optional (stream *standard-output*)) (maphash #'(lambda (k v) (format stream "~S -> ~S~%" k v)) h) h) -- 2.34.1