Newcommand to Work for Each Digit in a Parameter

It's very easy with xparse: we split the list “at nothing”.

\documentclass{article}
\usepackage{yhmath}
\usepackage{xparse}

\NewDocumentCommand{\myarc}{>{\SplitList{}}m}{%
  \ProcessList{#1}{\wideparen}%
}

\begin{document}

$13\myarc{682}75$

\end{document}

The process is easy: each digit is fed to \wideparen, so that \myarc{123} becomes \wideparen{1}\wideparen{2}\wideparen{3}.

enter image description here

If you want to avoid overlapping, add a small space:

\documentclass{article}
\usepackage{yhmath}
\usepackage{xparse}

\NewDocumentCommand{\myarc}{>{\SplitList{}}m}{%
  \ProcessList{#1}{\widerparen}%
}
\NewDocumentCommand{\widerparen}{m}{\mskip.3mu\wideparen{#1}\mskip.3mu}

\begin{document}

$13\myarc{682}75$

\end{document}

This is the same as before, but using \widerparen, that adds a bit of space on the left and right of the digit.

enter image description here

If you want to just put the arc over the first and the last digit in the argument, the code is a bit more complex. I've left \myarc* to print an arc over each digit.

\documentclass{article}
\usepackage{yhmath}
\usepackage{xparse}

\NewDocumentCommand{\widerparen}{m}{\mskip.3mu\wideparen{#1}\mskip.3mu}

\ExplSyntaxOn
\NewDocumentCommand{\myarc}{sm}
 {
  \IfBooleanTF{#1}
   { \enas_arc_all:n { #2 } } % the call is \myarc*{123}
   { \enas_arc_fl:n { #2 } }  % the call is \myarc{123}
 }

\seq_new:N \l_enas_arc_input_seq

\cs_new_protected:Nn \enas_arc_all:n
 {% this is essentially the same as the easy version
  % split the input one digit at a time
  \seq_set_split:Nnn \l_enas_arc_input_seq { } { #1 }
  % apply \widerparen to each digit
  \seq_map_inline:Nn \l_enas_arc_input_seq
   {
    \widerparen{##1}
   }
 }

\cs_new_protected:Nn \enas_arc_fl:n
 {% we only want the arc on the first and last digit
  % split the input one digit at a time
  \seq_set_split:Nnn \l_enas_arc_input_seq { } { #1 }
  % get the first item and store it
  \seq_pop_left:NN \l_enas_arc_input_seq \l_enas_arc_digit_tl
  % apply \wideparen to it
  \wideparen { \l_enas_arc_digit_tl }
  \seq_if_empty:NF \l_enas_arc_input_seq
   {% there are other digits, get the last one
    \seq_pop_right:NN \l_enas_arc_input_seq \l_enas_arc_digit_tl
    \seq_if_empty:NTF \l_enas_arc_input_seq
     {% they were only two, add some space
      \mskip .6mu
     }
     {% there are digits in between, print them
      \seq_use:Nn \l_enas_arc_input_seq {}
     }
    % print the last digit
    \wideparen { \l_enas_arc_digit_tl }
   }
 }
\ExplSyntaxOff

\begin{document}

$13\myarc{6}8275$

$13\myarc{68}275$

$13\myarc{682}75$

$13\myarc*{682}75$

\end{document}

enter image description here


Here, I set up an iteration, taking a token at a time from the argument and applying the \wideparen to it.

\documentclass{article}
\usepackage{yhmath}

%underline
\newcommand{\myarc}[1]{\myarchelp#1\relax}
\def\myarchelp#1#2\relax{\wideparen{#1}\ifx\relax#2\relax\else\myarchelp#2\relax\fi}

\begin{document}

$13\myarc{682}75$

\end{document}

enter image description here

The OP asks in a comment if the action can be limited to the first and last characters of the argument. Something like this seems to work

\documentclass{article}
\usepackage{yhmath}
\newcommand{\myarc}[1]{\myarcaux#1\relax}
\def\myarcaux#1#2\relax{\wideparen{#1}\ifx\relax#2\relax\else%
  \myarchelp#2\relax\relax\fi}
\def\myarchelp#1#2#3\relax{\ifx\relax#2\wideparen{#1}\else#1\fi\ifx\relax#2\relax\else%
  \myarchelp#2#3\relax\fi}

\begin{document}

$13\myarc{682}75$

$13\myarc{645682}75$

$13\myarc{62}75$

$13\myarc{6}75$

\end{document}

enter image description here