From 1ecf7f9c8ace6749392f2509d54f0c0bad93d86d Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Sat, 14 May 2022 08:14:08 -0300 Subject: [PATCH 1/2] SRFI-144: accept zero arguments for flmax/flmin SRFI-144 requires that (flmin) returns +inf.0 and that (flmax) returns -inf.0, so these procedures can't really be aliases to the Chibi implementation of R7RS max and min. --- lib/srfi/144/flonum.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/srfi/144/flonum.scm b/lib/srfi/144/flonum.scm index 273d07e86..de2e29dbf 100644 --- a/lib/srfi/144/flonum.scm +++ b/lib/srfi/144/flonum.scm @@ -17,8 +17,8 @@ (define fl- -) (define fl* *) (define fl/ /) -(define flmax max) -(define flmin min) +(define (flmax . args) (if (null? args) -inf.0 (apply max args))) +(define (flmin . args) (if (null? args) +inf.0 (apply min args))) (define (flabsdiff x y) (abs (- x y))) (define flnumerator numerator) (define fldenominator denominator) From 32ce583927759f77af18ef9314279c5f5297bc36 Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Sun, 15 May 2022 08:30:27 -0300 Subject: [PATCH 2/2] Add some more unit tests to SRFI-144 Tests for flmin, flmax, fl-least, fl-epsilon, fl-greatest are included. --- lib/srfi/144/test.sld | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/srfi/144/test.sld b/lib/srfi/144/test.sld index eb2ab30e0..0076c2705 100644 --- a/lib/srfi/144/test.sld +++ b/lib/srfi/144/test.sld @@ -95,4 +95,13 @@ (test -0.781212821 (flsecond-bessel 1 1.)) (test 0.842700793 (flerf 1.)) (test 0.157299207 (flerfc 1.)) + (test #t (< 0.0 + fl-least + fl-epsilon + 1.0 + (+ 1.0 fl-epsilon) + fl-greatest + +inf.0)) + (test +inf.0 (flmin)) + (test -inf.0 (flmax)) (test-end))))