
¿Cómo puedo usarla \str_if_in:nnTF
como función booleana, es decir, sin TF
argumentos para poder usarla dentro?
\bool_lazy_and:nnTF
{ \str_if_in:nn {abc} {a} }
{ ... }
{
true code
}{
false code
}
Respuesta1
Puede utilizar el etl
paquete, que define una forma totalmente expandible de \tl_if_in:nnTF
(llamada \etl_if_in:nnTF
). Tenga en cuenta que las funciones de etl
son más lentas que sus expl3
equivalentes, por lo que solo debe usar esto si tiene que ser ampliable.
\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}
Respuesta2
Aquí hay una solución alternativa confunctional
paquete:
\documentclass{article}
\usepackage{functional}
\begin{document}
\IgnoreSpacesOn
\boolVarAndTF {\strIfIn {abc} {a}} {\intCompare {1} < {2}} {
\prgReturn{True}
} {
\prgReturn{False}
}
\IgnoreSpacesOff
\end{document}