Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn input-move
- [heaps]
- (loop []
- (println (heap-string heaps))
- (let [row (prompt-int "From which row do you want to remove?")
- amount (prompt-int "How many do you want to leave?")
- move (try
- (let [new-heaps (assoc heaps row amount)]
- (if (legal-move? heaps new-heaps)
- new-heaps
- (throw (Exception. "Illegal move"))))
- (catch IndexOutOfBoundsException _ nil)
- (catch Exception _ nil))]
- (or move (do
- (println "Illegal move")
- (recur))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement