< Back to Snippets

Sequence

Apply a function to all integers in a specified range, and push each result to the stack. So, it basically works exactly like \(\sum \left ( f, v, y, x \right )\), except that it pushes each calculation rather than adding them and returning the sum.


<variable ID="seqIndex" label="i" integer="0"/>
<variable ID="seqEnd" label="n" integer="0"/>
<subroutine ID="seq" parameters="4">
  <MathCeiling.Action/>
  <variable_store ref="seqEnd"/>
  <StackBox.Swap2/>
  <MathFloor.Action/>
  <variable_store ref="seqIndex"/>
  <MathSubtract.Action/>
  <whileX isNegative="false">
    <StackBox.Clear/>
    <variable_push ref="seqIndex"/>
    <StackBox.UpArrow/>
    <StackBox.RightArrow/>
    <StackBox.Enter/>
    <StackBox.Swap2/>
    <StackBox.Clear/>
    <MathWhere.Action/>

    <StackBox.Enter/>
    <StackBox.Explode/>
    <StackBox.ApplyConsole/>
    <StackBox.Digit1/>
    <MathAdd.Action/>
    <variable_store ref="seqIndex"/>
    <variable_push ref="seqEnd"/>
    <StackBox.Swap2/>
    <MathSubtract.Action/>
  </whileX>
  <StackBox.Clear/>
  <StackBox.Clear/>
  <StackBox.Clear/>
</subroutine>