Handling stdin Clojure -


the below doesn't seem work, i'm not quite sure why. move-board take in 2d array , return 2d array, rest of code there. i'm trying accomplish following python:

while true:   stuff   if gameover:     print("game over!")     break 

clojure isn't working (prints board once, asks input, hangs)

(defn game-loop [board]   (loop [b board]     (if (game-over? b) "game over!"         (do (print-board b)             (recur (move-board (read-line) b)))))) 

we need see other functions doing. fabricated them minimally seems likely, , reindented make if-branch clearer. loop unnecessary.

(defn game-over? [b] false) (defn print-board [b] (println b)) (defn move-board [ln b] (println "moving board:" ln))  (defn game-loop [b]   (if (game-over? b)     "game over!"     (do (print-board b)         (recur (move-board (read-line) b)))))  (game-loop :bored) 

with top 3 functions, loop behaves expected: prompting single line, infinitely. well, @ least first time, "hang" issue reproduced.

this being caused this issue jvm. discussed here.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -