State in Numipulator: Memory Numipulation Boxes
Personal Edition 4.0
State in Numipulator: Memory Numipulation Boxes

Most applications in Numipulator need to be able to handle state. For example, with a game the state might include the current board positions, the current score and the number of evaluation cycles. Numipulator has no variables in which to store state, so a different approach is required.

In essence, the Numipulator processing engine modifies the inputs to certain types of numipulation box: Memory Number or Memory List. To understand these, the actual Memory Number box shown at the top of the figure below is best considered as shown below it, with two implicit identity functions made explicit.

Associated with it are, unusually, two values that can be evaluated in a cycle: (1) the principal value, Y1, whose input is the single input field, mem, and whose value is determined by the identity function (the value of mem x 1); (2) a second value, newY1, whose input is the single input field, next, and whose value is determined by the identity function (the value of next x 1).

Now, newY1 and mem are actually the same field, as shown. This means that the output newY1, specified by next, overwrites the existing specification in mem and becomes the new input specification, mem, to Y1 in the next cycle, so will become the next value of Y1. The system therefore makes an output value from one cycle an input to the next cycle by modifying the input. State changes are therefore reflected in changes to the program (input specifications) made by the processing engine. Note: Only Y1 above may be used as an input to other numipulation boxes; newY1 may not. The dependencies of newY1 are, however, shown explicitly when the Flow button is pressed, but newY1 is not shown as feeding into any other numipulation box - not even Y1; this is correct, since within one evaluation there is no relationship between Y1 and newY1.

In the first cycle, mem will be undefined, as there is no previous cycle to supply its value. To overcome this, the user must provide a specification for mem in a separate field, init. If the processing engine finds that mem is empty, or the Start button is pressed, the text in this is copied from init into mem, to provide its initial specification.

The Numipulator Help facility or file demonstrates the use of a Memory Number box and a Number Operation box to implement an incrementor.

Note: If no specification for next is given in a Memory box, there will be no overwriting of the specification of mem at the end of a cycle. Due to this, a Memory Number box in which next is not specified acts just like a Common Number box.

Copyright TopAccolades Limited, 2023