Is there a simple way of performing an operation on all possible pairs of rows in a table?
For example, if I had four rows, I would want the operation to be applied to rows 1 and 2, 1 and 3, 1 and 4, 2 and 3, 2 and 4, and finally rows 3 and 4.
Is there a simple way of performing an operation on all possible pairs of rows in a table?
For example, if I had four rows, I would want the operation to be applied to rows 1 and 2, 1 and 3, 1 and 4, 2 and 3, 2 and 4, and finally rows 3 and 4.
Nested loops seem like the easiest way to me.. unless you have some special requirement?
for (i = 0; i < 3; i++) {
for (j = i + 1; j < 4; j++) {
operation(row[i], row[j]);
}
}