Max Alekseyev on Sun, 16 Sep 2018 15:34:00 +0200


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

Re: concat: domain error in concat: vector = []


Bill, Karim,

I thought [] is the universal empty object. E.g., znlog() returns [] (not "", []~, or [;]) if no solutions exist. 
Why not adopt a similar convention for other cases when an empty object (of unspecified nature) is returned?

Regards,
Max

On Sun, Sep 16, 2018 at 2:51 AM, Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> wrote:
* Max Alekseyev [2018-09-15 23:56]:
> Hello,
>
> Since concat(x) accepts x being a list/vector of objects to be
> concatenated, it is expected that concat([]) returns []. However:
>
> ? concat([])
>   ***   at top-level: concat([])
>   ***                 ^----------
>   *** concat: domain error in concat: vector = []
>   ***   Break loop: type 'break' to go back to GP prompt
>
> What's wrong?

concat([x1,...,xn]) returns the concatenation of x1, ..., xn

When the vector is empty we do not know the type of objects we'd be expected
to concatenate: we may just as well return "", [], List(), []~ or [;].

I decided to make it a domain error instead of defining it arbitrarily,
just like vecmax([]) for instance.

Cheers,

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