Int*_*ist 5 parameters clojure naming-conventions
在大多数语言中,存在围绕参数的约定.例如,在嵌套循环中,您可以i在顶层使用j,然后k.
但在Clojure中我不知道会议是什么.我经常看到xs函数参数的使用; 那为什么呢?这是否具体是什么意思?还有其他惯例吗?
Cha*_*eng 11
对于命名约定,您可以参考Clojure库编码标准
特别:
Follow clojure.core's example for idiomatic names like pred and coll.
in fns
f, g, h - function input
n - integer input usually a size
index - integer index
x, y - numbers
s - string input
coll - a collection
pred - a predicate closure
& more - variadic input
in macros
expr - an expression
body - a macro body
binding - a macro binding vector
Run Code Online (Sandbox Code Playgroud)
我不确定它是一个标准,但通常约定是x一个简单的变量和xs一个代表一个序列的变量.'s'代表序列或复数,这很方便.
例如,在解构中,您可以使用[x & xs]第一个和第二个.您还可以找到idx索引并idxs为更多的索引.