my $N = 4; my $depth = 3; my $i2 = nested_for([ [ 0..$N ], ( sub { [$_+1..$N] } ) x ($depth-1), ]); print "@args\n" while @args = $i2->();