help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: Any faster way to find frequency of words?


From: Drew Adams
Subject: RE: [External] : Re: Any faster way to find frequency of words?
Date: Mon, 10 May 2021 14:02:02 +0000

> (defun hash-to-list (hash)
>   "Convert hash HASH to list"
>   (let (list)
>     (maphash (lambda (key value)
>                (setq list (append list
>                                   (list (list key value)))))
>                                   hash)
>     list))

I use this, FWIW:

(defun hash-table-to-alist (hash-table)
  "Create and return an alist created from HASH-TABLE.
The order of alist entries is undefined, but it seems to be the same
as the order of hash-table entries (which seems to be the order in
which the entries were added to the table)."
  (let ((al  ()))
    (maphash (lambda (key val) (push (cons key val) al))
             hash-table)
    (nreverse al)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]