4

What is the difference between \bool_if_p:N and \bool_if:NFT? How to use these commands?

The documentation does not provide any details on this.

enter image description here

1
  • 1
    Take a look at section "9.1 Defining a set of conditional functions" from texdoc interface3 for a better grasp at the differences. But \bool_if_p:N is a predicate which "returns" either true or false, whereas \bool_if:NFT is a function which has a true and a false branches.
    – gusbrs
    Mar 18, 2023 at 1:07

1 Answer 1

9

This is documented, but not for this specific function, rather at the beginning, which applies to all expl3 conditionals:

enter image description here


The :NTF form is a branching conditional, and you use it like:

\bool_if:NTF \l_my_bool
  { <code if true> }
  { <code if false> }

and the _p:N form is a “predicate” conditional, and you use it as part of a boolean expression:

%              vvvvvvvvvvvv
\bool_if:nTF { \bool_if_p:N \l_my_bool || \tl_if_exist_p:N \l_my_tl }
  { <code if true> }
  { <code if false> }

In short: the predicate form returns a value, while the branching form executes some code.

Note that the predicate form is not available in non-expandable conditional functions (e.g. l3regex conditionals).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .