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

标签 parameters clojure naming-conventions

在大多数语言中,都有关于参数的约定。例如在嵌套循环中,您可能会使用 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/

相关文章:

google-app-engine - 项目适合 Google App Engine?

naming-conventions - 在 conan 包名称中使用连字符有多糟糕?

matlab - 使用 lsqcurvefit 拟合

postgresql - 您如何才能有效地对存储在数据库中的应用程序参数进行版本控制?

json - CloudFormation 嵌套堆栈参数

xml-parsing - Clojure Leining REPL OutOfMemoryError Java 堆空间

java - 参数化方法调用何时有用?

clojure - 没有为类找到方法 : :make-reader of protocol: #'clojure. java.io/IOFactory 的实现:nil

python - 我应该以 _ 开头内部方法吗?

version-control - 如何处理源代码中不断变化的功能和产品名称?