I'm trying to have a command take in a comma separated list early in a document, and then later on test a given comma separated list to see if it contains (exactly) the same elements. Thus;
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\newcommand{\activetags}{yellow, blue, red, green}
\newif\ifis@Strict
\is@Stricttrue
\newcommand{\strictTest}[1]
{
\renewcommand*{\do}[1]
{
\in@{##1}{\activetags}
\ifin@{}% If the element is in the second string do nothing
\else
\is@Strictfalse% If you find a non fitting string, mark strict as false.
\fi
}
}
\newcommand{\filter}[1]{
\strictTest{#1}{\activetags}% Check one being subset of the other
\docsvlist{#1}
\strictTest{\activetags}{#1}% Check other being subset of the one
\docsvlist{\activetags}
\ifis@Strict{The elements match!}\else{The elements don't match}\fi
\is@Stricttrue
}
\begin{document}
\filter{yellow, blue, red, green}% This should show "The elements match!"
\filter{yellow, blue, red}% This should show "The elements don't match"
\filter{yellow, blue, red, green, purple}% This should show "The elements don't match"
\ifis@Strict{It works}\else{It failed}\fi% This should show "It works"
\end{document}
I can't seem to find any info on the syntax on \in@
anywhere. As I understand it, it takes 2 arguments and tests one of them to see if it is contained as a substring in the other. This seems to be usable for what I need, but I can't seem to get macros to expand inside it.
The macro seems to work if I hardwire the \activetags
command, but I can't seem to get \expandafter
to work correctly, nor any of the \edef
or \let
commands that I know of that expand the token early...
I'm probably just missing something silly, but It's been a couple hours of trying now...
Thanks