The following question is on python 3.6. Suppose I have lists of sets, for example
L1 = [{2,7},{2,7,8},{2,3,6,7},{1,2,4,5,7}]
L2 = [{3,6},{1,3,4,6,7},{2,3,5,6,8}]
L3 = [{2,5,7,8},{1,2,3,5,7,8}, {2,4,5,6,7,8}]
I need to find all the intersection sets between each element of L1, L2, and L3. E.g.:
{2,7}.intersection({3,6}).intersection({2,5,7,8})= empty
{2,7}.intersection({3,6}).intersection({1,2,3,5,7,8})= empty
{2,7}.intersection({3,6}).intersection({2,4,5,6,7,8})= empty
{2,7}.intersection({1,3,4,6,7}).intersection({2,5,7,8})= {7}
{2,7}.intersection({1,3,4,6,7}).intersection({1,2,3,5,7,8})= {7}
{2,7}.intersection({1,3,4,6,7}).intersection({2,4,5,6,7,8})= {7}
...............................
If we keep doing like this, we end up with the following set:
{{empty},{2},{3},{6},{7},{2,3},{2,5},{2,6},{2,8},{3,7},{4,7},{6,7}}
Suppose:
- I have many lists L1, L2, L3,...Ln. And I do not know how many lists I have.
- Each list L1, L2, L3..Ln are big, so I can not load all of them into the memory.
My question is: Is there any way to calculate that set sequentially, e.g., calculate between L1 and L2, then using result to calculate with L3, and so on...