I have a collection of elements. I can relate each element with the other like this:
> k=0; for (i=0;i<5;i++) {for (j=i+1;j<5;j++) { console.log(k++, ': ', i, '-', j) } }
0 :  0 - 1
1 :  0 - 2
2 :  0 - 3
3 :  0 - 4
4 :  1 - 2
5 :  1 - 3
6 :  1 - 4
7 :  2 - 3
8 :  2 - 4
9 :  3 - 4
My question is:
Given two element indexes, how can I get the position in the relations list?
For example, for i=1 and j=2 I want to obtain 4.
The solution should work for collections of any size.
 
     
    