concat()

Read(4672) Label: concat,

Here’s how to use concat() function.

concat()

Description:

Concatenate parameters into a string.

Syntax:

concat(xi,…)

Note:

The function concatenates parameters xi,… into a string in which quotation marks will not be used

Parameter:

xi

Any value that can be converted to a string; if it is a sequence, it will be broken up before concatenation

Return value:

String

Example:

 

A

 

1

=demo.query("select * from SCORES where SCORE>90")

2

=A1.(SCORE)

 

3

=A1.(SUBJECT)

 

4

=concat(A2,A3)

979691939797979691939797PEEnglishPEEnglishMathMathPEEnglishPEEnglishMathMath.

5

=concat(2,3,"a")

23a.

Related functions:

s.split()

concat(x;d)

Description:

Use a delimiter to concatenate values of an aggregation field.

Syntax:

concat(x;d)

Note:

The function concatenates values of aggregation field x using the delimiter d; concatenate them without using a delimiter when parameter d is absent. It can only work as the aggregate function in the groups() function.

Parameter:

x

Aggregation field name

d

A delimiter

Option:

@c

Concatenate with the comma

@i

Enclose each to-be-concatenated value with the single quotation marks

@q

Enclose each to-be-concatenated value with the double quotation marks; won’t quote them when the option is absent

Return value:

String

Example:

 

A

 

1

=demo.query("select EID,NAME,DEPT from employee")

Return a table sequence.

2

=A1.groups(DEPT;concat(NAME;"_"):ALL_NAME)

Group A1’s table sequence by DEPT field, concatenate NAME values in each group with the delimiter _ and return them to ALL_NAME column.

3

=A1.groups(DEPT;concat@c(NAME):ALL_NAME)

Work with @c option to use the comma as the delimiter.

4

=A1.groups(DEPT;concat@q(NAME):ALL_NAME)

Work with @q option to enclose each to-be-concatenated value with the double quotation marks.

5

=A1.groups(DEPT;concat@i(NAME):ALL_NAME)

Work with @i option to enclose each to-be-concatenated value with the single quotation marks.

6

=A1.groups(DEPT;concat@i(NAME;"|"):ALL_NAME)

Work with @i option to enclose each to-be-concatenated value with the single quotation marks, and use | as the delimiter.

A.concat(d)

Description:

Concatenate members of a sequence with the delimiter and return result as a string.

Syntax

A.concat(d)

Note:

The function concatenates members of A delimited by d and returns result as into a string; the sub-sequences of the string will be handled in a same way. Concatenate the members without a delimiter when parameter d is omitted.

Option:

@q

Add quotation marks to string members when concatenating them into a string. If this option is omitted, do not use the quotation marks

@c

Concatenate with the comma

@i

Enclose string members to be concatenated with single quotes

@n 

If members of the sequence are also sequences, create a newl line after concatenate members of each sequence members with the delimiter. The operations are equivalent to A.(~.concat(d)).concat("\n"). If there are other options, perform the concatenation in the inner layer of the function

Parameter:

A

A sequence of strings

d

Delimiter

Return value:

String

Example:

 

A

 

1

=[1, ["a","b"],[2,"c"]]

 

2

=A1.concat()

Concatenate members of sequence A1 without using the separator; the result is 1[ab][2c] .

3

=A1.concat(":")

Concatenate members of sequence A1 using colon as the separator; the result is 1:[a:b]:[2:c] .

4

=A1.concat@q()

Use @q option to do the concatenation with the quotation marks retained; the result is 1["a""b"][2"c"].

5

=A1.concat@c()

Use @c option to do the concatenation with comma being the separator; the result is 1,[a,b],[2,c].

6

=A1.concat@i()

Use @i option to do the concatenation with  members bing enclosed by single quotation marks; the result is 1['a''b'][2'c'] .

7

=[[1,2,3], ["a","b"],[2,"c"]]

Return a sequence of sequences

8

=A7.concat@n("-")

Use @n option to join members of each sub-sequence in sequence A7 with the separator “-” and use the line break for a new sub-sequence; the result is as follows:

 

9

=A7.concat@nc()

Use @nc options to do the concatenation; below is the result: