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

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

(*) -> 1


From: Jean Louis
Subject: (*) -> 1
Date: Tue, 17 Jan 2023 19:04:02 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

* Andreas Eder <a_eder_muc@web.de> [2023-01-17 15:20]:
> > For now vague purpose is only to satisfy some other functions which
> > process lists, like `reduce' or `apply', I am searching for
> > confirmation if that was the sole purpose.
> 
> The purpose is to be consistent in a mathematical sense.
> There empty products are 1 and empty sums are 0. That is the only to
> sensibly define it and to  fulfill the associative property of the
> operations.

There are different contexts:

- mathematical sense whereby "+" always require addends, without it,
  there is nothing to add. A number like zero is alright, but it must
  be there.

- in lisp no addend is needed to yield (+) ➜ 0

- there is convention of identity elements, fine, but I do not see
  relation to above, neither why is one convention nullified in favor
  of the other convention

Then we have:

- mathematical sense whereby "*" always require 2 factos, without it,
  there is nothing to multiply. That is also convention. 

- in lisp no factor is needed to yield (*) ➜ 1

- because some other convention is followed nullyfing the previously
  explained one.

Still I have not find clear relation why is it so.

It is definitely not in every Lisp that way.

PicoLisp does not think so:

$ pil
: (+)
-> NIL
: (*)
-> NIL

and it handles properly function `apply' without having (+) ➜ 0:
----------------------------------------------------------------

: (apply '+ '(1 2 3 4))
-> 10

(apply '* '(1 2 3 4))
-> 24

Emacs Lisp:

(-) ➜ 0

but Guile:

-)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong number of arguments to -

So there are differences and the question is still open why is Lisp
using those identity elements.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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