
Warum ist das ifnum
immer wahr? \@tempcntb
ist 5, sollte es nicht stattdessen \tmp
für das letzte Argument gedruckt werden? Außerdem verstehe ich nicht, was das m@ne
tut, denn dies erhöht den Zähler sicherlich nicht um 1 (es geht von außerhalb nach innerhalb der verschachtelten \tmp
's).
\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}