Can someone show me how to make the following macro (\applycouple) expandable using expl3, if it is possible?
This question is similar to this post of mine.
\documentclass{article}
\newcounter{applycoupleposition}
\newcommand\applycouplemacro{}
% #1 : macro to apply
% #2 : multi-args
\newcommand\applycouple[2]{
\setcounter{applycoupleposition}{0}
\renewcommand\applycouplemacro{#1}
\applycouplerecu#2|\nil
\renewcommand\applycouplemacro{}
}
\def\applycouplerecu#1|#2|#3\nil{
\stepcounter{applycoupleposition}
\applycouplemacro{#1}{#2}
\if\relax\detokenize{#3}\relax\else
\applycouplerecu#2|#3\nil
\fi
}
\newcommand\decocouple[2]{%
(#1)[#2]%
}
\newcommand\multiapplycouple[1]{%
\applycouple{\decocouple}{#1}
}
\begin{document}
\multiapplycouple{1|12|123|1234}
\end{document}

\quark_if_recursion_tail_stop:n {#1}. I have seen that by using\quark_if_recursion_tail_stop_do:Nn {#1} {--KO--}instead. – projetmbc Aug 23 '20 at 13:31\quark_if_recursion_tail_stop_do:nn(note the:nnvs.:Nn): at that point in the code you don't know that#1is a single token (and often it is not!), so you can't use anNargument there. – Phelype Oleinik Aug 23 '20 at 13:54