Skip to content

Instantly share code, notes, and snippets.

@spratt
Created March 26, 2011 22:17
Show Gist options
  • Save spratt/888690 to your computer and use it in GitHub Desktop.
Save spratt/888690 to your computer and use it in GitHub Desktop.
(defun ttt-print (board)
"Prints a tic-tac-toe board."
(let* ((symbol nil)
(nl (string #\Newline))
(str (concatenate 'string
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl)))
(loop for i from 0 below (length str) do
(when (equal #\S (char str i))
(progn
(setq symbol (pop board))
(if (equal nil symbol)
(setf (char str i) #\Space)
(setf (char str i) (char (symbol-name symbol) 0))))))
(format t str)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment