[texhax] Composing two commands one inside another
Philip TAYLOR
P.Taylor at Rhul.Ac.Uk
Wed Aug 11 17:03:55 CEST 2004
Rodolfo Medina wrote:
> Hi, all.
>
> In plain TeX, I want to compose to commands together, one inside another.
> I say, e.g.,
> \edef\a#1,#2{#1}
That will simply void #2
> and
> \edef\b#1{#1,dog};
> then I want to define \c#1,#2 so that the value of \a is collected from \b:
> I tried with
> \edef\c#1,#2{\b{\a#1,#2}}, but it didn't work.
>
> Please anyone who can help?
> (Sorry for my ignorance!)
I'm sure you're not ignorant, but your explanation is distincly unclear!
However, let's work backwards :
> so that \c{cat,mouse} should give the result 'cat,dog'.
i.e.,
\def \c #1, #2{#1,<something>}
where we don't yet know how <something> becomes instantiated to "dog".
Can you explain this part ?
For what it's worth (and not knowing what exactly you're setting out
to achieve) you /may/ need to look at \expandafter : in your example
above :
> \edef\c#1,#2{\b{\a#1,#2}}, but it didn't work.
there is every chance that you need to force a to be expanded before b,
in which case you would need something like :
\edef \c #1,#2{ \expandafter \expandafter \expandafter \b \expandafter {\a #1,#2}}
Philip Taylor
More information about the texhax
mailing list