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

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

Re: (*) -> 1


From: Tassilo Horn
Subject: Re: (*) -> 1
Date: Thu, 19 Jan 2023 11:06:10 +0100
User-agent: mu4e 1.9.16; emacs 30.0.50

Jean Louis <bugs@gnu.support> writes:

> I look only at functions like:
>
> (+ (*) (*) (*)) ➜ 3
>
> which do not result that mathematically shall be sum of three
> multiplications.

(*) is 1 because 1 is the neutral element of multiplication.
(+) is 0 because 0 is the neutral element of addition.

> It is error in programming language.
>
> Without trying to explain it, provide Lisp function where it is
> actually useful.
>
> Or otherwise, the research has shown so far:
>
> 1. nobody knows why is it useful in Lisp

It's useful because you can (apply #'+ my-list-of-numbers) and get a
correct result.

> 2. various hypothesis have been tried out and tested. All with the
>    attempt to justify how (*) ➜ 1 should be there, but none can find
>    reason for (1), see aove.
>
> 3. there is no to me known piece of Emacs Lisp that would raise error
>    if function `*' would be made to require two arguments, as this
>    point (3) would lead to probable understanding of it.
>
> and
>
> 4. Function makes something out of nothing instead of raising error: 
>    (+ (*) (*) (*)) ➜ 3
>
>> Saying "I have no cars in my garage, but (*) ==> 1, so where is that
>> car out of nothing?"
>
> Joke? It was joke.

The sum of cars in your garage is (apply #'+ nil) => 0 which is
absolutely correct.

>    (+ (*) (*) (*)) ➜ 3
>
> Where is example of how it is useful?

Well, replace + and * with `and' and `or' and you get the canonical
disjunctive or conjunctive normal forms.  And then you can use it with
lists of nil/non-nil values and it will be logically correct even when
an empty lists sneaks in which is essentially the constant t or nil in
this context.

Bye,
Tassilo



reply via email to

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