Bill Allombert on Mon, 07 May 2012 21:55:41 +0200


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

Re: new GP language feature: simultaneous affectations


On Sat, Apr 28, 2012 at 04:20:36PM +0200, Bill Allombert wrote:
> Dear PARI developpers,
> 
> I have created a GIT branch 'bill-multi_affect'
> which allow to affect several values at once:
> 
> ? [a,b,c]=[1..5]
> %1 = [1,2,3,4,5]
> ? [a,b,c]
> %2 = [1,2,3]
> ? [a,b]=[b,a]
> %3 = [2,1]
> ? [a,b,c]=[1..2]
>   ***   at top-level: [a,b,c]=[1..2]
>   ***                      ^---------
>   ***   array index (3) out of allowed range [1-2].
> 
> Currently, affecting to components (a[i] etc.) is not supported.

I hae just updated the branch with a version which allows
arbitrary components:

? M=matrix(5,5);
? [M[1,1],M[2,],M[,4]]=[4,[1..5],[6..10]~]
%6 = [4, [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]~]
? M
%7 =
[4 0 0  6 0]

[1 2 3  7 5]

[0 0 0  8 0]

[0 0 0  9 0]

[0 0 0 10 0]

Please tell me if you find any problems.

Cheers,
Bill.