【文件属性】:
文件名称:defk:Clojure的紧凑关键字参数
文件大小:10KB
文件格式:ZIP
更新时间:2021-05-02 23:55:24
Clojure
防御
Clojure库旨在使关键字参数变得不仅容易,而且实际上也非常容易,以至于您可能再也不会使用其他任何东西了。
用法
不要使用defn定义函数,而应使用defk 。 现在,任何调用您函数的人都会自动获得关键字参数语义。 一个例子比较容易:
( defk foo [a b]
( - a b))
( let [a 1 , b 2 ]
( foo b a)) ; <- returns 1 - 2, NOT 2 - 1. How? Because the NAME a and
; b are used, not the positions of those variables at the call site
当然,您也可以使用其他名称或文字来传递变量的值:
( let [c 2 ]
( foo a=1 b=c))
( foo a=( + 1 2 3
【文件预览】:
defk-master
----.lein-failures(3B)
----src()
--------defk()
----target()
--------classes()
--------stale()
----doc()
--------intro.md(92B)
----.travis.yml(48B)
----LICENSE(11KB)
----test()
--------defk()
----README.md(1KB)
----project.clj(264B)