Re: Arbitrarily Many Nested Loops



"Jacob JKW" <jacobcdf@xxxxxxxxx> wrote in news:1143679874.629703.156690
@u72g2000cwu.googlegroups.com:

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?

You need to work a little on explaining the problem and algorithm.
Neither the code snippet above nor your verbal description makes any
sense to me, but I am curious to understand why such a monstrosity is
needed.

Sinan

--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

.



Relevant Pages

  • Re: accessing chars in a string
    ... Posting code showing a attempt at solving the problem ... questions with Perl code). ... prefer explaining the reasoning behind something, ... posting often helps to clarify the nature of the problem. ...
    (perl.beginners)
  • Re: array search speeds?
    ... > impact on the algorithm (Perl programms often use hashes because they ... seem to require more knowledge of C/C++ which I don't have. ...
    (comp.lang.perl.misc)
  • Re: which language should i use?
    ... > It may do some simple hashing and string matching in the first stage. ... > I'm thinking of using perl for this, ... your algorithm, processes it 100 times, and times the ... How fast the production code parses, ...
    (comp.programming)
  • Re: Arbitrarily Many Nested Loops
    ... decide at run time to have how nested levels to go (probably be on the ... Some redundency left in for clarity and ...
    (comp.lang.perl.misc)
  • Re: Arbitrarily Many Nested Loops
    ... decide at run time to have how nested levels to go (probably be on the ... Some redundency left in for clarity and ...
    (comp.lang.perl.misc)