Search code examples
emacselisphashtableloops

Iterate over Emacs Lisp hash-table


How to iterate over items (keys, values) in Elisp hash-tables?

I created a hash-table (map, dictionary) using (make-hash-table) and populated it with different items. In Python i could iterate over dicts by:

for k in d # iterate over keys
for k in d.keys() # same
for k in d.values() # iterate over values
for k in d.items() # iterate over tuples (key, value)

How can i do the same the most succinct and elegant way possible, preferably without loop-macro?


Solution

  • (maphash (lambda (key value) ....your code here...) hash-table)