cotner@ronzoni.berkeley.edu (08/29/90)
I have a macro question. I have a macro which I use like this: \mymacro input1 \mymacro input2 ... \mymacro inputn I would like to be able to say instead \mynewmacro input1 <delimiter> input2 <delimiter> ... <delimiter> inputn where <delimiter> is any character or string which doesn't appear in any of the inputs and the number of inputs is arbitrary (variable). Any help would be greatly appreciated. Carl Cotner cotner@math.berkeley.edu
marcel@cs.caltech.edu (Marcel van der Goot) (09/06/90)
In <1990Aug29.002146.24426@agate.berkeley.edu> Carl Cotner (cotner@math.berkeley.edu) asks for a way to write macros that take an arbitrary number of arguments. Here's how I usually do it (I don't remember whether this can be found somewhere in the TeX-book; the idea was described to me several years ago by Prof. R. Backhouse). I assume that the technique is pretty well-known. \def\callmymacro[#1+#2]% {\mymacro{#1}% \def\more{#2}% \ifx\more\empty{}\else\callmymacro[#2]\fi } \def\mynewmacro[#1]% {\callmymacro[#1+]% } % The separator is '+'. You can call % \mynewmacro[input1+input2+input3] % Try with, e.g., \def\mymacro#1{\immediate\write16{--- #1}} Marcel van der Goot marcel@vlsi.caltech.edu