Re: Arbitrarily Many Nested Loops
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 30 Mar 2006 10:42:19 GMT
Jim Gibson <jgibson@xxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
In article <1143679874.629703.156690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Jacob JKW <jacobcdf@xxxxxxxxx> wrote:
This is what I have:
-------------
#!perl
for (my $i = 0; $i<=$n_ra->[0]; $i++) {
for (my $j = 0; $j<=$n_ra->[1]; $j++) {
for (my $k = 0; $k<=$n_ra->[2]; $k++) {
$prob_ra->[$i+$j+$k] += (
$f_raa->[0]->[$i] *
$f_raa->[1]->[$j] *
$f_raa->[2]->[$k] *
);
}
}
-------------
But that's obviously messy and more imprtantly I'd like to be able to
decide at run time to have how nested levels to go (probably be on the
order of 50 or 60). I assume that there's a canonical manner in which
this should be handled (using closures I'd guess) but I can't
sufficiently summarize my issue to make it Google-able.
Any advice?
This question was asked several weeks ago, and Anno Siegel had a most
elegant solution. I googled for it but couldn't find.
I am honored, but I think Google is right. I don't remember this
particular problem from the recent past.
I have tried a couple of variants of Ilya's suggestion (using an index
array), but nothing came up to write home (to clpm) about.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: Arbitrarily Many Nested Loops
- From: Tad McClellan
- Re: Arbitrarily Many Nested Loops
- References:
- Arbitrarily Many Nested Loops
- From: Jacob JKW
- Re: Arbitrarily Many Nested Loops
- From: Jim Gibson
- Arbitrarily Many Nested Loops
- Prev by Date: Re: Arbitrarily Many Nested Loops
- Next by Date: Re: file renamer... request feedback
- Previous by thread: Re: Arbitrarily Many Nested Loops
- Next by thread: Re: Arbitrarily Many Nested Loops
- Index(es):
Relevant Pages
|