Permutation Operator

In order to process multiple items in the same way, I'd suggest processing the content as a list (separated by commas, say):

enter image description here

\documentclass{article}

\usepackage{etoolbox}

\newcommand{\permutation}[1]{
  \gdef\itemdelim{\gdef\itemdelim{\mathchoice{\ }{\ }{\,}{\,}}}
  (\dopermutation{#1})}
% https://tex.stackexchange.com/a/89187/5764
\newcommand{\dopermutation}[1]{
  \renewcommand*{\do}[1]{\itemdelim##1}
  \docsvlist{#1}}

\begin{document}

\begin{tabular}{l}
  $(1\ 3\ 2\ 4)$ \\
  $\permutation{1,3,2,4}$
\end{tabular}

\begin{tabular}{l}
  $S_{(1\,3\,2\,4)}$ \\
  $S_{\permutation{1,3,2,4}}$
\end{tabular}

\end{document}

You can update the spacing depending on the math mode you're in.

References:

  • How to iterate over a comma separated list?
  • What is \mathchoice?
  • Cunning (La)TeX tricks

Here the separators are spaces; if you prefer a syntax like \perm{1,2,3,4} (but output just blank space), change { ~ } in the code below with { , }.

\documentclass{article}
\usepackage{xparse}

\newcommand{\permsep}{%
  \mathchoice
    {\mskip\thickmuskip}% display
    {\mskip\medmuskip}% text
    {\mskip1.5mu}% first level sub/superscript
    {\mskip1.5mu}% second level or deeper
}

\ExplSyntaxOn
\NewDocumentCommand{\perm}{m}
 {
  \seq_set_split:Nnn \l_tmpa_seq { ~ } { #1 }
  ( \seq_use:Nn \l_tmpa_seq { \permsep } )
 }
\ExplSyntaxOff

\begin{document}

$\perm{1 2 3 4}\in S_{\perm{1 2 3 4}}$
\[
\perm{1 2 3 4}
\]

\end{document}

With \mathchoice you can decide what spacing you want for each math style.

enter image description here


\documentclass{scrartcl}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand \perm { r() } { \percy_perm:n {#1} }
\cs_new_protected:Npn \percy_perm:n #1
 {
  (
   \seq_set_split:Nnn \l_tmpa_seq { ~ } { #1 }
   \mathchoice
    { \seq_use:Nn \l_tmpa_seq { \  } }
    { \seq_use:Nn \l_tmpa_seq { \  } }
    { \seq_use:Nn \l_tmpa_seq { \, } }
    { \seq_use:Nn \l_tmpa_seq { \, } }
  )
 }
\ExplSyntaxOff

\begin{document}
$\perm(1 2 3 4)$ and $S_{\perm(1 2 3 4)}$
\end{document}