Subject: ‘min’ and ‘max’ behavior when mixing exact and inexact numbers.

From: Mathieu Lirzin <[email-masked]>
Date: Mon, 26 Mar 2018 16:11:01 +0200

Hello,

I am observing a unexpected behavior of ‘min’ and ‘max’:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (min 1 2.4)
$2 = 1.0
scheme@(guile-user)> (min 1/2 4.0)
$7 = 0.5
scheme@(guile-user)> (max 4 3.5)
$4 = 4.0
--8<---------------cut here---------------end--------------->8---

I would expect the results to be integers instead.  AIUI the
implementation of the ‘min’ procedure should to be equivalent to:

  (define (min val . rest)
    (let loop ((x val) (other rest))
      (match other
        (() x)
        ((y . rest) (loop (if (< x y) x y) rest)))))

Maybe there is a good performance reason for the current behavior.  If
that's the case then it should be specified in the manual that exact
numbers are converted to real numbers when at least one of the arguments
is inexact.

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37