next up previous contents
Next: Profiling Up: Strategies Previous: Strategies


In order to track the input digits required to obtain certain digits of output we modify the data types used to store the digits to contain an additional `lookahead' field. We number the lookahead of the digits in the input stream (ie. 1, 2, 3, ...), and then we can extract the lookahead of the digits in the output stream.

The implementation of this is not entirely trivial. The readability and performance of the parts of code is seriously affected, so the lookahead experiments were implemented on a copy of the basic code and are separate from the calculator. It is achieved by modifying the basic operations so that when two digits are operated upon, the lookahead of the resulting digit is the maximum of the lookaheads of the operands. Similarly, if we introduce constants or pattern match in order to decide digits, we must extract the lookaheads from the digits used and ensure that the lookahead of the output digit is the maximum of its current lookahead and the lookahead of other digits used to decide it.

Martin Escardo