I am trying to iterate over the list of all basic colours:
\def\thecolors{black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow}
I want to define a command for each of them with some kind of for each loop, more or less as follows:
\foreach \x in \thecolors%
{\newcommand{\csname command\x\endcsname}
{\textcolor{\x}{Some text including the string \x.}}
I know this is more or less the way to do it with pgf/tikz, but I was wondering whether there is a way to do it only with (La)TeX primitive commands.
Thanks in advance for any answer.
PS: Do I need to explicitly define \thecolors or are LaTeX basic colours already stored in some command?
EDIT
I don't think this is a duplicate of (1) since it explicitly asks for a (La)TeX primitive method.

\loopcommand but as far as I am aware there is no TeX primitive for dealing with comma separated lists, so you would have to implement this first. Easier alternatives would be to use pgf, as you suggest, or\docsvlistfrom etoolbox package, or\clist_use:Nnfrom LaTeX3, or ... – Sep 30 '19 at 08:07\@formacro. – Skillmon Sep 30 '19 at 08:12