I need to create a macro to render lists with a variable number of arguments (1+), e.g.
\mylist{1,2,3} should expand to $\tilde{1}$--$\tilde{2}$--$\tilde{3}$. I'm trying to use xparse and \SplitList, but I didn't find a way to tell when I'm processing the last token (where I don't need the separator --).
\NewDocumentCommand\mylist{>{\SplitList{,}}m}
{
\ProcessList{#1}{\myitem}
}
\newcommand\myitem[1]{$\tilde{#1}$--}
This would expand \mylist{1} to $\tilde{1}$-- instead of the desired $\tilde{1}$.


\clist_map_inline:nnconstruction is to store the sequence with\seq_set_split:Nnn <seq> { , }(stable, doesn't ignore blank entries) or\seq_set_from_clist:Nn <seq>(experimental, ignores empty/blank entries), then using\seq_set_map:NNn <seq> <seq> { \exp_not:n {$\tilde{##1}$} }(experimental function), then\seq_use:Nnnnas you did. It is more efficient :-), and (perhaps) clearer. – Bruno Le Floch May 22 '13 at 09:49