Page 1 of 1

for-all

Posted: Sat Mar 18, 2023 7:56 pm
by bebalo
> (exists integer? '())
nil
> (exists integer? '(a b 3 t 7))
3
> (for-all integer? '(a b 3 t 7))
nil

Well, that's fine. But what about this:
> (for-all integer? '())
true

Is it intentionally so or have I overlooked something?
-----
My newLISP:
newLISP v.10.7.5 64-bit on Linux IPv4/6 UTF-8 libffi

Re: for-all

Posted: Sun Mar 19, 2023 10:36 am
by bebalo
The same holds for float:

> (for-all float? '())
true

Re: for-all

Posted: Fri Mar 24, 2023 2:17 pm
by Astrobe
It is correct from the perspective of mathematics : the relationship with existential and universal quantification is pretty clear. Math says that (trasposed to newlisp) :

(not (for-all integer? L)) is equivalent to (exists (fn(x) (not (integer? x))) L)

and conversely

(not (exists integer? L)) is equivalent to (for-all (fn(x) (not integer? x))) L)

So once it has been decided that (exists) on an empty list returns nil (which makes sense), (for-all) for an empty list has to return true.

Re: for-all

Posted: Fri Mar 24, 2023 7:38 pm
by bebalo
Mathematically correct -- good to know. Thank you for your help.