在我的程序中,我试图通过编写验证我定义的函数的功能的测试来测试我的程序。在它们通过我的函数后,我正在测试序列的相等性。
my-reverse 的定义:
(defn my-reverse [coll]
(if (empty? coll)
[]
(conj
(my-reverse (rest coll))
(first coll)
)
)
)
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我的断言失败了,因为 (my-reverse [1]) 返回 [1]。这是断言:
(assert (identical? (my-reverse [1]) [1]))
Run Code Online (Sandbox Code Playgroud)
谢谢大家!