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}