Is there a word meaning "append", but at the beginning, not the end? [closed]

In computer programming, when you append a "string" to another, you add it to the end of the former string.

E.g.

String string1 = "abcd";
String string2 = "efgh";

Appending the two strings would give

"abcdefgh"

But what if I wanted to add string2 before string1 to have the result:

"efghabcd"

What would be a good name for that that reverse operation? What is the opposite of "append"?


Prepend:

(computing, linguistics, transitive) To attach (an expression, phrase, etc.) to another, as a prefix.


Prepend: To attach (an expression, phrase, etc.) to another, as a prefix

I would also consider using concatenate, since this is often used to describe joining two strings together (and many computer languages have some kind of native CONCATENATE function).

Although the order of appending is implied by the order the strings are listed in, one can make it explicit by writing "append X to Y", which would result in YX.

If you wanted to describe the "reverse operation", you could simply reverse the order of variables in your sentence: "I'd like to append string1 to string2" (resulting in efghabcd).


Both dot-net and Java StringBuilder libraries, and probably comparable things in other libraries, have an "insert" function that allows you to insert a new string at an arbitrary place in a target string. Location zero would be at the beginning, location 1 is after the first character, etc.

Thus, my practical answer to your question in a programming context is that the opposite of "append" is "insert(0)".

Note that insert is useful to insert at any known offset into a string. It is not so useful for inserting at the end of the string because we then need an extra step to find just where the end is. As this is an extremely common thing to want to do, it makes sense to have a separate append function.

In general English, we say "prepend", as others have noted. But I don't think most string-builder-type objects have a prepend function, as it would be rather redundant with insert.