[texhax] Handling arrays or lists in LaTeX command arguments

Donald Arseneau asnd at triumf.ca
Fri Apr 23 19:40:47 CEST 2010


Brandon Kuczenski <brandon at 301south.net> writes:

> I'm hunting for a TeX or LaTeX macro which processes an argument as a
> [c-style] array with a (possibly arbitrary, possibly fixed) number of entries.
> 
> For instance, I imagine three hypothetical LaTeX commands:
> 
> \defarray{\arrayname}{num}{[element1,element2,element3...]}
> 
> creates an array called \arrayname with num elements.  Here I assume the
> elements are comma-separated and enclosed in brackets, but that is just for
> example.
> 
> \arraydo{\arrayname}{operation}
> 
> performs 'operation' once for each element in the array in succession.
> 
> \thearrayelement

If these are the *only* requirements, and you don't need to
look up individual elements by index, then the existing LaTeX
list handling seems sufficient:

\def\arrayname{element1,element2,element3...}

\@for\thearrayelement:=\arrayname\do{operation}




-- 
Donald Arseneau                          asnd at triumf.ca


More information about the texhax mailing list