Hi,
It appears to me that for loops don’t work properly in Clojure. For the Temperatures puzzle I reduced the code to this very basic form:
(ns Solution
(:gen-class))
(defn -main [& args]
(for [i (range 1)] (println (inc i))))
The expected behaviour is to print
1
, and pass the first test. I tested it in a Clojure REPL.
The actual result is
Failure
Found: Nothing
Expected: 1
Aries1
May 17, 2018, 12:04pm
#2
If Clojure for
loop was defective, I’m pretty sure it would has been detected 10 years ago. Maybe you should try the following code snippet then take a look at the Clojure documentation on laziness .
(ns Solution
(:gen-class))
(defn -main [& args]
(dorun (for [i (range 1)] (println (inc i)))))
Thanks for the help! I was thinking it was broken on codingame.com , since it worked just fine in my local REPL.
I find the same problem.
for is not working anywhere, puzzel or clash of code. I need to modify a loop instead.