Pop Element from List Property
This property describes how LW Python pops an element from a list, It first looks in the "Value" stack to get the index of the list in "Object Store. Then it pops the element at a given index (also specified in the "Value" stack) and updates the "Object Store" with the new list. More formally,
if the following are true:
- expression state at time t = "call_function_begin"
- Value Stack at time t = [ [ a, [ ] ], stack ]
- the expression at time t = name."pop"(args)
- value at obj in map (Variables Map at time t) = Python reference idx
- the element at index idx of stack (Python Object Store at time t) = Python list entries
then Python Object Store at time (t + 1) = result of storing (Python list (stack after popping a value from stack entries at index a)) at index idx of stack (Python Object Store at time t)
if the following are true:
- expression state at time 26 = "call_function_begin"
- Value Stack at time 26 = [ [ 2, [ ] ], [ ] ]
- the expression at time 26 =
numbers.pop(2)
- Python Object Store at time 26 = [
[2, 4, 6, 8, 10]
, [ ] ]
then Python Object Store at time (29 + 1) = result of storing (Python list (stack after popping a value from stack [ 2, [ 4, [ 6, [ 8, [ 10, [ ] ] ] ] ] ] at index 2)) at index 0 of stack (Python Object Store at time 29)
Here, LW Python read the list in index 0 of the "Object Store," popped the element at index 2 of this list, and then updated the "Object Store" with this new list.
Try stepping through the simulator to see LW Python pop 6 from "numbers."
Current Line | 1 | Current Tab | 0 | Time | 0 |
Comments
Please log in to add comments