help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (*) -> 1


From: Óscar Fuentes
Subject: Re: (*) -> 1
Date: Wed, 18 Jan 2023 13:46:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

<tomas@tuxteam.de> writes:

>> I was prompted to enter the discussion when I saw your reference to
>> Mathematics. As almost every other math-related thing in computers,
>> Elisp's + is a toy representation of Sigma. And then the relevant
>> characteristics of Sigma for this discussion are a convention among
>> practitioners, not a proper mathematical fact.
>
> This goes a bit deeper: whenever you have an associative operator
> [i.e. (a + b) + c == a + (b + c)],
>
>  1. the "variadic extension" is straightforward, since you can leave
>     out the parentheses in (a + (b + (c + ...))) without losing info
>  2. the extension to zero arguments is also straightforward *provided*
>     you have a neutral element, since 0 + a == a.
>
> This works for products, logical and, or, set union and intersection,
> you name it (in mathematical logic, you often see the or/and cousins
> of Sigma and Pi; in set theory likewise the union/intersection things).

Yes.

>> Although it is possible that the implementors were inspired by Sigma, I
>> think it is more probable that they made + variadic because s-exps like
>> (+ (+ 1 2) 3) are awkward and then extended the function with support
>> for 0 and 1 arguments because they are convenient when defining macros.
>
> I think a mathematician doesn't really distinguish between "Sigma" and
> just "sum". Sigma is just a notation. No magic, just maths.

Sigma is often used with infinite terms, and then it no longer is a sum,
at least not in the naive sense that Elisp + operates. Elisp + would
correspond to the simplest incarnation of Sigma. Even a programmer can't
assume that associativity and commutativity can be used on a long,
finite, sum.

But that's a digression. My point is that (+) and (+ n) are not
supported (or, better said, appreciated) because some mathematical
reason, but because they are as much convenient when writing macros as
they are silly on "normal" code. It's about making easy for the
programmer to do some mundane tasks, not about Mathematics.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]