Updated solution using the features of etoolbox which has essentially implemented the “\MapCommand” and named it \forcsvlist
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\newcommand{\DeclareMyOperator}[1]{%
\expandafter\DeclareMathOperator\csname #1\endcsname{#1}
}
\newcommand{\DeclareMathOperators}{\forcsvlist{\DeclareMyOperator}}
\DeclareMathOperators{Rep,Tet,Maps,Diff}
\begin{document}
Operators: $\Rep, \Tet, \Maps, \Diff$
\end{document}
“For historical reasons”, I leave my original answer bellow.
Combining the previous answers from Grigory and Andrew I was able to come up with the following somewhat cleaner implementation which also exposes a nice user interface.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\ops@declare#1{%
\expandafter\DeclareMathOperator\csname #1\endcsname{#1}
}
\def\ops@scan#1,{%
\ifx#1\relax
\let\ops@next\relax
\else
\ops@declare{#1}\let\ops@next\ops@scan
\fi\ops@next
}
\newcommand{\DeclareMathOperators}[1]{\ops@scan#1,\relax,}
\makeatother
\DeclareMathOperators{Rep,Tet,Maps,Diff}
\begin{document}
Operators: $\Rep, \Tet, \Maps, \Diff$
\end{document}
\MapCommand{\Cmd}{a,b,c}which expands to\Cmd{a}\Cmd{b}\Cmd{c}. – Juan A. Navarro Jul 27 '10 at 15:33\MapCommand(which is what I've been trying to do to no avail). I was wondering if you could give a hint as to how to do it, or even a full implementation? Of course, I know the value of learning to do something myself, but in this case I'm sufficiently exasperated to ask for a solution that I will then try to understand. Thanks! – Zev Chonoles Aug 30 '11 at 07:23etoolboxpackage and its command\forcsvlistwhich is basically the "map command" that you are looking for. Have a look at the documentation of that package. – Juan A. Navarro Aug 30 '11 at 09:13