in reply to Read array of arrays in reverse order
First a typo in your example:
(Step 2) Find the element <tt>$my_arr[k][3]...Now, in order to make it programmable, it is better to not have variable names that are changing like k, l, m, n, ... Since you want to have the entire list, in any case, we can call them k[0], k1, ..., so your algorithm now becomes:
Step 0) k[0] = $arr[4][3] Step 1) k[1] = $arr[3][k[0]] Step 2) k[2] = $arr[2][k[1]] Step 3) k[3] = $arr[1][k[2]]
Now k is the answer. Since step 0, is different, it could be done out of the loop, while the rest can be easily made into a loop. Perhaps this is enough help?
|
|---|