[texhax] A useful macro?

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Sun Apr 23 18:51:18 CEST 2006


Is this any use, Michael ?

         \def \seq #1{\innerseq #1,\sentinel}

         \def \innerseq #1,#2\sentinel%
             {%
              #1%
              \ifx \sentinel #2\sentinel
              \else
                 ,\,\innerseq #2\sentinel
              \fi
             }

         \long \def \test #1{{\let \, = \relax \xdef \result {\seq {#1}}}{\tt \meaning \result}\par}

         \test {x,y,z}
         \test {x_1,x_2,\ldots,x_n}
         \test {x_1,x_2,x_3,\ldots}

         \end

Philip Taylor
--------
Michael Barr wrote:
> Could someone design a macro, say call it \seq, such that any comma inside 
> the parameter of \seq would expand to ,\, .  So that \seq{x,y,z} would 
> give x,\,y,\,z, \seq{x_1,x_2,\ldots,x_n} would give 
> x_1,\,x_2,\,\ldots,\,x_n , and \seq{x_1,x_2,x_3,\ldots} would give 
> x_1,\,x_2,\,x_3,\,\ldots .  You could try giving it mathcode 8000 and 
> defining it inside math mode to give ,\,  but there is no way to just have 
> an ordinary comma then.
> 
> Michael Barr


More information about the texhax mailing list