gpt4 book ai didi

parameters - 为什么 Clojure 开发人员使用 "xs"作为函数参数?

转载 作者:行者123 更新时间:2023-12-03 09:41:43 24 4
gpt4 key购买 nike

在大多数语言中,都有关于参数的约定。例如在嵌套循环中,您可能会使用 i在顶层,然后 j ,然后 k .

但是在 Clojure 中,我不知道约定是什么。我经常看到 xs 的使用在函数参数中;那是为什么?有什么特别的意思吗?还有其他约定吗?

最佳答案

命名约定可以引用Clojure library coding standards

具体来说:

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

关于parameters - 为什么 Clojure 开发人员使用 "xs"作为函数参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28660588/

24 4 0