Reputation: 1776
This program should've written triples of indices that have a sum less or equal to 7:
for ((1..7) X (1..7)) X (1..7) {
.say if [+] $_ <= 7;
}
I thought it would only loop over the top level of the list (and the code would have an error in the loop body then, but it's not the point), but it just loops over individual numbers, which is frustrating :( Is there a neat trick to avoid it? And BTW, is there a way to make an n-ary direct product?
Upvotes: 4
Views: 192
Reputation: 26910
the easiest way to to name the reference
for (1..7) X (1..7) -> $a, $b { }
Upvotes: 4