Frank Mittelbach wrote: > Joseph Wright writes: > > Hi all, > > > > On my latest LaTeX3 excursion, I'm looking achieve the effect of > > \@removeelement. I'd expect this to be a clist function, but there is > > nothing like "\clist_remove_elt:nnN" (#1 = elt, #2 = clist, #3 = new > > clist name) or "\clist_remove_elt:nN" (#1 = elt, #2 = clist to be edited). > > what are the precise semantics that you have in mind (with respect to element > not there, element there more than once etc ...) ? Good questions. In my case, I've already checked that the element is present and I can use \clist_remove_duplicates:N, so I'm not too fussed. However, in general this needs to be addressed. I'd imagine that, in the main, any removal function should tolerate the element not being there at all. \clist_if_in:NnTF is already available, and so can be used for checks by programmers. I'd imagine that most uses where an element is to be removed will either have a check before removal or will not need to know if the element is not there. On the repeated-item question, I think that in general you can't rely on \clist_remove_duplicates:N. So perhaps two versions are needed: \clist_remove_elt_first:Nn (or perhaps _left:) \clist_remove_elt_all:Nn (or perhaps _total: or _complete:) I'm thinking of usage along the lines: \clist_set:Nn \l_example_clist {a,b,c,d,d,e,e} \clist_remove_elt_first:Nn \l_example_clist {a} % \l_example_clist now {b,c,d,d,e,e} \clist_remove_elt_first:Nn \l_example_clist {d} % \l_example_clist now {b,c,d,e,e} \clist_remove_elt_all:Nn \l_example_clist {e} % \l_example_clist now {b,c,d} Here, I'm assuming that the clist is supplied by name and is returned into the same list. \@removeelement actually works slightly differently, but I think that the syntax above is clearer. I'm not sure a pre-expanded clist is very helpful, so I'd probably avoid: \clist_remove_elt:nnN {a,b,c} {b} \l_new_clist (which is actually similar to \@removeelement}. On the other hand, it might be useful to store the new clist in a separate place to the initial one: \clist_set:Nn \l_example_clist {a,b,c,d,d,e,e} \clist_set:Nn \l_new_clist {} \clist_remove_elt_first:NnN \l_example_clist {a} \l_new_clist % \l_new_clist now {b,c,d,d,e,e} \clist_remove_elt_first:NnN \l_example_clist {d} \l_new_clist % \l_new_clist now {a,b,c,d,e,e} \clist_remove_elt_all:NnN \l_example_clist {e} \l_new_clist % \l_new_clist now {a,b,c,d,d} How does all of this sound? -- Joseph Wright