I could not find in the LaTeX3 documentation any function to count the number of elements in a clist. So I coded my own, but it is likely to be very suboptimal.
Is there any better alternative?
To be precise, \clist_count:NN stores in its first argument (of type int) the length of its second argument (a clist)
\cs_new:Nn \clist_count:NN
{
\int_set:Nn \l_tmpa_int {0}
\clist_set_eq:NN \l_tmpa_clist #2
\bool_until_do:nn
{
\clist_if_empty_p:N \l_tmpa_clist
}{
\clist_pop:NN \l_tmpa_clist \l_tmpa_tl
\int_add:Nn \l_tmpa_int {1}
}
\int_set_eq:NN #1 \l_tmpa_int
}
I am also interested in a function that would pick the n-th element of a clist.
\cs_if_free:NT). I would be very interested in hearing your thoughts on using expl3 as a relatively new package author; please don't hesitate to write any comments to me directly. – Will Robertson Jan 23 '11 at 11:09