replace a bunch of minesweeper-for with dotimes.
1 files changed, 31 insertions(+), 31 deletions(-)

M minesweeper.el
M minesweeper.el +31 -31
@@ 316,13 316,13 @@ There's a field of squares; each square 
 (defun minesweeper-fill-field (protect-row protect-col)
   "Fills '*minesweeper-field* with '*minesweeper-mines* mines, and builds the neighbor count. It will not place any mines in the square (protect-row, protect-col)."
   (minesweeper-debug "filling the field")
-  (minesweeper-for col 0 (1- *minesweeper-board-width*)
-		   (minesweeper-debug "inside outer loop -- col is " (number-to-string col))
-		   (minesweeper-for row 0 (1- *minesweeper-board-height*)
-				    (minesweeper-debug "inside inner loop -- setting up mine " (number-to-string col) " " (number-to-string row))
-				    (minesweeper-set-mine row col ?0)
-				    (minesweeper-hide row col)
-				    (minesweeper-unmark row col)))
+  (dotimes (col *minesweeper-board-width*)
+    (minesweeper-debug "inside outer loop -- col is " (number-to-string col))
+    (dotimes (row *minesweeper-board-height*)
+      (minesweeper-debug "inside inner loop -- setting up mine " (number-to-string col) " " (number-to-string row))
+      (minesweeper-set-mine row col ?0)
+      (minesweeper-hide row col)
+      (minesweeper-unmark row col)))
   (minesweeper-debug "done setting zeros; now inserting mines")
   (minesweeper-insert-mines *minesweeper-mines* protect-col protect-row))
 

          
@@ 332,13 332,13 @@ There's a field of squares; each square 
   (let* ((square-count (1- (* *minesweeper-board-width* *minesweeper-board-height*)))
 	 (mines (make-vector square-count (list 0 0)))
 	 (pos 0))
-    (minesweeper-for col 0 (1- *minesweeper-board-width*)
-		     (minesweeper-for row 0 (1- *minesweeper-board-height*)
-				      (unless (and (eq row protect-row)
-						   (eq col protect-col))
-					(minesweeper-debug "setting " (number-to-string col) "\t" (number-to-string row))
-					(aset mines pos (list row col))
-					(setq pos (1+ pos)))))
+    (dotimes (col *minesweeper-board-width*)
+      (dotimes (row *minesweeper-board-height*)
+        (unless (and (eq row protect-row)
+                     (eq col protect-col))
+          (minesweeper-debug "setting " (number-to-string col) "\t" (number-to-string row))
+          (aset mines pos (list row col))
+          (setq pos (1+ pos)))))
     (dotimes (i count)
       (let* ((rand (random (- square-count i)))
 	     (ele (aref mines rand)))

          
@@ 460,10 460,10 @@ There's a field of squares; each square 
   (let ((inhibit-read-only t)
         (pt (point)))
     (erase-buffer)
-    (minesweeper-for row 0 (1- *minesweeper-board-height*)
-		     (minesweeper-for col 0 (1- *minesweeper-board-width*)
-				      (minesweeper-insert-value (minesweeper-view-mine row col reveal)))
-		     (newline))
+    (dotimes (row *minesweeper-board-height*)
+      (dotimes (col *minesweeper-board-width*)
+        (minesweeper-insert-value (minesweeper-view-mine row col reveal)))
+      (newline))
     (unless reveal
       (insert-char ?\s *minesweeper-board-width*) ;;insert a row below the field for choosing neighbors.
       (newline)

          
@@ 636,19 636,19 @@ There's a field of squares; each square 
                         point
                         (1+ point)
                         (get-buffer "minesweeper")))
-        (minesweeper-for newrow 0 *minesweeper-board-height*
-                         (minesweeper-for newcol 0 *minesweeper-board-width*
-                                          (when (and (minesweeper-marked newrow newcol)
-                                                     (not (minesweeper-is-mine newrow newcol)))
-                                            (let ((pt (+ (* newrow
-                                                            (1+ *minesweeper-board-height*))
-                                                         newcol
-                                                         1)))
-                                              (minesweeper-debug "(" (number-to-string newrow) ", " (number-to-string newcol) ") is mismarked.")
-                                              (move-overlay (copy-overlay *minesweeper-mismarked-overlay*)
-                                                            pt
-                                                            (1+ pt)
-                                                            (get-buffer "minesweeper"))))))))
+        (dotimes (newrow *minesweeper-board-height*)
+          (dotimes (newcol *minesweeper-board-width*)
+            (when (and (minesweeper-marked newrow newcol)
+                       (not (minesweeper-is-mine newrow newcol)))
+              (let ((pt (+ (* newrow
+                              (1+ *minesweeper-board-height*))
+                           newcol
+                           1)))
+                (minesweeper-debug "(" (number-to-string newrow) ", " (number-to-string newcol) ") is mismarked.")
+                (move-overlay (copy-overlay *minesweeper-mismarked-overlay*)
+                              pt
+                              (1+ pt)
+                              (get-buffer "minesweeper"))))))))
   (when (y-or-n-p (if won
                       (concat "Congrats! You've won in "
                               (minesweeper-game-duration-message)