5 ms·
Append to which side? Push and pop are terms of are for queues and stacks which containers can be and the back and front tell us which end of the container we
by beached_whale 2y ago
Append to which side? Push and pop are terms of are for queues and stacks which containers can be and the back and front tell us which end of the container we mean
- CamperBob2 2y agoAppend implies the back or end of something, while "prepend" would be the analogous term for the front.
- throwaway2037 2y agoFrom a natural language perspective, I agree. In practice, however, I see far more container libraries use the terms: (1) add or append and (2) insert w/ index (instead of prepend). Do you know of any container libraries that use the term prepend? From time to time, I use it in a function for some kind of business logic, e.g., "prependMeetingInvite()".
- mewpmewp2 2y agoJS dom manipulation has prepend and append. These always felt quite natural to me. While push back feels weird. The act of pushing feels out of place and I also think back and front may also be ambiguous.
- timthorn 2y agoPrefix would be the traditional term.
- jkaplowitz 2y agoWouldn’t prefix be the traditional counterpart to suffix, not to append?
- timthorn 2y agoYes, it would. But prefix is also a verb that means to "to add something before another thing" which is the counterpart to append.
- jkaplowitz 2y agoSuffix is also a verb that means “to add something after another thing”. I think the verb prefix is the counterpart to the verb suffix, the noun prefix is the counterpart to the noun suffix, and the verb prepend is the counterpart to the verb append.