TABULA/samples/indicator flag

From J Wiki
Jump to navigation Jump to search

This is SAMPLE7. To work with this sample, enter $7

indicator flag
┌ {1}    0 *   unit
└>{2}   NO     is {1} non-zero?

Rationale

An indicator flag is a quantity which gets displayed as YES or NO instead of a value (1 or 0) followed by a units.

You can use it as a switch to modify the behavior of the t-table in some way.

Try it out

  1. Select line {1} then enter 0
    Line {2} will change to NO.
  2. Select line {1} then enter 1
    Line {2} will change to YES.
  3. Select line {1} then change its value to any non-zero number
    Line {2} will remain unchanged at YES.
  4. Select line {2} then enter YES
    Line {1} will change to 1.

The indicator flag at line {2} has an underlying value which tracks the value of {1}.

  • It displays NO whenever {2} has the value zero.
  • Otherwise it displays YES.
  • If you force {2} = YES, then {1} becomes 1 by backfitting.

Build this t-table

  1. Clear the t-table.
  2. Edit the title to read: indicator flag
  3. Make a new line {1}.
  4. Make an equal line {2} equal to {1}.
  5. Change the units of line {2} to [!]
  6. Re-label line {2} to read: is {1} non-zero?