]> git.earman.xyz Git - lisp/workenv.git/commitdiff
Use the 0-if-null defun master
authorrearman <rearman@r717.net>
Mon, 13 Apr 2026 21:15:54 +0000 (17:15 -0400)
committerrearman <rearman@r717.net>
Mon, 13 Apr 2026 21:15:54 +0000 (17:15 -0400)
math.lisp

index 405669da10f545a2aedb39b144036016e8a5f6c7..ec68ded266e1cfa02437e81fbcfb7f2865f775b2 100644 (file)
--- a/math.lisp
+++ b/math.lisp
@@ -29,9 +29,9 @@ If a 2d point is given, it is converted to 3d with z=0."
        (mapcar #'/
                (list (apply #'+ (mapcar #'first points))
                      (apply #'+ (mapcar #'second points))
-                     (apply #'+
-                            (mapcar #'(lambda (x) (if (null (third x)) 0 (third x)))
-                                    points)))
+                     (apply #'+ (mapcar #'
+                                 (lambda (x) (0-if-null (third x)))
+                                 points)))
                (list numpoints numpoints numpoints)))))
 
 (defun dot-product-points (apoint bpoint)
@@ -67,14 +67,10 @@ Inputs are of the form '(ax ay az) '(bx by bz).
 The function returns '(cx cy cz)."
   (let ((ax (first apoint))
        (ay (second apoint))
-       (az (if (null (third apoint))
-               0
-               (third apoint)))
+       (az (0-if-null (third apoint)))
        (bx (first bpoint))
        (by (second bpoint))
-       (bz (if (null (third bpoint))
-               0
-               (third bpoint))))
+       (bz (0-if-null (third bpoint))))
     (list (- (* ay bz) (* az by))
          (- (* az bx) (* ax bz))
          (- (* ax by) (* ay bx)))))