如何将序列序列变成映射,其中值是序列中的第一项的计数?
我有((“通用” 7)(“ ore” 1)(“通用” 4)(“ wood” 6)(“小麦” 3)(“通用” 2)(“通用” 9)的数据(“绵羊” 5)(“砖” 8))
,我想将其变成数据
{"brick" 1
"generic" 4
"sheep" 1
"ore" 1
"wheat" 1
"wood" 1}
,因为“通用”在数据中出现4次,我希望键是“通用”,并且值为4因为“绵羊”出现1在数据中,我希望钥匙是“绵羊”,值为“ 1”。
I have data like (("generic" 7) ("ore" 1) ("generic" 4) ("wood" 6) ("wheat" 3) ("generic" 2) ("generic" 9) ("sheep" 5) ("brick" 8))
and I want to turn it into
{"brick" 1
"generic" 4
"sheep" 1
"ore" 1
"wheat" 1
"wood" 1}
Since "generic" appears 4 times in the data, I want the key to be "generic" and the value to be 4. Since "sheep" appears 1 time in the data, I want the key to be "sheep" and the value to be "1".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
map
,(
- >>>
是“ thread-last”宏。)
Use
map
,first
andfrequencies
:(
->>
is "thread-last" macro.)