如何列出两个列表?

时间:2016-01-28 07:47:16

标签: list emacs

示例:

(setq foo '("f" "o" "o"))
(setq bar '("b" "a" "r"))

(setq foobar `(,foo .  ,(list bar))) 
;; Give me a normal list ( ("f" "o" "o")  ("b" "a" "r") ) which is not what I want.

我想得到( ("f" "o" "o") . ("b" "a" "r") )。怎么样?

2 个答案:

答案 0 :(得分:2)

使用cons获取虚线对:

(setq foo '("f" "o" "o"))
(setq bar '("b" "a" "r"))

(cons foo (list bar))
-> (("f" "o" "o") ("b" "a" "r"))

答案 1 :(得分:0)

可替换地,

(setq foobar `(,foo ,bar))
(memq foo foobar)
-> (("f" "o" "o") ("b" "a" "r"))