Search

mercredi 8 février 2017

Conditional execution: if / then

Context

Assuming that a condition has been already evaluated (0 = false, true otherwise), it's fairly simple to execute code based on this condition. However, condition also need to be reset after execution of conditional code, to make sure that loop breaks and that both true and false cases ends up to the same state.
Finally, note that the conditional execution implemented like this destroys the condition, for the reason mentioned above.

Initial state

  • Memory: A
  • Cursor: first cell
  • Input: any

Process

  • While first cell is not null
    • Do something
    • Reset first cell

Code 

[do something[-]]

Final state



  • Memory: 0
  • Cursor: first cell
  • Input: any
  • Output: unchanged

Aucun commentaire:

Enregistrer un commentaire