25
I wonder if there is a less verbose way than using a loop. Anyway this works for me in CLISP:
(loop for key being the hash-keys of *my-hash* collect key)
I've seen others using maphash, but that involves accumulating each key into a list. Apart from that being more involved than using loop, it also introduces a side-effect, which I try to avoid whenever I can - I prefer functional programming as much as possible :)
Is there anything predefined like this for this common task, even though implementation-specific?
(defun hash-keys (hash-table)
(loop for key being the hash-keys of hash-table collect key))