Evaluates a different code branch depending on whether a condition is met, and in turn generates any resulting values generated by the chosen code branch.
<if <gt score, 100> then={High} else={Low}> generates High or Low.<if done then=<putLn {/finished}>> sends a line to the program only if done counts as true.The condition: a value, usually generated by a comparison or logic tag, which is treated as true or false. See Values for which values count as true.
When the if tag is complete, the condition in the tag's primary field is equated to a value of either true or false. If the condition was true, and the then field is defined, the code in the then field is executed. If the condition was false and the else field is defined, the code in the else field is executed instead. No code is executed if neither field is defined. If the condition is invalid or inf, which are neither true nor false, the if tag generates invalid and neither branch is executed. As code in either field is executed and generates values, the if tag itself generates the same values so the result can be used in the parent field of the if tag. The lifetime of the if tag ends when the selected branch has finished executing.
<n:scalar 7>
<box <if <eq <mod n, 2>, 0> then={even} else={odd}>>
odd