Question: Problem when using "subsop" in a procedure

 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
 

Please Wait...