This question is similar to this one but not exactly the same.
The following "not doing what I need" MWE comes from this answer.
I have not found how to make it evoluate such as to iterate over non overlaping couples.
IMPORTANT ! The number of arguments separated by pipes will allways be odd.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewExpandableDocumentCommand \multiapplycouple { m +m }
{ \mbc_multiapply_pair:Nn #1 {#2} }
\cs_new:Npn \mbc_multiapply_pair:Nn #1 #2
{
__mbc_multiapply_pair:nNw { 0 } #1
| \prg_do_nothing: #2 | \q_recursion_tail | \q_recursion_stop
}
\cs_new:Npn __mbc_multiapply_pair:nNw #1 #2 | #3 |
{ __mbc_multiapply_pair:nNww {#1} #2 | #3 | \prg_do_nothing: }
\cs_new:Npn __mbc_multiapply_pair:nNww #1 #2 | #3 | #4 |
{ __mbc_multiapply_pair:oofN {#3} {#4} { \int_eval:n {#1+1} } #2 }
\cs_new:Npn __mbc_multiapply_pair:nnnN #1 #2 #3 #4
{
\quark_if_recursion_tail_stop:n {#2}
\quark_if_recursion_tail_stop:n {#1}
\exp_not:e { \exp_not:N #4 {#3} { \tl_trim_spaces:n {#1} } { \tl_trim_spaces:n {#2} } }
__mbc_multiapply_pair:nNww {#3} #4 | \prg_do_nothing: #2 | \prg_do_nothing:
}
\cs_generate_variant:Nn __mbc_multiapply_pair:nnnN { oof }
\ExplSyntaxOff
\newcommand\deco{?}
\begin{document}
\multiapplycouple\deco{ 1 } % [[1]]
\multiapplycouple\deco{ 1 | 2 | 3 } % [[1]] (2-3)
\multiapplycouple\deco{ 1 | 2 | 3 | 4 | 5 } % [[1]] (2-3) (4-5)
\end{document}
