Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 211
Mirzhan Irkegulov Avatar asked Jan 07 '13 11:01

Mirzhan Irkegulov


1 Answers

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

like image 169
Anton Kovalenko Avatar answered Sep 28 '22 18:09

Anton Kovalenko