You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(This stems from discussions on an unrelated pull request #819). The \tl_item:nn function expands to nothing when the item is out of bounds. It would be good to provide TF versions of these functions which take the false branch when there is no item.
However it is not clear where the true branch should end up compared to the item itself. For consistency with all other TF functions \tl_item:nnTF { abc } { 2 } t f should give bt. This is essentially the same problem we had regarding \file_if_exist_input:nTF in #253, and the solution may be similar: add another argument to place before the found item. More precisely, I would suggest the following list of functions:
\tl_item:nnF, but not :nnT nor :nnTF;
\tl_item_apply:nnNTF (token list) (position) (n-type function) (true code) (false code), which gives either (false code) if the position is out of bounds, and (function){(item)} (true code) otherwise. Provide also the nnNT, nnNF, and nnN variants.
The indexing issue #892 will also apply here. All these comments about tl apply to clist, seq, prop at least.
The text was updated successfully, but these errors were encountered:
I'm worried that this would add 5 commands (:nnF, :nnN, :nnNT, :nnNF, :nnNTF) for each of N/c/n-type tl/clist/str and N/c type seq/prop, leading us to add 5×(3×3+2×2)=65 control sequences, plus some auxiliaries to implement them. Is that reasonable?
I think only catching the false case makes sense, which overcomes the “order” issue and keeps the number of excess csnames down. If someone comes along with a complex need that this doesn’t capture, a slimmer addition could be something like \tl_if_item_in_range:nnTF so you could write, say,
\tl_if_item_in_range:nnTF {abc} {4}
{
something~before
\tl_item {abc} {4}
something~after
}
{ \ERROR }
(This stems from discussions on an unrelated pull request #819). The
\tl_item:nn
function expands to nothing when the item is out of bounds. It would be good to provide TF versions of these functions which take the false branch when there is no item.However it is not clear where the true branch should end up compared to the item itself. For consistency with all other
TF
functions\tl_item:nnTF { abc } { 2 } t f
should givebt
. This is essentially the same problem we had regarding\file_if_exist_input:nTF
in #253, and the solution may be similar: add another argument to place before the found item. More precisely, I would suggest the following list of functions:\tl_item:nnF
, but not:nnT
nor:nnTF
;\tl_item_apply:nnNTF
(token list) (position) (n-type function) (true code) (false code), which gives either (false code) if the position is out of bounds, and (function){(item)} (true code) otherwise. Provide also thennNT
,nnNF
, andnnN
variants.The indexing issue #892 will also apply here. All these comments about tl apply to clist, seq, prop at least.
The text was updated successfully, but these errors were encountered: