Karim Belabas on Sun, 16 Sep 2018 08:51:44 +0200


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

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


* 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]
`