【发布时间】:2014-12-05 14:10:14
【问题描述】:
您好,我开始编写 clojure 代码并练习 Hackerrank 问题。
这个问题需要我把输入作为
2
RGRG
BGYG
其中 2 是测试用例的数量,后跟 2 个字符串。
我编写了以下代码来获取输入并打印输出,其中fullballs? 是我的函数:
(defn Start [FuncToCall inputParse outputParse]
(let [lines (line-seq (java.io.BufferedReader. *in*))
input (rest lines)
times (first lines)]
(for [i (range (Integer. times))]
(outputParse (FuncToCall (inputParse (nth input i)))))
))
(Start fullballs?
(fn [x] x)
(fn [x]
(if x
(println "True")
(println "False"))
x))
但是,Hackerrank 说 stdout 上没有打印任何内容。
另外,当我尝试使用 int cider repl 时,它并不像往常一样
(False
False
false false)
对于我的两个测试用例..
这是for 的问题还是我的代码哪里错了?
【问题讨论】:
-
发现我应该使用
doseq而不是for