Clojure:如何在运行时找出函数的arity? [英] Clojure: How to find out the arity of function at runtime?
本文介绍了Clojure:如何在运行时找出函数的arity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个函数对象或名称,如何确定它的arity?像(arity func-name)
。
Given a function object or name, how can I determine its arity? Something like (arity func-name)
.
我希望有一种方法,因为arity是Clojure
I hope there is a way, since arity is pretty central in Clojure
推荐答案
函数的arity存储在var的元数据中。
The arity of a function is stored in the metadata of the var.
(:arglists (meta #'str))
;([] [x] [x & ys])
这需要使用 defn
或:arglists
元数据。
这篇关于Clojure:如何在运行时找出函数的arity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文