我想在Clojure中比较两个列表,
这是我的代码,但结果是()。我哪里出错了?请帮忙。
(def a '(1 2 3 4 5))
(def b '(3 2 7 8 10))
通过比较两个列表的元素,生成结果 (2 3) 或 (3 2)。
(defn compareList[x, y]
(do
(def result '())
(def i 0)
(def j 0)
(while (< i 5)
(while (< j 5)
(if (= (nth x i) (nth y j))
(def result (conj (nth x i) result)))
(def j (inc j))
)
)
result))
(print (compareList a b))
这是我的代码,但结果是()。我哪里出错了?请帮忙。
(cons 3 #{1 2})
的值为(3 1 2)
。 - Thumbnail