It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit it or put a new question.
So, what I am trying to do is the following. I have the following set of values: A=[a1,a2....a100]. Now, suppose I want to loop trough them to check something for each possible pair of these values but without repetition and avoiding to check a value against itself.
It means that we start with a1 and check it against a2, then a3, then a4, until checking it against a100. Next, we start with a2, but we do not check it against a1 because that was already checked. We go directly to check a2 against a3, then a4, until a100. Next, we start with a3 and check it directly agains a4, then a5, and so on. The idea is that there will be 100+99+98+97...+1 checks, instead of 100^2 checks.
A naïve way of doing that would be to use two loops, one nested in the other, both going trough all the values of A. However, after the main parent loop completes each iteration, it stores the current iterated value in a list. So, when the child nested loop starts it checks if its currently iterated value is already on that list - if it is, the nested loop breaks.
However, it is very likely that this is not a very efficient way of doing that, since one would have to create a list, add to the list every iteration of the first loop and search the list every iteration of the second loop. Considering that I will be dealing with enormous amount of values in A, not only 100, that is real concern.