
Como posso usar \str_if_in:nnTF
como uma função booleana, ou seja, sem TF
argumentos, para que eu possa usá-la dentro
\bool_lazy_and:nnTF
{ \str_if_in:nn {abc} {a} }
{ ... }
{
true code
}{
false code
}
Responder1
Você pode usar o etl
pacote, que define uma forma totalmente expansível de \tl_if_in:nnTF
(nomeado \etl_if_in:nnTF
). Observe que as funções de etl
são mais lentas que as expl3
equivalentes, portanto, você só deve usá-las se precisar ser expansível.
\documentclass{article}
\usepackage{etl}
\ExplSyntaxOn
\cs_generate_variant:Nn \etl_if_in:nnTF { oo }
\prg_new_conditional:Npnn \antshar_str_if_in:nn #1#2 {p, TF, T, F}
{
\etl_if_in:ooTF { \tl_to_str:n {#1} } { \tl_to_str:n {#2} }
\prg_return_true:
\prg_return_false:
}
\NewExpandableDocumentCommand \antshartest { m m }
{
\bool_lazy_and:nnTF
{ !\tl_if_empty_p:n {#1} }
{ \antshar_str_if_in_p:nn {#1} {#2} }
{ true }
{ false }
}
\ExplSyntaxOff
\begin{document}
\antshartest{}{abc}
\antshartest{def{abc}def}{abc}
\end{document}
Responder2
Aqui está uma solução alternativa comfunctional
pacote:
\documentclass{article}
\usepackage{functional}
\begin{document}
\IgnoreSpacesOn
\boolVarAndTF {\strIfIn {abc} {a}} {\intCompare {1} < {2}} {
\prgReturn{True}
} {
\prgReturn{False}
}
\IgnoreSpacesOff
\end{document}