http://qs1969.pair.com?node_id=463041


in reply to Re (tilly) 1 (perl): What Happened...(perils of porting from c)
in thread What Happened...(perils of porting from c)

That was beautiful. I'm writing primarily so more people can see it. I also did a little rewrite that isn't an improvement, per se, but is AWTDI and may help people understand what's going on. (Iterating instead of recursing.)
sub ret_iter { my $sub = shift; while (my $range = pop) { my $inner = $sub; $sub = sub { $inner->(@_, $_) for @$range }; } return $sub; }
I made it so it changes elements on the right fastest, like a counter.

Caution: Contents may have been coded under pressure.