§11.18. The value after and the value before
A point which has come up several times in recent chapters is that enumerated kinds of value have a natural ordering. For example, if we write:
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
...then we not only have seven possible values, we have put them into a sequence, in order of their naming. We can't perform arithmetic on colours, of course, but we can perform comparisons on them. Thus "red < yellow" is true, while "green >= violet" is not. (More on comparisons in the chapter on Numbers and Equations, which also covers arithmetic.)
It's also sometimes useful to get at the sequence directly. First, the two ends:
first value of (name of kind) ... value
This phrase produces the first-created value of the given kind, which should be an enumeration. Example: if we have
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
then "first value of colour" is red.
last value of (name of kind) ... value
This phrase produces the last-created value of the given kind, which should be an enumeration. Example: if we have
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
then "last value of colour" is violet.
And now how to step forward and back:
(name of kind) after (enumerated value) ... value
This phrase produces the next-created value of the given kind, which should be an enumeration. Example: if we have
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
then "colour after orange" is yellow.
(name of kind) before (enumerated value) ... value
This phrase produces the previous-created value of the given kind, which should be an enumeration. Example: if we have
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
then "colour before blue" is green.
| ExampleEntropy All objects in the game have a heat, but if not kept insulated they will tend toward room temperature (and at a somewhat exaggerated rate).
|
|
"The Hang of Thursdays"
The Stage is a room. Rule for printing the name of the stage: say "[current weekday] [current time period]" instead.
A weekday is a kind of value. The weekdays are Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday. The current weekday is a weekday that varies. The current weekday is Saturday.
A time period is a kind of value. The time periods are morning, afternoon, evening, night. The current time period is a time period that varies. The current time period is afternoon.
This is the new advance time rule:
if the current time period is less than night:
now the current time period is the time period after the current time period;
otherwise:
now the current time period is morning;
now the current weekday is the weekday after the current weekday.
Now we need to borrow from a later chapter to make these instructions apply to the passage of time:
The new advance time rule is listed instead of the advance time rule in the turn sequence rules.
Test me with "z / z / z / z / z".
|   ExampleThe Hang of Thursdays Turns take a quarter day each, and the game rotates through the days of the week.
|
"The Hang of Thursdays"
The Stage is a room. Rule for printing the name of the stage: say "[current weekday] [current time period]" instead.
A weekday is a kind of value. The weekdays are Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday. The current weekday is a weekday that varies. The current weekday is Saturday.
A time period is a kind of value. The time periods are morning, afternoon, evening, night. The current time period is a time period that varies. The current time period is afternoon.
This is the new advance time rule:
if the current time period is less than night:
now the current time period is the time period after the current time period;
otherwise:
now the current time period is morning;
now the current weekday is the weekday after the current weekday.
Now we need to borrow from a later chapter to make these instructions apply to the passage of time:
The new advance time rule is listed instead of the advance time rule in the turn sequence rules.
Test me with "z / z / z / z / z".
"The Hang of Thursdays"
The Stage is a room. Rule for printing the name of the stage: say "[current weekday] [current time period]" instead.
A weekday is a kind of value. The weekdays are Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday. The current weekday is a weekday that varies. The current weekday is Saturday.
A time period is a kind of value. The time periods are morning, afternoon, evening, night. The current time period is a time period that varies. The current time period is afternoon.
This is the new advance time rule:
if the current time period is less than night:
now the current time period is the time period after the current time period;
otherwise:
now the current time period is morning;
now the current weekday is the weekday after the current weekday.
Now we need to borrow from a later chapter to make these instructions apply to the passage of time:
The new advance time rule is listed instead of the advance time rule in the turn sequence rules.
Test me with "z / z / z / z / z".
|