4 ms·
A minor problem with "append" (and "prepend" for the front) is that, as far as I know, there isn't a really satisfying word for the reverse operation. A search
by tzs 2y ago
A minor problem with "append" (and "prepend" for the front) is that, as far as I know, there isn't a really satisfying word for the reverse operation.
A search for the opposite of "append" suggests "remove", "subtract", "detach", "disconnect", "disjoin", "unfasten", "reduce", "diminish", and more. None of them really have the same "at the back" connotation that "append" has.
"Push" and "pop" are well known from stacks so it makes sense to use them for operations on one end of list-like containers. That still leaves the problem of what to call the similar operations on the other end.
I suppose we could sidestep that problem by only providing them at one end. So say push() adds to the back and pop() removes from the back.
If you want to operate at the front just reverse the list, do your push or pop, and then reverse the list again and let the optimizer deal with eliminating the two reverses. :-)