[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] nested loop of arbitary number of elements in a hash of h
From: |
arnold |
Subject: |
Re: [bug-gawk] nested loop of arbitary number of elements in a hash of hash |
Date: |
Tue, 09 Apr 2019 07:44:06 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
I'm not sure what you're asking. But I think what you want is
not a nested loop, but rather a traversal of the full multidimensional
array. There is a an example of doing this in the manual, using
isarray() and recursion. See there.
Arnold
Peng Yu <address@hidden> wrote:
> Hi,
>
> "input" is a hash of hash. The following example is a nested loop
> assuming there are only "1" "2" and "3" in the first level of the
> hash. If there are an arbitrary number of elements in the first level,
> what is the best way to construct a nested loop? Thanks.
>
> for(j1 in input[1]) {
> for(j2 in input[2]) {
> for(j3 in input[3]) {
> # do something
> }
> }
> }
>
> --
> Regards,
> Peng