Begin For Loop Iterable State Property

When LW Python encounters a "for" statement, it first evaluates the "iterable." More formally,

if the following are true:
  • the line at time t = i
  • the tab at time t = j
  • statement at line i, tab j = for target in iterable:
  • map (Control Map at time t) does not contain a for loop entry at line: i and tab: j
  • expression state at time t = "not_expr"

then expression state at time (t + 1) = "begin_expr"

LW Python checks the "Control" map to see if it previously recorded information about the current "for" loop. It also checks the current expression state (to ensure it hasn't already started evaluating the "iterable.").

For example, if the following are true:

  • the line at time 14 = 2
  • the tab at time 14 = 0
  • statement at line 2, tab 0 = for value in numbers:
  • map (Control Map at time 14) does not contain a for loop entry at line: 2 and tab: 0
  • expression state at time 14 = "not_expr"

then expression state at time (14 + 1) = "begin_expr"

Try stepping through the simulator to see the "Expression State" change to "begin_expr"

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments