From 559e7770e0a606b89c6d812dba1aac645069ac62 Mon Sep 17 00:00:00 2001 From: "Thomas M. Hermann" Date: Mon, 15 Oct 2012 21:39:09 -0500 Subject: [PATCH] Implement default-epsilon for sequences using LOOP. --- extensions/floating-point.lisp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/extensions/floating-point.lisp b/extensions/floating-point.lisp index 369dde8..1789353 100644 --- a/extensions/floating-point.lisp +++ b/extensions/floating-point.lisp @@ -131,26 +131,22 @@ ((complex long-float) (* 2L0 long-float-epsilon)) (t 0))) -;;; FIXME : Use the LOOP (defmethod default-epsilon ((value list)) "Return the default epsilon based on contents of the list." - (reduce (lambda (x y) (max x (default-epsilon y))) - value :initial-value 0)) + (loop for val in value maximize (default-epsilon val))) -;;; FIXME : Use the LOOP (defmethod default-epsilon ((value vector)) "Return the default epsilon based on the contents of the vector." - (reduce (lambda (x y) (max x (default-epsilon y))) - value :initial-value 0)) + (loop for val across value maximize (default-epsilon val))) -;;; FIXME : Use the LOOP (defmethod default-epsilon ((value array)) "Return the default epsilon based on the contents of the array." - (reduce (lambda (x y) (max x (default-epsilon y))) - (make-array (array-total-size value) - :element-type (array-element-type value) - :displaced-to value) - :initial-value 0)) + (loop for val across + (make-array + (array-total-size value) + :element-type (array-element-type value) + :displaced-to value) + maximize (default-epsilon val))) #| (RELATIVE-ERROR x y) => float -- 2.11.4.GIT