Bill Allombert on Wed, 02 Mar 2016 18:52:53 +0100


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

Re: extremal case of component extraction


On Mon, May 20, 2013 at 05:08:23PM +0200, Bill Allombert wrote:
> Dear PARI developers,
> 
> In PARI 2.6.0 we have:
> 
> ? [1,2][2..-2]
>   ***   at top-level: [1,2][2..-2]
>   ***                 ^------------
>   *** _[_.._]: inconsistent dimensions in _[..].
> 
> ? [1,2][2..1]
>   ***   at top-level: [1,2][2..1]
>   ***                 ^-----------
>   *** _[_.._]: inconsistent dimensions in _[..].
> 
> I think a case could be made to return [] in both case.
> 
> On the other hand
> 
> ? [1,2][3..1]
> 
> should probably fail.

I implement that. Also 0 is handled differently.
Specifically:
1. Negative values are converted to positive value by adding the length.
2. 0 is considered negative when at the left of "..", positive otherwise
3. [a..b] is allowed as long as (after the above conversion) b-a+1 >= 0
and return a vector of length b-a+1.

So V[1..0] and V[0..-1] returns [].

Cheers,
Bill.