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

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

Re: Elisp - quoting or not?


From: Teemu Likonen
Subject: Re: Elisp - quoting or not?
Date: Sat, 05 Dec 2020 08:21:38 +0200

* 2020-12-04 21:15:00-08, David Masterson wrote:

> I give up -- what's the proper way of doing this?
>
> (setq ab '("a" . "b")
>       cd '("c" . "d")
>       abcd '(ab cd))
>
> What I want is a result for abcd to be '(("a" . "b") ("c" . "d")). I
> imagine I need to use cons/car/cdr, but I'm not sure how.

I would not use quotes there:

    (setq ab (cons "a" "b")
          cd (cons "c" "d")
          abcd (list ab cd))

You can use "'", "`" and "," reader "macros" if you want:

    (setq ab '("a" . "b")
          cd '("c" . "d")
          abcd `(,ab ,cd))

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450

Attachment: signature.asc
Description: PGP signature


reply via email to

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