Advertisement
loloof64

Clojure TicTacToe show board

Aug 21st, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn show-board [board]
  2.     "Prints the board on the screen.
  3.      Board must be a list of three lists of three elements with
  4.      :cross for a cross and :circle for a circle, other value for nothing"
  5.     (let [
  6.           convert-elem {:cross \X, :circle \O}
  7.           convert-line (fn [elems-line]
  8.                             (reduce str (map #(convert-elem % \_) elems-line)))
  9.           ]
  10.          (doseq [line board]
  11.             (println (convert-line line)))))
  12.  
  13. (show-board [[:cross :circle :a] [:none :circle :none] [:cross :none :none]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement