问题描述
elisp中相当于 {’a’:,‘b’:2}
的python字典是什么意思?
还有elisp是否有任何map-reduce api?
What is the equivalent of a python dictionary like {'a':1, 'b':2}
in elisp?And again, does elisp have any map-reduce api?
推荐答案
是elisp中最常用的关联容器。它只是像这样的(((key。value))
的键值约束单元列表。您可以使用 assoc
函数获取对应于键的值,并使用 rassoc
获取具有所需值的键
Association lists are the most commonly used associative containers in elisp. It is just a list of key-value cons cells like this ((key . value))
. You can use the assoc
function to get a value corresponding to a key and rassoc
to get a key with the required value.
Elisp带有内置功能可以进行地图绘制,但是AFAIK没有很好的 fold
设施。您可以使用提供的任何循环工具来模拟它。但是,更好的解决方案是使用 cl-lib
并进入CommonLisp领域。特别是,它 cl-mapcar
和 cl-reduce
。
Elisp comes with the built-in function mapcar
which does map, but AFAIK there is no good fold
facility. You could emulate it using any of the looping facilities provided. However, the better solution is to use cl-lib
and slip into CommonLisp land. In particular, it supplies cl-mapcar
and cl-reduce
.
这篇关于elisp中的Python字典或地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!