D
Derek Cannon
I'm new to Ruby and I can't think of how to do this! I would like each
element in an array to compare itself with all its proceeding elements.
For example:
In an array of 10 elements,
a[0] will be compared to a[1] ... a[9]
a[1] will be compared to a[2] ... a[9]
...
a[9] will not be compared, as there is nothing larger than it.
For those who don't understand, I think the Java/C++ equivalent would
be:
for(int i=0; i < array.length; i++) {
for(int j=i+1; j < array.length; j++) {
// Compare array with array[j]
}
}
element in an array to compare itself with all its proceeding elements.
For example:
In an array of 10 elements,
a[0] will be compared to a[1] ... a[9]
a[1] will be compared to a[2] ... a[9]
...
a[9] will not be compared, as there is nothing larger than it.
For those who don't understand, I think the Java/C++ equivalent would
be:
for(int i=0; i < array.length; i++) {
for(int j=i+1; j < array.length; j++) {
// Compare array with array[j]
}
}