lisp/word-search.lisp
2024-12-16 14:34:52 -05:00

26 lines
707 B
Common Lisp

;; TODO:
;; an M*N word search has M horiz, N vert, M diag, N diag
(load "utils.lisp")
;; not good
(defun eacharray (f arr)
(apply #'map-product
#'(lambda (&rest idxs) (apply f (apply #'aref arr idxs) idxs))
(mapcar #'iota (array-dimensions arr))))
(defmacro docross ((x y &optional c) arr &body body)
(once-only (arr)
`(loop for ,y below (array-dimension ,arr 0)
do (loop for ,x below (array-dimension ,arr 1)
do
,(if c
`(symbol-macrolet ((,c (aref ,arr ,y ,x)))
(progn ,@body))
`(progn ,@body))))))
(defun things (arr words)
(docross (x y)))