User Tools

Site Tools


plato:tutor:conditional_calc_commands

The Conditional -calc- Commands: -calcc- and -calcs-

The effects of -writec- can be achieved by a conditional -do- and a bunch of units containing the text elements, but we have seen that this is a clumsy way to do it. We would often like to calculate one of several things based on a condition. This, too, could be done with a conditional -do- to one of several units containing the calculations, but this is cumbersome. We saw one shortcut already:

calc x⇐100-25(y>13)

This statement is equivalent to “x⇐125” if y>13, and to “x⇐100” if y≤13. This can also be written as:

calcc y>13,x⇐125,x⇐100

The -calcc- (pronounced “calc-see”) is strictly analogous to -writec-. It indicates a list of calculations to be performed, dependent on a condition. The elements in the list are calculations rather than pieces of text or unit names.

Very often each of the calculations in the list consists of assigning a value to the same variable. In the example above, both calculations assign a value to the variable “x”. An even shorter way to write this kind of thing is:

calcs N-5y,bin⇐37,5.2,y3+2„2/N

The -calcs- (pronounced “calc-ess”) will More one of five values in “bin”, depending on the condition “N-537”. Note that if “N -5y” rounds to two, we do nothing. Two commas in a row („) indicate “do nothing” in -calcs-, -calcc-, and -writec-. Just as “x” can be a legitimate piece of text to write, so “x” might be a defined variable, which is why it cannot be used as the “do-nothing” indicator in these commands.

The Conditional -mode- Command

plato/tutor/conditional_calc_commands.txt · Last modified: 2023/08/05 18:55 by Site Administrator