
Por que isso é ifnum
sempre verdade? \@tempcntb
é 5, não deveria imprimir \tmp
o último argumento? Além disso, não entendo o que m@ne
acontece, porque isso certamente não avança o contador em 1 (está indo de fora para dentro dos aninhados \tmp
)
\documentclass{article}
\usepackage{color}
\makeatletter
\newcommand\metafunc[1]{{
\count@\z@
Number of arguments: \the\@tempcntb \par
\@tempcnta\z@\relax
\@tempcntb=\count@
\@for\tmp:=#1\do{\advance\count@\@ne}
\ifnum\@tempcnta=\@tempcntb
\@for\tmp:=#1\do{%
\advance\@tempcnta\@ne
\textcolor[RGB]{\the\numexpr255*\@tempcnta/(\count@)\relax,
0,
\the\numexpr255-(255*\@tempcnta/(\count@))\relax}%
{\tmp(}}\relax
\@tempcnta\count@
\@for\tmp:=#1\do{%
\textcolor[RGB]{\the\numexpr255*\@tempcnta/(\count@)\relax,
0,
\the\numexpr255-(255*\@tempcnta/(\count@))\relax}%
{)}\relax
\advance\@tempcnta\m@ne
}
\else
\@for\tmp:=#1\do{\tmp}
\fi
}}
\makeatother
\begin{document}
\metafunc{Banana,Stool,Another banana,chair,peanut}
\end{document}