Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A set implementation in LaTeX?

Tags:

list

set

latex

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) ?

like image 812
Giovanni Funchal Avatar asked Nov 15 '22 13:11

Giovanni Funchal


1 Answers

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%
}%
like image 55
Giovanni Funchal Avatar answered Nov 29 '22 06:11

Giovanni Funchal