Pop in an immutable stack would return the top element + the new state of the stack.
that's retarded af, just use a mutable stack instead
Name:
Anonymous2018-12-04 0:50
not sure why you wouldn't want to modify the original one, but I guess an immutable stack would just create a new stack object and populate it with the same shit in the original one, sans the top thing to be popped
I guess you could use a generic class array, like Object[], and the popped value would be index 0, and the new stack would be index 1
Name:
Anonymous2018-12-04 5:04
Like >>6 implies, an immutable stack may as well just be an immutable linked list (like Haskell lists). You can efficiently pop and push the top (aka front) element, and previous iterations of the stack will still be perfectly valid in memory.
Name:
Anonymous2018-12-04 8:31
You cannot mutate the stack. The language is purely functional with immutable objects.
Name:
Anonymous2018-12-04 10:03
>>8 my anus is purely functional and can't be mutated