elisp中的Python字典或地图 [英] Python dictionary or map in elisp

查看:96
本文介绍了elisp中的Python字典或地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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带有内置功能 mapcar 可以进行地图绘制,但是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字典或地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆