finish comments
This commit is contained in:
parent
0681ec7ba5
commit
e4cd2808c2
3
main.rkt
3
main.rkt
|
@ -49,7 +49,8 @@
|
||||||
; given a point that is the top-left corner of a square on the grid, returns the amount of edges surrounding that square.
|
; given a point that is the top-left corner of a square on the grid, returns the amount of edges surrounding that square.
|
||||||
(define (count-square p g)
|
(define (count-square p g)
|
||||||
; explanation:
|
; explanation:
|
||||||
; for every item in the grid (g), test it against every edge of the box
|
; for every item in the grid (g), test it against every edge of the box for equality. these form a list, which is then folded into #t or #f if any match.
|
||||||
|
; then only those that match are kept and this list is checked for length to determine the matching lines.
|
||||||
(length
|
(length
|
||||||
(filter (lambda (item) (foldl (lambda (x y) (or x y)) #f
|
(filter (lambda (item) (foldl (lambda (x y) (or x y)) #f
|
||||||
(for/list ([x (list (point 0 0) (point 0 1) (point 1 0) (point 0 0))]
|
(for/list ([x (list (point 0 0) (point 0 1) (point 1 0) (point 0 0))]
|
||||||
|
|
Loading…
Reference in New Issue