gpt4 book ai didi

Clojure Defn 在显示正确答案后返回空括号

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

我试图只获取一个生肖名称以将其传递给不同的函数,但我不知道为什么在显示生肖后我会得到空括号。我是 Clojure 的新手。

(defn miko []
(let [guess (read)]
(remove nil?(cond

(some #(= guess %) (range 101 120))(println "Capricorn")
(some #(= guess %) (range 120 219))(println "Aquarius")
(some #(= guess %) (range 219 321))(print "Pisces")
(some #(= guess %) (range 321 420))(print "Aries")
(some #(= guess %) (range 420 521))(print "Taurus")
(some #(= guess %) (range 521 621))(print "Gemini")
(some #(= guess %) (range 621 723))(print "Cancer")
(some #(= guess %) (range 723 823))(print "Leo")
(some #(= guess %) (range 823 923))(print "Virgo")
(some #(= guess %) (range 923 1023))(print "Libra")
(some #(= guess %) (range 1023 1122))(print "Scorpio")
(some #(= guess %) (range 1122 1221))(print "Sagittarius")
(some #(= guess %) (range 1221 3112))(print "Capricorn")
:else "wrong"))))

I run it (miko) and this is the result:

Capricorn

()

请帮我删除它,因为当我想将结果名称(例如 Capricorn)传递给另一个函数时,它会传递给 ()-括号。

最佳答案

你做得很好,只需删除打印语句,例如将 (print "Capricorn") 替换为 "Capricorn",该函数将起作用。

你也不需要 (remove nil? ...)

关于Clojure Defn 在显示正确答案后返回空括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29230802/

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