Here I applied something like a hash-table, using name/characteristics
as a bundled pair and splitting them with a small helper macro, setting the name as a property key and the characteristics as the key value.
The iteration about all keys is done with \prop_map_inline
.
Some important notes:
- The keys must be unique -- specifying them again will just overwrite the old value.
- The order of appearance is not necessarily the same as the order of specification!
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\prop_new:N \l_felipe_prop_list
\def\helpercmd#1/#2{%
\prop_put:Nnn \l_felipe_prop_list {#1} {#2}
}
\newcommand{\fillproplist}[1]{%
\seq_set_from_clist:Nn \l_tmpa_seq {#1}
\seq_map_inline:Nn \l_tmpa_seq {%
\helpercmd ##1 % Splitting!
}
}
\newcommand{\displaynamecharacteristics}{%
\prop_map_inline:Nn \l_felipe_prop_list {%
\displaynamechar{##1}{##2}% using a specialized display macro
}
}
\ExplSyntaxOff
% Change the `\displaynamechar` macro at will: #1 -> key name, #2 -> key value
\newcommand{\displaynamechar}[2]{%
Name = #1 \hfill Characteristics: #2%
}
\begin{document}
\fillproplist{Gandalf/A, Frodo/B, Sauron The Dark Lord/C}
\displaynamecharacteristics
\end{document}
expl3
this should be easy.\loop
…\repeat
constructs, etc; Understanding a\@for
loop