1

What is the equivalent of \ifthenelse{<statement>}{<iftrue>}{<iffalse>} when using expl3 syntax?

Sigur
  • 37,330
noibe
  • 2,084
  • 2
    expl3 has different conditional macros, such as \bool_if:NTF \some_bool {true branch}{false branch} or \seq_if_in:NnTF etc, depending on the 'variable' type and the precise application usage –  Feb 16 '19 at 19:39
  • Let's say I want to check whether two integers are equal or not, would something like \bool_if:{ \equal{#1}{#2} }{ <iftrue> }{ <iffalse> } work? – noibe Feb 16 '19 at 19:42
  • 4
    No, since integers are not bool, at least not that way. \int_compare:nNnTF {#1} = {#2} {true}{false} -- the \equal etc. syntax is not available in expl3 and I found \ifthenelse never convincing -- see the interface3 manual please –  Feb 16 '19 at 19:44
  • 2
    You could do \bool_if:nTF { \int_compare_p:nNn {#1} = {#2} } { true } { false }, but as @ChristianHupfer says normally one would use just the basic int comparison. – Joseph Wright Feb 16 '19 at 19:46
  • @JosephWright: Is your style more efficient? –  Feb 16 '19 at 19:47
  • 3
    @ChristianHupfer No, quite the opposite, but it's using the general 'do some comparisons' syntax – Joseph Wright Feb 16 '19 at 19:48
  • @JosephWright: I seem to have missed \int_compare_p:nNn however yet -- most likely I had no need for it (yet) –  Feb 16 '19 at 19:50
  • You may want to look at https://tex.stackexchange.com/a/467527/4427 – egreg Feb 16 '19 at 22:18

0 Answers0