clojure 中的 smap 是什么?

What is an smap in clojure?

在 clojure 文档中,偶尔会使用术语 smap。例如,core/replace:

Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap.

术语“smap”是什么意思?

没有什么特别的意思。它只是指函数的参数名称:

(replace smap coll)

"smap" 代表 "substitution map" 似乎是合理的。

他们可能在它前面加上了 "s" 这样它就不会遮蔽 built-in used inside the function,或者因为他们认为 map 参数的用例足够具体以保证更具体姓名。