Re: Arbitrarily Many Nested Loops



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.
.



Relevant Pages

  • SOLVED: "Text File Busy" And Other Frustrating NFS/Perl Errors
    ... Perl file on one computer, ... and I am running it on another (my server). ... The first problem I had was that when I saved my script through NFS, ... searched newsgroups on Usenet and mailing lists and general Google searches ...
    (comp.lang.perl.misc)
  • Re: finding perl info on google can be hard
    ... Please alow me to point out that I am using google to ... I am also using it to read various other newsgroups. ... the perl docs were all anyone needed to learn about perl these ... The perldocs are a standard part of the Perl distribution. ...
    (comp.lang.perl.misc)
  • Re: Structuring informational content for commercial site
    ... I like the way you've blended the articles and sales through links ... within the text - flows nicely without diminishing the authority... ... >>> concern, more than google, as google is just a means to the ... > link-menu stuff on the top, sides, or bottom of a text block. ...
    (alt.internet.search-engines)
  • Re: How to get all the files under the webdir?
    ... That would be a question about webservers, not about Perl, ... But are you, like Google, dealing with more than a dozen other sites? ... (Or, maybe, the information's owner may not want you to have ... Perl can do web robots. ...
    (perl.beginners)
  • Re: Jam Police Radar with Cold Plasma
    ... "While the concept may be foreign or, possibly, even repugnant to ... even Google advises bottom posting:" ... Google believes as "appropriate." ... you didn't even need to scroll down to the bottom of the listing ...
    (sci.electronics.basics)