Skip to content

Instantly share code, notes, and snippets.

@TobiasBouma
Created May 8, 2014 09:21
Show Gist options
  • Save TobiasBouma/e68a7a83e6a199daf59a to your computer and use it in GitHub Desktop.
Save TobiasBouma/e68a7a83e6a199daf59a to your computer and use it in GitHub Desktop.
\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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment