in reply to What Happened...(perils of porting from c)
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.
Also note the lack of pointer arithmetic to mess up on. :-)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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re (tilly) 1 (perl): What Happened...(perils of porting from c)
by Madams (Pilgrim) on Jan 06, 2001 at 05:20 UTC | |
Re: ancient masterpiece
by Roy Johnson (Monsignor) on Jun 02, 2005 at 22:27 UTC |
In Section
Seekers of Perl Wisdom