Iterate/Subset

From Esolang
Jump to navigation Jump to search

Back to Iterate

This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Iterate's cross-scope selectors and commands—n#, n^, ~n#, ~n^, !#, !^, &#, and &^, but excluding those which manipulate visit counts—are not necessary for the purposes of Iterate. While helpful, they can be completely ignored and trivially replaced with a stricter control flow.

n and ~n

The cross-scope variants of these two commands can easily be replaced by storing a copy of the value for later reference. For a further subset, these values can be ignored entirely and computed by hand.

*?< (1*)<> > // loop length
*=1<
  (2*)<> // effective n
  $3 *=1< (3*)<> > // set L3 = loop length
  *=2<             // decrement L3 by n
    $4 $5
    *=3<           // increment L4 to equal L3 - 1
      *=5<         // this is initially 0
       (4*)<>
       !
      >
      (5*)<>       // only after the first loop will we start incrementing
    >
    $3 *=4< (3*)<> > // set L3 to new count
  >
>

&

While replicating this is a little more complex, it can be done by setting a label's value to equate to zero where the command would run, and setting up a child loop to use that value and be skipped after it is ran. The label should be initialized back to one. Depending on how deep the command is, multiple equivalent loops that skip functionality may be necessary.

!

Breaking a parent loop functions similarly to continuing, however everything will require double-nesting in order to not only skip past the remaining content, but also prevent any further loops from occurring. Unlike &, this emulation does not work with infinite loops, as the loop will never truly halt, making calculating upper-bounds necessary.

Caveats

Proper output is not possible.