CoCalc -- Collaborative Calculation in the Cloud
Sharedsupport / 2016-07-08-135753-filter.sagewsOpen in CoCalc

Examples for support purposes...

Is there any code that allows me to filter sequences? For example, if there are 4 sequences, (1,2,3,5), (1,2,3,6), (1,2,4,5), (1,2,5,6), but I only want to see the sequences that do not include certain numbers in the same sequence, let's say '1 and 5'. So in this case, only (1,2,3,6) would show.

v = [ (1,2,3,5), (1,2,3,6), (1,2,4,5), (1,2,5,6)]

[x for x in v if 3 not in set(x) and 6 not in set(x)]
[(1, 2, 4, 5)]