This is more of a theoretical question.
Is it possible to use ternary operators, like it is possible in C (e.g.
(a<b) ? a : b), and if yes how?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
Yes C only needs different syntax for
if because it distinguishes between statements and expressions. programming languages that don't make that distinction or don't make it so strongly, can naturally use the value of an if-expression.
so you do not have to go
\ifnum \count0<\count2 \count3=4 \else \count3=5 \fi
which is the analogue of a C
if surrounding two assignments.
You can go
\count3=\ifnum \count0<\count2 4\else 5\fi
with the if expression providing the value of a single assignment which is the analogue of a C ternary expression.