3 ms·
> Pushing items onto a stack isn't inherently a prepend operation. a stack has no idea of "prepend" or similar. It's defined by abstract like operations PUSH,
by lispm 2y ago
> Pushing items onto a stack isn't inherently a prepend operation.
a stack has no idea of "prepend" or similar. It's defined by abstract like operations PUSH, POP, IS-EMPTY, MAKE-STACK. How it is implemented is an implementation detail.
> It's generally a "put it on an end" operation,
Which you made up. There is nothing "generally" like that.
> meaning you could append it. Now, with a linked list that would be slower,
and to append would be unnecessary.
> So if I do implement a simple stack, I implement it with a vector (example[1]).
That's a simple "bounded" & "fixed size" stack.
> I'm a professional.
Okay. ;)
> Yes, I know the answer you're fishing for is "immutability"
That would be one answer. Can you think of more?
- kerkeslager 2y ago> > Pushing items onto a stack isn't inherently a prepend operation. > a stack has no idea of "prepend" or similar. It's defined by abstract like operations PUSH, POP, IS-EMPTY, MAKE-STACK. How it is implemented is an implementation detail. You say that as if the fact that it's an implementation detail means it doesn't matter. Implementation details do, in fact, matter. > > It's generally a "put it on an end" operation, > Which you made up. There is nothing "generally" like that. So you're saying that stacks don't have a "push" operation? Or that you don't understand what "push" does? > > meaning you could append it. Now, with a linked list that would be slower, > and to append would be unnecessary. Literally picking and quoting parts of two sentences out of context to state the obvious as if it's a response to anything I said in context is a new low even for you. > > So if I do implement a simple stack, I implement it with a vector (example[1]). > That's a simple "bounded" & "fixed size" stack. No, it's not. Are you aware that vectors can be resized? > > Yes, I know the answer you're fishing for is "immutability" > That would be one answer. Can you think of more? I'm not going to make your argument for you. If you have something to say, say it.