Use every instead of all

This commit is contained in:
2024-10-29 20:00:39 +00:00
parent b2c570524c
commit cd94c350e6
2 changed files with 3 additions and 9 deletions

View File

@@ -29,12 +29,6 @@
(defun id (x) x) (defun id (x) x)
(defun all (pred lst)
(if (not (cdr lst))
(funcall pred (car lst))
(and (funcall pred (car lst))
(all pred (cdr lst)))))
(defun remove-nth (n lst) (defun remove-nth (n lst)
(if (or (null lst) (= n 0)) (if (or (null lst) (= n 0))
(cdr lst) (cdr lst)

View File

@@ -23,7 +23,7 @@
(defun is-visible? (x y) (defun is-visible? (x y)
(if (or (= x 0) (= x (- n-trees 1)) (if (or (= x 0) (= x (- n-trees 1))
(= y 0) (= y (- n-trees 1))) (= y 0) (= y (- n-trees 1)))
t t
(let* ((tree (get-tree x y)) (let* ((tree (get-tree x y))
(lt-tree? (lambda (a) (< a tree))) (lt-tree? (lambda (a) (< a tree)))
@@ -34,8 +34,8 @@
(col-top (subseq col 0 y)) (col-top (subseq col 0 y))
(col-bottom (subseq col (+ y 1)))) (col-bottom (subseq col (+ y 1))))
(some #'id (some #'id
(mapcar (lambda (x) (all lt-tree? x)) (mapcar (lambda (x) (every lt-tree? x))
(list row-left row-right col-top col-bottom)))))) (list row-left row-right col-top col-bottom))))))
(defun how-many-visible () (defun how-many-visible ()
(loop (loop