Skip to content

Instantly share code, notes, and snippets.

@echosa
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echosa/9028090 to your computer and use it in GitHub Desktop.
Save echosa/9028090 to your computer and use it in GitHub Desktop.
;; GRID is a vector of vectors that represents a game board
;; Example:
;; [[1 3 4 9 5] [5 1 2 4 7] [1 "@" 0 0 5] [4 2 3 9 1] [1 2 3 4 5]]
;; should print out
;; 13495
;; 51247
;; 1@ 5
;; 42391
;; 12345
;;
;; I have indicated in <CAPS> the arguments I need to have incremented
(defn print-grid [grid]
"Prints the grid to the screen."
(s/put-string scr 0 0 (print-str grid))
(mapcat (fn [row]
(mapcat (fn [item]
(s/put-string scr
<X-POSITION-INCREMENT-EVERY-INNER-MAPCAT-LOOP>
<Y-POSITION-INCREMENT-EVERY-OUTER-MAPCAT-LOOP>
(if (= item 0)
" "
(print-str item))))
row))
grid)
(s/redraw scr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment