[comp.text.tex] problem with macros

eao@shape.mps.ohio-state.edu (Ed Overman) (08/30/90)

Help!!!  I am doing some strange things and have reached a point where I am
stumped.  To briefly summarize my problem I have written a sorting macro
which sorts a set of integers into increasing order.  (The integers are the
parameter text of the macro and are separated by commas.)  It works fine as
long as the integers are given either explicitly or by simple macros.
However if the macros are complicated it doesn't work.  A MUCH simpler
example which illustrates my difficulty is given below where I am trying to
"build up" the macro \A one piece at a time:
    \def\aa{1} \def\bb{2} \def\cc{3}
    \edef\A{} \edef\A{\A\aa} \edef\A{\A\bb} \edef\A{\A\cc}  .
\A goes from blank to 1 to 12 to 123 --- and this works fine.  However if
\dd is added to the list where
    \def\dd{\let\B=\aa\B}
then it bombs.  That is,
    \def\aa{1} \def\bb{2} \def\cc{3} \def\dd{\let\B=\aa \B}
    \edef\A{} \edef\A{\A\} \edef\A{\A\bb} \edef\A{\A\cc} \edef\A{\A\dd}
bombs.  (In reality \dd is MUCH more complicated but it does indeed include
a \let .)

I have RTFM (although not necessarily UTFM {U=understood}) and I do not see
what I have done wrong.  Perhaps someone could tell me.

HOWEVER WHAT I REALLY WANT TO DO is to be able to build up something like \A
by the method shown.  Is there any way that I can take a much more
complicated macro than \dd (which simply expands to an integer), expand it
to the integer, and put the integer into SOMETHING (a control sequence or a
macro or a count register or a token register) so that I can then use \edef
to add it to \A ?  I have tried many things but none of them has worked.