Consider the following straightforward implementation of a list in latex:
\newcommand{\add@to@list}[2]{%
\ifx#2\@empty%
\xdef#2{#1}%
\else%
\xdef#2{#2,#1}%
\fi%
}%
I wonder if there is a simple way to implement a set (list with no repeated elements) ?
This seems to work:
\newcommand{\add@to@set}[2]{%
\ifx#2\@empty%
\xdef#2{#1}%
\else%
\@expandtwoargs\@removeelement{#1}{#2}{#2}%
\xdef#2{#2,#1}%
\fi%
}%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With