嵌套列表中的索引:检索嵌套子列表的元素

嵌套列表中的索引:检索嵌套子列表的元素

我需要创建一个层图,其中每个下一层都与前一层紧密相连。因此,我为每一层节点标签创建了一个嵌套列表:

\def\noderows{{{"M","P","H"},{"L","E","Z"},{"max","mean","all","MIL"},{"M","Q"},{"T","A","E","C","S","SI"},{"mi","mo","se"},{"EN","XGB","MIL"}}}

并尝试迭代将每一层的(现有)节点连接到下一层:

% Iterate over all but the last row
\foreach \rowindex in {0,...,\length} {
  \ifnum\rowindex<\length
    % This is not the last row, so we can do something with it
    \pgfmathsetmacro{\nextrowindex}{int(\rowindex+1)}
    \pgfmathsetmacro{\row}{\noderows[\rowindex]}
    \pgfmathsetmacro{\nextrow}{\noderows[\nextrowindex]}
    \typeout{Row \rowindex: \row}
    \typeout{Next row \nextrowindex: \nextrow}
       \foreach \src in \row {
            \foreach \dst [count=\cn] in \nextrow{
                    \typeout{connection: \src -- \dst}
                       % \edef\connect{\noexpand\typeout{connection: \src{} -- \dst}}%
                       %                     \connect
                    % \draw[->] (\src) -- (\dst);
            }
        }
  \else
    % This is the last row, so we skip it
    \typeout{Skipping last row}
  \fi
}

但是行并没有被分成元素:

Row 0: {{M}{P}{H}}
Next row 1: {{L}{E}{Z}}
connection: {M}{P}{H}-- {L}{E}{Z}
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Row 1: {{L}{E}{Z}}
Next row 2: {{max}{mean}{all}{MIL}}
connection: {L}{E}{Z}-- {max}{mean}{all}{MIL}
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Row 2: {{max}{mean}{all}{MIL}}
Next row 3: {{M}{Q}}
connection: {max}{mean}{all}{MIL}-- {M}{Q}
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Row 3: {{M}{Q}}
Next row 4: {{T}{A}{E}{C}{S}{SI}}
connection: {M}{Q}-- {T}{A}{E}{C}{S}{SI}
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Row 4: {{T}{A}{E}{C}{S}{SI}}
Next row 5: {{mi}{mo}{se}}
connection: {T}{A}{E}{C}{S}{SI}-- {mi}{mo}{se}
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Row 5: {{mi}{mo}{se}}
Next row 6: {{EN}{XGB}{MIL}}
connection: {mi}{mo}{se}-- {EN}{XGB}{MIL}

我怎样才能让它迭代这里的嵌套元素?

相关内容