I could not find any function to list the keys of an associton list in Emacs documentation. So I wrote a simple one.
(defun my/keys (alist) "Return the keys of the given ALIST." (let ((value nil) (result-list ())) (dolist (value alist result-list) (setq result-list (cons (car value) result-list)))))
For which the following test evaluates true:
(ert-deftest keys-test () (should (equal (my/keys '((key1 . "foo") ("key2" . "bar") (1 . "bazz"))) ;; result: '(1 "key2" key1))))
I do not like reinventing the well are there any Emacs built-in function analogues with mine?