If we have a list like $[[2,1],[5,2,1],[6,5,2,1],[9,10]]$ and I want to find the result in the form of $[[6,5,2,1], [9,10]]$ and want to delete all those list that are contained in another. How may I program this
I do like let FV := $[[2,1],[5,2,1],[6,5,2,1],[9,10]]$;
Intersection:=function(FV)
local A, B, a;
for A in FV do
for B in FV do
if Intersection(A,B) = B then
a := Position(FV,B);
Unbind(FV[a]);
fi;
od;
od;
return FV;
end;
However, I find the empty list after running this program. I need the answer like $[[6,5,2,1],[9,10]]$
It can be achieved as follows:
In the running example:
Note:
Intersectionis a poor choice of function name: GAP already has anIntersectionfunction and yourIntersectionfunction looks like it's intending to use GAP'sIntersectionfunction. This might have some unpredictable results.