Given a list
of things, I want to create an alist
by applying a function which creates elements of the alist
.
For example, what is the implementation of doit
here:
(doit '("a" "b" "c"))
;; => (("a" . "A") ("b" . "B") ("c" . "C"))
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communitymapcar
is another option:
(mapcar (lambda (x)
(cons x (upcase x)))
'("a" "b" "c"))
It can be
(defun doit (l)
(seq-map (lambda (x)
(cons x (upcase x))) l))
seq-map
over mapcar
? ( seq-map
defined in seq.el.gz
seems to be only a wrapper to mapcar
)
doit
function was just an example to make my question more clear. The answer from @jagrg is just perfect. It captures the essence of the problem here.