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

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

Re: (*) -> 1


From: Michael Heerdegen
Subject: Re: (*) -> 1
Date: Tue, 17 Jan 2023 20:18:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Jean Louis <bugs@gnu.support> writes:

> Do you have mathematical exercise in Lisp that may demonstrate it
> usefulness?
>
> Is it only for representation purposes like Eduardo explained,
> something like:
>
> (* 2 2 2) ➜ 8
> (* 2 2) ➜ 4
> (* 2) ➜ 2
> (*) ➜ 1
>
> Do you think it is only for representation or consistency purposes? Or
> there is some actual use?

The complete thing must be consistent, but anything must be consistent
to avoid false results, consistence is not the purpose.

The question of use is a valid one, we missed to answer it yet.  It
wasn't clear to me that this was part of what you are asking for.

Ok, I'll try to give an example.

You list your expenses in a form.  On six pages.  You write the sum of
all expenses of any page on the bottom of the page to be able to
calculate the final sum conveniently.

But on page 5 there are no expenses at all.  What do you write on the
bottom of that page?  You could write nothing, but then you might wonder
if you have forgotten to fill out that page.  You could also leave a
special note "no expenses" - but in Lisp we don't have such special
values that can be used in summation.  So you just write "0" onto that
page - the partial sum of no summands.  That works because adding 0
doesn't change the final result (as adding zero summands to the final
sum would) - it's the same in the case of summation: 0 is the "nothing"
of addition.

Likewise, 1 is the "nothing" of products and "" is the "nothing" of
string `concat'enation, etc.  This interpretation only makes sense when
the result of (+), (*), (concat) appears as intermediate result in some
other call of `+', `*', `concat'.  By themselves the value is not always
meaningful (0 as the value of the empty sum might be meaningful, 1 as
result of an empty product less, the empty string as results of
concatenating no strings -- depends).  But it allows to avoid to treat
the case of empty subsets specially.


> OK I understand people in Common Lisp included it, and Emacs Lisp has
> it, and other Lisps. But why for example Emacs Lisp has (-) ➜ 0 but
> other Lisps not?

That's also a valid question.

(-) and (/) are questionable.  `-' accepts one argument, so e.g. (- 7)
==> 7.  (/ 7.0) is also interpreted as value of 1/7.

I don't care about the results of (-) and (/), these are indeed a bit
obscure IMO.

Michael.




reply via email to

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