I've found what purports to be a solution to the TEST problem (Life, The Universe, and Everything) in Clojure, but it fails to produce any output. I'm just trying to get something to work in Clojure so I can move on to other problems but as of now I'm frustrated and disappointed. The code I tried is:
(ns spoj-test)
(defn read-int
[]
(let [s (read-line)]
(Integer/parseInt s)))
(defn main
[] (let [n (read-int)]
(when (not (== 42 n))
(println n)
(recur))))
which fails because (according to SPOJ) it produces no output. When I run this in a Clojure REPL it seems to work fine. Any idea where I've gone wrong? I've also tried running this without the (ns spoj-test), thinking that it might make the main function un-findable, but got the same results. I also tried changing the first line to
(ns clojure.main)
but this did not affect the results either.
created
last reply
- 1
reply
- 1.3k
views
- 1
user
- 1
like