I want to convert a space separated list of items, given as argument to a function, into a clist variable in order to iterate over them. However, I am not able to create a usable clist variable as the following code example demonstrates. \clist_map_inline:Nn always takes the whole list instead of separating the elements. What am I doing wrong?
\documentclass{minimal}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Nn\parselist:n{
\tl_set:Nx\l_csv_tl{#1}
\tl_replace_all:Nnn\l_csv_tl{~}{,}
\clist_set:Nx\l_csv_clist\l_csv_tl
\clist_map_inline:Nn\l_csv_clist{
\noindent Name:~#1\par
}
}
\ExplSyntaxOff
\begin{document}
\def\csv{fred jane albert}
\ExplSyntaxOn
\parselist:n\csv
\parselist:n{john~peter~linda}
\ExplSyntaxOff
\end{document}
Name:~##1. With#1you are getting the outer argument. – Ulrike Fischer Dec 02 '11 at 11:41\seq_set_split:Nnnhere. – Joseph Wright Dec 02 '11 at 12:43\parselist:nshould be either aVorNfunction (little in it here). – Joseph Wright Dec 02 '11 at 12:44\seq_set_split:Nnnvery much, but is it stable enough to be used in a public package? – AlexG Dec 02 '11 at 13:21\seq_set_split:Nnnover the next few days: it's definitely useful. – Joseph Wright Dec 02 '11 at 13:58\tl_set:Nx, the function should probably be called\parselist:x. I think\seq_set_split:Nnnis stable enough (at the implementation level) to be moved to non-experimental. Decide. – Bruno Le Floch Dec 02 '11 at 19:52