我怎么知道作为字符串提供的函数名在当前上下文中是否可调用?就像是:
(callable? "asdasd") ;; false
(callable? "filter") ;; true
Run Code Online (Sandbox Code Playgroud)
谢谢
Ham*_*aya 17
你在寻求决心,
(resolve (symbol "asd"))
Run Code Online (Sandbox Code Playgroud)
返回零
(resolve (symbol "filter"))
Run Code Online (Sandbox Code Playgroud)
return#'clojure.core/filter
检查var是否是函数(信用转到@amalloy):
(-> s symbol resolve deref ifn?)
Run Code Online (Sandbox Code Playgroud)