List Length Count Property
length of remaining stack [ x, y ] with count count = length of remaining stack y with count (count + 1)
This property says that we can count the length of a list by popping an element off the list and incrementing the count by 1 at the same time. Thus, by the time we pop off all the elements from a list, we have the full count.
Examples
length of remaining stack [ A, [ "B", [ "C", [ ] ] ] ] with count 0 = length of remaining stack [ "B", [ "C", [ ] ] ] with count (0 + 1)
length of remaining stack [ 2, [ 4, [ 8, [ ] ] ] ] with count 1 = length of remaining stack [ 4, [ 8, [ ] ] ] with count (1 + 1)
Comments
Please log in to add comments