Bill Allombert on Sun, 22 Apr 2012 15:30:47 +0200


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

new GP syntax: slices: M[a..b,^c]


Dear PARI developers,

As discussed at the PARI Ateliers,

I have added a new syntax to replace vecextract:
Instead of vecextract(M,"str1","str2"), you can write M[str1,str2].

Also I have added [x<-b,c(x)] as a short cut for [x|x<-B,c(x)].

Some examples:

? V=[x<-[1..25],issquare(x)]
%1 = [1,4,9,16,25]
? V[2..4] \\ components of indices 2,3,4.
%2 = [4,9,16]
? V[^3] \\ components of indices 2,3,4.
%3 = [1,4,16,25]
? M=matrix(5,5,i,j,j+5*i-5);
? M[2..4,1]
%10 =
[ 6]

[11]

[16]
? M[^4,]
%8 =
[ 1  2  3  4  5]

[ 6  7  8  9 10]

[11 12 13 14 15]

[21 22 23 24 25]

? M[,1..3]
%9 =
[ 1  2  3]

[ 6  7  8]

[11 12 13]

[16 17 18]

[21 22 23]

Cheers,
Bill.