Begin For Loop Iterable 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 the expression at time (t + 1) = iterable

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 the expression at time (14 + 1) = numbers

Try stepping through the simulator to see LW Python evaluate "numbers."

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments