You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2005 Pearls / philip-taylor / bachotex2005-philip-taylor-pearl1.tex


TeX document icon bachotex2005-philip-taylor-pearl1.tex — TeX document, 1 KB

File contents

%%% Philip Taylor: The Iterator
% In general-purpose \TeX{} programming (as opposed to typesetting
% with \TeX), one of the most commonly needed techniques is the
% ability to iterate over an unknown number of parameters.  If the
% number is known to be nine or less in advance, \TeX{} is quite
% capable of doing all that is necessary with only a little help
% from the user.  However, if the number of parameters may
% exceed ten, then a rather more devious approach will be required.

\def \forall #1#2\do #3{#3 {#1}\ifx \relax #2\relax
        \else \forall #2\do {#3}\fi}

% example

\def \debug #1{\message {[#1]}#1 }
\forall 1234abcd{ef}{ghi}etc...\do {\debug}

Document Actions