# how to substract two tuples selections

i have two tuples select done with modulo on a range {-1,1} :

Select[Tuples[Range[-1, 1], 3], Mod[Total[#], 1] == 0 &]


and

Select[Tuples[Range[-1, 1], 3], Mod[Total[#], 2] == 0 &]


these generates coordinates for centers of spheres .

I am trying to filter the first select (mod 1) to remove the result of the second select (mod 2) from it in order to remove the coordinates that match in the two select from the final result.

How can it be achieved ?

• Related – Stitch Jan 23 '17 at 22:24

ClearAll[f, g]
f = Select[Tuples[Range[-1, 1], 3], Mod[Total[#], 1] == 0 &]
g = Select[Tuples[Range[-1, 1], 3], Mod[Total[#], 2] == 0 &]


If we want to delete g from f:

DeleteCases[f, Alternatives @@ g]

Fold[Cases[#1, Except@#2] &,f,g]

• Complement[f, g] is way more compact. – J. M. will be back soon Jan 24 '17 at 2:41
• @J.M. Absolutely! – Stitch Jan 24 '17 at 2:42