src/hash-tables.lisp @ aaf09c52cad9

Fix hash table pretty printing.  Thanks, CLR.
author Steve Losh <steve@stevelosh.com>
date Fri, 09 Nov 2018 21:23:48 -0500
parents de9d10a9b4b5
children 861b0bbcb319
(in-package :losh.hash-tables)

(defun mutate-hash-values (function hash-table)
  "Replace each value in `hash-table` with the result of calling `function` on it.

  Returns the hash table.

  "
  (iterate (for (key value) :in-hashtable hash-table)
           (setf (gethash key hash-table)
                 (funcall function value)))
  hash-table)

(defun hash-table-contents (hash-table)
  "Return a fresh list of `(key value)` elements of `hash-table`."
  (gathering (maphash (compose #'gather #'list) hash-table)))