[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Maphash
- To: Scott E. Fahlman <Fahlman%CMU-CS-C@SU-DSN>
- Subject: Maphash
- From: David A. Moon <Moon%SCRC-TENEX%MIT-MC@SU-DSN>
- Date: Tue, 24 May 1983 03:35:00 -0000
- Cc: common-lisp@su-ai
- In-reply-to: The message of 19 May 83 00:23-EDT from Scott E. Fahlman <Fahlman at CMU-CS-C>
Date: Thu, 19 May 1983 00:23 EDT
From: Scott E. Fahlman <Fahlman@CMU-CS-C>
Since MAPHASH returns NIL, there is no elegant way to turn the
contents of a hashtable into a list. What would people think of
flushing MAPHASH and replacing it with DO-HASH ?
Is (defun hash-table-to-alist (ht)
(let ((alist nil))
(do-hash ((key value) ht)
(push (cons key value) alist))
alist))
more elegant than
(defun hash-table-to-alist (ht)
(let ((alist nil))
(maphash #'(lambda (key value)
(push (cons key value) alist))
ht)
alist))
?
You aren't allowed to base your decision on the fact that both your CL
implementation and my CL implementation are currently in violation of
the standard, such that the latter version doesn't work unless alist is
declared special. You also aren't allowed to base your decision on the
fact that the best way to do this operation is with LOOP.