Reversing a List Property 3
reverse of remaining stack [ x, xs ] and already reversed stack ys = reverse of remaining stack xs and already reversed stack [ x, ys ]
Comparing the left side of the = sign to the right side, notice how x moves from front of xs to the front of ys. Thus, if this property is applied many times, the "remaining" list gradually gets shorter while the "already reversed" list grows larger (with the elements reversed).
Examples
reverse of remaining stack [ 1, [ 2, [ 3, [ 4, [ ] ] ] ] ] and already reversed stack [ ] = reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ]
reverse of remaining stack [ 2, [ 3, [ 4, [ ] ] ] ] and already reversed stack [ 1, [ ] ] = reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ]
reverse of remaining stack [ 3, [ 4, [ ] ] ] and already reversed stack [ 2, [ 1, [ ] ] ] = reverse of remaining stack [ 4, [ ] ] and already reversed stack [ 3, [ 2, [ 1, [ ] ] ] ]
Please fill in the blank:
(reverse of remaining list [10,[5,[]]] and already reversed list [15, [20,[25,[]]]]) = (reverse of remaining list [5, []] and already reversed list _________________)
Comments
Please log in to add comments