Items tagged with subsop

I have a list of functions which looks like this:

RR:={F[l, m-2, n-1], F[l, m+2, n], F[l, m+2, n-1], F[l-1, m+1, n-2], ...}

I wish to remove the first and second arguments from the functions, so only leaving the third argument containing the n's. I then wish to group these remaining terms together to shorten the list. i.e.

RR:={F[n-1], F[n], F[n-2]}

I have used the 'subsop' command with 1 and 2 specified as NULL in a loop, but I was wondering if there is a better way to do it? I like to avoid loops where possible and use some inbuilt Maple magic to make it tidier and (usually) more efficient.



 Hi, I got an error (the code below) when using subsop in procedure. But when I replace "NULL" with an integer, it would work.                             

> phephoi := proc (A, B)
local check, i, j, C, E;
C := A;
E := B;
for i from 1 to nops(C) do
   check := 0; 
   for j from 1 to nops(E) do
      if E[j] = C[i] then check := 1; break; end if;
   end do; 
   if check = 0 then C := subsop(i = NULL, eval(C)); end if;
end do;
return C;
end proc;

> A := [1, 2, 3, 5, 6, 7];
B := [2, 4, 7, 11, 8];
phephoi(A, B);

                             [1, 2, 3, 5, 6, 7]
                              [2, 4, 7, 11, 8]
Error, (in phephoi) invalid subscript selector

Page 1 of 1