From: rearman Date: Mon, 13 Apr 2026 21:15:54 +0000 (-0400) Subject: Use the 0-if-null defun X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=26a90ab6c4a32dbb3e549009fddda936d7f57100;p=lisp%2Fworkenv.git Use the 0-if-null defun --- diff --git a/math.lisp b/math.lisp index 405669d..ec68ded 100644 --- 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)))))