Reputation: 7439
How to write two nested loops in CoffeeScript: where the inner loop is using the outer loop current index as its initial value?
ie
for (int i = 0; i < array.size(); i++) {
for (int j = i; j < array.size; j++) {
...
}
}
Thanks!
Upvotes: 1
Views: 51
Reputation: 36
Most succinct way I could think of:
for item, i in array
for item, j in array when j >= i
Upvotes: 2
Reputation: 193261
Try something like this, maybe:
for i in array
for j in [i ... array.size()]
console.log i, j
Upvotes: 0