Comparing each possible pair of elements in a list, once?

Viewed 13

How can I go through a list, such that each pair of element is considered once?

For example:

myList = ["fruit", "bread", "meat", "cheese"]

I would need to compare:

fruit - bread
fruit - meat
fruit - cheese
bread - meat
bread - cheese
meat - cheese

Is there an efficient way to achieve this?

0 Answers
Related