Re: Arbitrarily Many Nested Loops



[A complimentary Cc of this posting was sent to
A. Sinan Unur
<1usa@xxxxxxxxxxxxxxxxxxx>], who wrote in article <Xns9795CB63AB7DAasu1cornelledu@xxxxxxxxx>:
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

I'm afraid the problem is on your side. The explanation-by-code looks
absolutely clear to me.

Looks like there is a multi-dimensional array of unknown-in-advance
dimension. It is known that it is "rectangular"; the sizes are stored
in another vector (one size per dimension).

One wants a CONVENIENT way to run through the elements of this array.

One hint to OP: since you do not know the dimension at compile
time, you cannot be sure that the index of 1st,2nd,3rd etc
dimensions is $k, $l, $m etc. So the only solution is to have the
running index to be an array too: $I[0], $I[1], $I[3] etc.

This more or less immediately suggests a possible solution...

Hope this helps,
Ilya

P.S. One could also use Math::Pari's forvec(); might be a little bit
heavy-weight solution, but maybe then you will find some use for
other functions in Math::Pari too. ;-)
.



Relevant Pages

  • Re: Array declaration syntax question
    ... barry wrote: ... > dimension I won't know the size of until runtime, ... I have tried the following declaration ... It's a multi-dimensional array, so the type is: ...
    (comp.lang.java.programmer)
  • Re: Arbitrarily Many Nested Loops
    ... Sinan Unur ... Neither the code snippet above nor your verbal description makes any ... in another vector (one size per dimension). ... distribution where the success probability differs between trials. ...
    (comp.lang.perl.misc)