Sujet : Re: Why don't people like lisp?
De : jbb (at) *nospam* notatt.com (Jeff Barnett)
Groupes : comp.lang.lispDate : 03. Jul 2024, 04:59:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v62eqe$20o3c$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 7/2/2024 6:15 PM, Paul Rubin wrote:
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
If a function like “max” or “min” is defined to return a number,
They are defined to return the larger or smaller of two members of any
datatype with an order relation, e.g. lexicographic order on strings.
There is no infinity for strings. There's also none for integers, for
that matter.
then it makes sense that the maximum of an empty list should be -∞,
Meh, it's just undefined. Otherwise you can't tell whether the list is
empty or actually contains -∞ as a value.
Consider a SUM of a set of integers: mathematicians define that operator
to return 0 for the empty set
Similarly:
MAX empty-set = -oo
MIN empty-set = +oo
PRODUCT empty-set = 1
and, in general,
GROUP OPERATOR empty-set = group-identity-element
This convention makes a whole lot of sense because, for one thing, it
makes definition of indefinite number of argument functions very easy.
For example SUM nil = 0
and SUM (CONS x list) = x + SUM list
If you try this sort of definition for MAX, the only value in all known
mathematics that can replace 0 in the above is -oo.
If you want to get into details, what I've said here applies to abelian
groups; we need to be careful about order in other settings.
and a lot of special cases no longer become special.
More likely a lot of errors go undetected. Better to handle the special
cases in some sane way, if they can happen in the program and need
handling.
PS oo is meant to stand for numerical infinity.
-- Jeff Barnett