From: Bruce L. Lambert, Ph.D.
Subject: Which loop can iterate over hash-tables
Date:
Message-ID: <4lobmm$1huc@piglet.cc.uic.edu>
Which publically available loop macro can loop over the keys and values
of a hash-table (and where can I find it)? I have mit_loop.cl, but it
cannot do what I need it to do.
-bruce
>>>>> "Bruce" == Bruce L Lambert, Ph D <········@uic.edu> writes:
In article <···········@piglet.cc.uic.edu> Bruce L. Lambert, Ph.D. <········@uic.edu> writes:
Bruce> Which publically available loop macro can loop over the keys
Bruce> and values of a hash-table (and where can I find it)? I have
Bruce> mit_loop.cl, but it cannot do what I need it to do.
CLISP's loop macro can do this.
ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/lisp/clisp
(let ((hash-table (make-hash-table :initial-contents '(("key1" . "value1")
("key2" . "value2")
("key3" . "value3")))))
(loop for key being each hash-key of hash-table using (hash-value value)
collect key into keys
collect value into values
finally (format t "~%keys: ~S values: ~S~%" keys values)))
keys: ("key3" "key2" "key1") values: ("value3" "value2" "value1")