Subject: Re: Excerise in Graham's ANSI Common Lisp
From: (Rob Warnock)
Date: Thu, 20 Jul 2006 04:41:36 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Bill Atkins <> wrote:
| Rob Warnock wrote:
| > (defun hash-table-alist (table)
| >   (let (result)
| > 	(do-hash (key value table result)
| > 	  (push (cons key value) result))))
| What is DO-HASH?

Oops!! My bad. Sorry for not spotting that earlier.
It seems that DO-HASH is a CMUCL extension:

    cmu> (describe 'do-hash)
    DO-HASH is an external symbol in the EXTENSIONS package.
    Macro-function: #<Byte function (:MACRO DO-HASH) {28F9EEE9}>
    Macro documentation:
      DO-HASH (Key-Var Value-Var Table [Result]) Declaration* Form*
       Iterate over the entries in a hash-table.

that expands into a call of WITH-HASH-TABLE-ITERATOR, very
similar to the example definition of MAP-HASH in the CLHS
entry for WITH-HASH-TABLE-ITERATOR, except that instead of
FUNCALL'ing a function it executes a &BODY.

| (defun hash-table-to-alist (table)
|   (let (result)
|     (maphash (lambda (k v) (push (cons k v) result))
|              table)
|     result))

Yes, that's an equivalent standard-conformant way to define it.


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607