concat

Syntax

concat(X, Y)

Arguments

X can be a STRING/CHAR scalar or vector.

Y can be a STRING/CHAR scalar.

If X or Y is not specified, it is treated as an empty string.

Details

If X is a STRING/CHAR scalar

  • For an empty X,
    • if Y is an empty STRING/CHAR scalar, the function returns an empty string.

    • if Y is a non-empty STRING/CHAR scalar, the function returns Y.

  • Otherwise, the function forms a new string by combining X and Y regardless of whether Y is an empty string or not.

If X is a STRING/CHAR vector

  • For an empty X, the function returns an empty string.

  • Otherwise,
    • if Y is an empty STRING/CHAR scalar, the function concatenates each element in X and returns a string object;

    • if Y is a non-empty STRING/CHAR scalar, Y serves as the separator between the elements in vector X and the function returns a string object.

Note: The function concat implicitly converts all arguments to STRING type (NULL values to empty strings) before concatenation.

Return value: a STRING scalar

Examples

// join two strings
$ concat (`hello, `world);
helloworld

// join IBM, GOOG and APPL with "," as the delimiter
$ x = concat(`IBM`GOOG`APPL, ",");
$ x;
IBM,GOOG,APPL

$ typestr x;
STRING

$ size x;
1

$ concat(string([]),"a")
NULL

$ concat("55","")
55

// When Y is not specified, the function joins the elements of X to form a new string
$ concat(`a`b`c`d,)
abcd