End For Loop Tab Property

If iterable is empty, then LW Python skips the "for" loop body by keeping the tab unchanged. 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_ex:
  • value at j in map (Control Map at time t) = trio ("for", i, [ ])

then the tab at time (t + 1) = j

The iterable is stored in the "Control" map entry. For example, if the following are true:
  • the line at time 56 = 2
  • the tab at time 56 = 0
  • statement at line 2, tab 0 = for value in numbers:
  • value at 0 in map (Control Map at time 56) = trio ("for", 2, [ ])

then the tab at time (56 + 1) = 0

Try stepping through the simulator to see LW Python skip the loop after 3 iterations.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments