note
tilly
Here is a native Perlish thing that basically does what
I think you really want. Note how much shorter this is
than the C version.
<code>
use strict;
nested_for(
sub {print "@_\n";},
[1..2], ['a'..'c'], ['A'..'D']
);
sub nested_for {
ret_iter(@_)->();
}
sub ret_iter {
my $fn = shift;
my $range = shift;
my $sub = sub {$fn->($_, @_) for @$range};
return @_ ? ret_iter($sub, @_) : $sub;
}
</code>
Also note the lack of pointer arithmetic to mess up on. :-)
50050
50050