in minesweeper-neighbors, we can use in-bounds; we don't have to reproduce the logic.
1 files changed, 7 insertions(+), 6 deletions(-)

M minesweeper.el
M minesweeper.el +7 -6
@@ 434,12 434,13 @@ There's a field of squares; each square 
 (defun minesweeper-neighbors (row col)
   "Returns a list of the neighbors of (row, col)."
   (let ((neighbors nil))
-    (dolist (newcol (number-sequence (max (1- col) 0)
-                                     (min (1+ col) (1- *minesweeper-board-width*))))
-      (dolist (newrow (number-sequence (max (1- row) 0)
-                                       (min (1+ row) (1- *minesweeper-board-height*))))
-        (when (not (and (eq newcol col)
-                        (eq newrow row)))
+    (dolist (newcol (number-sequence (1- col)
+                                     (1+ col)))
+      (dolist (newrow (number-sequence (1- row)
+                                       (1+ row)))
+        (when (and (minesweeper-in-bounds newrow newcol)
+                   (not (and (eq newcol col)
+                             (eq newrow row))))
           (push (list newrow newcol)
                 neighbors))))
     neighbors))