gpt4 book ai didi

clojure - 在 clojure 中,如果定义为 [x] 参数然后引用为 x,为什么不识别 x?在代码块中?

转载 作者:太空宇宙 更新时间:2023-11-03 18:56:19 26 4
gpt4 key购买 nike

(defn boolean [x]
(if (x? nil or false)
(false)
(true)))

我明白了

Unable to resolve symbol: x? in this context

x 是函数的参数,我只是引用它,我错过了什么?

最佳答案

因为 x 和 x?是两个不同的名字。您的函数可以简单地写成

(defn boolean [x]
(if x true false))

关于clojure - 在 clojure 中,如果定义为 [x] 参数然后引用为 x,为什么不识别 x?在代码块中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26737646/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com