Begin For Loop Line Property

If the 'Control' map shows at least one element in the iterable, increment the line number by 1 to enter the "for" loop body. 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, [ elem, rest ])

then the line at time (t + 1) = i + 1

For example, if the following are true:
  • the line at time 17 = 2
  • the tab at time 17 = 0
  • statement at line 2, tab 0 = for value in numbers:
  • value at 0 in map (Control Map at time 17) = trio ("for", 2, [ 1, [ 2, [ 3, [ ] ] ] ])

then the line at time (17 + 1) = 2 + 1

Try stepping through the simulator to see LW Python enter the "for" loop body

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments