So I am new to maple and need to write a procedure that given one list removes the entries of that list from another.
[> thingy := proc (a1, a2)
[> local i, j, a3;
[> for i to nops(a1) do
for j to nops(a2) do
if evalb(a2[j] = a1[i]) then a3 := subsop(i = NULL, a1) end if;
end do;
end do;
return a3 end proc
essentially, this code returns the original list, a1, as if I had not run the code. I am really quite stumped as of what to do.
Thanks
There's a little ambiguity in your description. I'm interpreting it as meaning that you want every instance within the first list a1 of any member of the second list a2 to be replaced by NULL.
Is this of any use? I mean, do you just need the functionality? Or is it coursework, for you to code it using loops. etc?
You might want to take care about time and space efficiency. Even if your original had worked, it would be creating an entirely new (partial result) list for each time through the nested loops. That could entail the production a great deal of collectible garbage (and the time to clear such).
I'm sure that this is not optimally efficient, but hopefully it scaled not too horribly.