No need to make it a macro

This commit is contained in:
Bram Schoenmakers 2023-02-04 10:56:08 +01:00
parent 574c6ed158
commit fc696060d4

View file

@ -9103,19 +9103,19 @@ Consider your map; how many trees are visible from outside the grid?
(puthash (cons m n) (plist-put cur-value direction value) vmap) (puthash (cons m n) (plist-put cur-value direction value) vmap)
vmap)) vmap))
(defmacro advent/8/count-trees-from-edge () (defun advent/8/count-trees-from-edge ()
''(let ((h (advent/8/height-at hmap m n)) '(let ((h (advent/8/height-at hmap m n))
(vmap-update (apply-partially #'advent/8/update-vmap vmap m n)) (vmap-update (apply-partially #'advent/8/update-vmap vmap m n))
(max-vert (or (advent/8/max-height-at vmap (+ m (* -1 step)) n vprop) 0)) (max-vert (or (advent/8/max-height-at vmap (+ m (* -1 step)) n vprop) 0))
(max-hor (or (advent/8/max-height-at vmap m (+ n (* -1 step)) hprop) 0)) (max-hor (or (advent/8/max-height-at vmap m (+ n (* -1 step)) hprop) 0))
(max-heights (-non-nil (list (max-heights (-non-nil (list
(plist-get (gethash (cons m (1- n)) vmap) :left) (plist-get (gethash (cons m (1- n)) vmap) :left)
(plist-get (gethash (cons m (1+ n)) vmap) :right) (plist-get (gethash (cons m (1+ n)) vmap) :right)
(plist-get (gethash (cons (1- m) n) vmap) :top) (plist-get (gethash (cons (1- m) n) vmap) :top)
(plist-get (gethash (cons (1+ m) n) vmap) :bottom))))) (plist-get (gethash (cons (1+ m) n) vmap) :bottom)))))
(setq vmap (funcall vmap-update hprop (max h max-hor))) (setq vmap (funcall vmap-update hprop (max h max-hor)))
(setq vmap (funcall vmap-update vprop (max h max-vert))) (setq vmap (funcall vmap-update vprop (max h max-vert)))
(setq vmap (funcall vmap-update :visible (advent/8/tree-is-visible hmap m n max-heights))))) (setq vmap (funcall vmap-update :visible (advent/8/tree-is-visible hmap m n max-heights)))))
(defun advent/8/get-visibility-map (hmap process-cell-form) (defun advent/8/get-visibility-map (hmap process-cell-form)
"Transforms the height map HMAP into a visibility map. Each cell is evaluated through PROCESS-CELL-FORM." "Transforms the height map HMAP into a visibility map. Each cell is evaluated through PROCESS-CELL-FORM."