This works for arbitrarily long lists (at least two elements, of course):
\documentclass{article}
\usepackage{xparse}
\newcommand{\myMacro}[3]{[#1,#2,#3]} % define suitably
\ExplSyntaxOn
\NewDocumentCommand{\otherMacro}{mmm}{ \maps_splitargs:nnn {#1}{#2}{#3} }
\seq_new:N \l_maps_first_seq
\seq_new:N \l_maps_second_seq
\seq_new:N \l_maps_third_seq
\cs_new:Npn \maps_splitargs:nnn #1 #2 #3
{
\seq_set_split:Nnn \l_maps_first_seq {,} { #1 }
\seq_set_split:Nnn \l_maps_second_seq {,} { #2 }
\seq_set_split:Nnn \l_maps_third_seq {,} { #3 }
\prg_stepwise_inline:nnnn { 0 } { 1 } { \seq_length:N \l_maps_first_seq - 1 }
{
\tl_set:Nx \l_tmpa_tl
{
{ \seq_item:Nn \l_maps_first_seq { ##1 } }
{ \seq_item:Nn \l_maps_second_seq { ##1 } }
{ \seq_item:Nn \l_maps_third_seq { ##1 } }
}
\exp_after:wN \myMacro \l_tmpa_tl
\int_compare:nTF { ##1 = 0 }
{ \mapsto ( }
{ \int_compare:nTF { ##1 = \seq_length:N \l_maps_first_seq - 1 } { ) } { , } }
}
}
\ExplSyntaxOff
\begin{document}
$\otherMacro {a1,a2}{b1,b2}{c1,c2}$
$\otherMacro {a1,a2,a3}{b1,b2,b3}{c1,c2,c3}$
$\otherMacro {a1,a2,a3,a4}{b1,b2,b3,b4}{c1,c2,c3,c4}$
$\otherMacro {a1,a2,a3,a4,a5}{b1,b2,b3,b4,b5}{c1,c2,c3,c4,c5}$
\end{document}
Important change
Due to the changes made to expl3
in Summer 2012, the code above should be replaced by the following:
\documentclass{article}
\usepackage{xparse}
\newcommand{\myMacro}[3]{[#1,#2,#3]} % define suitably
\ExplSyntaxOn
\NewDocumentCommand{\otherMacro}{mmm}{ \maps_splitargs:nnn {#1}{#2}{#3} }
\seq_new:N \l_maps_first_seq
\seq_new:N \l_maps_second_seq
\seq_new:N \l_maps_third_seq
\cs_new:Npn \maps_splitargs:nnn #1 #2 #3
{
\seq_set_split:Nnn \l_maps_first_seq {,} { #1 }
\seq_set_split:Nnn \l_maps_second_seq {,} { #2 }
\seq_set_split:Nnn \l_maps_third_seq {,} { #3 }
\int_step_inline:nnnn { 1 } { 1 } { \seq_count:N \l_maps_first_seq }
{
\tl_set:Nx \l_tmpa_tl
{
{ \seq_item:Nn \l_maps_first_seq { ##1 } }
{ \seq_item:Nn \l_maps_second_seq { ##1 } }
{ \seq_item:Nn \l_maps_third_seq { ##1 } }
}
\exp_after:wN \myMacro \l_tmpa_tl
\int_compare:nTF { ##1 = 1 }
{ \mapsto ( }
{ \int_compare:nTF { ##1 = \seq_count:N \l_maps_first_seq } { ) } { , } }
}
}
\ExplSyntaxOff
\begin{document}
$\otherMacro {a1,a2}{b1,b2}{c1,c2}$
$\otherMacro {a1,a2,a3}{b1,b2,b3}{c1,c2,c3}$
$\otherMacro {a1,a2,a3,a4}{b1,b2,b3,b4}{c1,c2,c3,c4}$
$\otherMacro {a1,a2,a3,a4,a5}{b1,b2,b3,b4,b5}{c1,c2,c3,c4,c5}$
\end{document}