Blame


1 665c255d 2023-08-04 jrmu (defun make-position (row col)
2 665c255d 2023-08-04 jrmu (cons row col))
3 665c255d 2023-08-04 jrmu (defun position-row (pos)
4 665c255d 2023-08-04 jrmu (car pos))
5 665c255d 2023-08-04 jrmu (defun position-col (pos)
6 665c255d 2023-08-04 jrmu (cdr pos))
7 665c255d 2023-08-04 jrmu (defun positions-equal (a b)
8 665c255d 2023-08-04 jrmu (equal a b))
9 665c255d 2023-08-04 jrmu (defvar empty-board '())
10 665c255d 2023-08-04 jrmu (defun adjoin-position (row col positions)
11 665c255d 2023-08-04 jrmu (append positions (list (make-position row col))))
12 665c255d 2023-08-04 jrmu (defun attacks? (a b)
13 665c255d 2023-08-04 jrmu (let ((a-row (position-row a))
14 665c255d 2023-08-04 jrmu (a-col (position-col a))
15 665c255d 2023-08-04 jrmu (b-row (position-row b))
16 665c255d 2023-08-04 jrmu (b-col (position-col b)))
17 665c255d 2023-08-04 jrmu (cond
18 665c255d 2023-08-04 jrmu ((= a-row b-row) t)
19 665c255d 2023-08-04 jrmu ((= a-col b-col) t)
20 665c255d 2023-08-04 jrmu ((= (abs (- a-col b-col))
21 665c255d 2023-08-04 jrmu (abs (- a-row b-row)))