Karim Belabas on Tue, 08 Jul 2014 09:14:06 +0200

 Re: concat([])

```* Max Alekseyev [2014-07-08 02:18]:
> Btw:
>
> ? [] == 0
> %8 = 1
> ? [] == ""
> %9 = 0
>
> Should the latter be also 1?

No. The semantics of "==" is fuzzy (because it must apply to all pairs
of PARI objects and decide whether they should be "mathematically"
equal, which leaves plenty of room for ambiguities and abuse), that's
why we introduced the stricted operator "===" (arguments must
have the same type, length and internal representation : we won't
decide that 1.0 === 1)

The actual implementation of "x == y"

* is the sensible one when the types of x and y agree (same as ===
except for inexact types t_REAL, t_PADIC, t_SER, when we check whether
the significant terms/digits agree to the lowest of the two acuracies)

* computes x - y otherwise and compares the result with 0 (gequal0) if
it exists, and immediately decides that x != y if the subtraction can't
be computed (raises an exception).

* gequal0 behaves almost decently on scalars (for inexact types it tests
whether the object has no significant terms/digits; the rule for
t_COMPLEX is complicated, we basically test whether norm(x) is 0 which
is not equivalent to testing real/imaginary parts separately). And
recursively test entries of vector/matrices.

Strings cannot be "subtracted" so the above always yield an exception: a
t_STR can never be "==" to a non-t_STR.

OTOH, [] - 0 is valid -- in fact v/*t_VEC or t_COL*/ + 0 is always valid
and returns v -- and returns a vector all of whose components are 0 (the
elements of the empty set have nice properties), so equal0 returns TRUE
in this case. Hence [] == 0

Cheers,

K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`

```