20060510412 发表于 2018-9-12 08:36:52

yshf 发表于 2018-9-12 08:28
“返回的结果应该是(“layout.layout1” “name.桥型布置图” “number.1” “sum.8”)这个样子”
如果 ...

哦,您意思是说list是函数名称,不能用作变量,知道了

Andyhon 发表于 2018-9-12 08:42:11

是这个吗? 不甚相同
Command: (mapcar 'cons tag lst)
(("layout" . "layout1") ("name" . "桥型布置图") ("number" . "1") ("sum" . "8"))

20060510412 发表于 2018-9-12 09:21:20

Andyhon 发表于 2018-9-12 08:42
是这个吗? 不甚相同
Command: (mapcar 'cons tag lst)
(("layout" . "layout1") ("name" . "桥型布置图") ...

我大致上理解两个mapcar嵌套的作用了,内层的mapcar,是为了定义一个函数,这个函数对两个列表进行cons函数处理,生成dotted pair(具体不知道是啥东西,看官方帮助上这样讲)。
外层的mapcar,则是将函数中的自定义变量x替换为实际的列表lst。
页: 1 [2]
查看完整版本: mapcar和lambda联合使用,出问题怎么解决