Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multiple intersection between lists

This is a toy example. Suppose I have a lot of lists (whose the number is not fixed as in the example and I want to determine the intersection of the list like

L=[["B", "C", "D", "E"],["A", "C", "D"],["A", "B","D", "E"], ["A", "B","D", "C"] ]
show(L)
interL1=[x for x in L[0] if x in L[1]]
show(interL1)
interL2=[x for x in L[0] if (x in L[1] and x in L[2])]
show(interL2)
interL3=[x for x in L[0] if (x in L[1] and x in L[2] and x in L[3])]
show(interL2)

But, as the number of list (here 4), I would like to know if there is a possibility to define an operator and like and(L[i],i,0, 4)

Multiple intersection between lists

This is a toy example. Suppose I have a lot of lists (whose the number is not fixed as in the example and I want to determine the intersection of the list like

L=[["B", "C", "D", "E"],["A", "C", "D"],["A", "B","D", "E"], ["A", "B","D", "C"] ]
show(L)
interL1=[x for x in L[0] if x in L[1]]
show(interL1)
interL2=[x for x in L[0] if (x in L[1] and x in L[2])]
show(interL2)
interL3=[x for x in L[0] if (x in L[1] and x in L[2] and x in L[3])]
show(interL2)

But, as the number of list (here 4), I would like to know if there is a possibility to define an operator and and like and(L[i],i,0, 4)

Multiple intersection between lists

This is a toy example. Suppose I have a lot of lists (whose the number is not fixed as in the example and I want to determine the intersection of the list like

L=[["B", "C", "D", "E"],["A", "C", "D"],["A", "B","D", "E"], ["A", "B","D", "C"] ]
show(L)
interL1=[x for x in L[0] if x in L[1]]
show(interL1)
interL2=[x for x in L[0] if (x in L[1] and x in L[2])]
show(interL2)
interL3=[x for x in L[0] if (x in L[1] and x in L[2] and x in L[3])]
show(interL2)

But, as the number of list (here 4), I would like to know if there is a possibility to define an operator and like and(L[i],i,0, 4)3)