I'm trying to compare a
and b
from \f{a}
and \g{b}
. It could be done by redefining \f
and \g
so that they expand to their argument, then comparing the arguments and finally resetting \f
and \g
's values. But that seems really ugly. Is there a better way to do that? Something like \skip\f{x}
→ {x}
?
Thank you in advance for your answers.
I apparently failed at minimizing my problem so here is the whole thing:
\ExplSyntaxOn
\DeclareExpandableDocumentCommand \eatstart { m m } { \eat_loop:NN #1 #2 }
\DeclareExpandableDocumentCommand \eatstop { m } {}
\cs_new:Npn \eat_loop:NN #1 #2
{
\token_if_eq_meaning:NNTF { #2 } { \eatstop }
{
#2
}
{
\eat_loop_not_stop:NN { #1 } { #2 }
}
}
\cs_new:Npn \eat_loop_not_stop:NN #1 #2
{
\token_if_eq_meaning:NNTF { #2 } { #1 }
{
\eat_loop:NN { #1 }
}
{
\token_if_expandable:NTF { #2 }
{
\expandafter\eat_loop:NN\expandafter#1#2
}
{
#2
}
}
}
\ExplSyntaxOff
\begin{document}
\newcommand{\plop}{o}
\newcommand{\plip}{i}
[] = [\eatstart{\plop}\plop\eatstop{\plip}\plop\eatstop{\plop}]
\end{document}
The idea is that after a \starteat\thing
, all the \thing
s are removed until a \eatstop\thing
or a character is reached. My problem is that at the moment it stops at any \eatstop
and I don't know how to make it stop only after a \eatstop\thing
.
\newcommand{\gobble}[1]{}
.