conj()

Read(2915) Label: conj,

Here’s how to use conj() functions.

A .conj()

Description:

Get concatenation of all sequence-type members.

Syntax:

A.conj(x)

Note:

The function concatenates all the sequence-type members in sequence A; compute expression x by loop and then concatenate the results when parameter x is present.

A.conj(x,…) is equivalen to A.(x,…).conj().

Option:

@r

Recursively concatenate members until there aren’t any sequence members

@v

Return a pure sequence when members of A are pure sequences/pure table sequences

Parameter:

A

A sequence whose members are sequences

x

An expression; can be omitted

Return value:

Sequence

Example:

When members of A are sequences:

 

A

 

1

=[[1,2,3],[4,5,6]].conj()

[1,2,3,4,5,6].

2

=[[1,[2,3]],[2,5,6]].conj()

[1,[2,3],2,5,6].

3

=[[1,2,3],[3],[7]].conj()

[1,2,3,3,7].

4

=[[1,[2,3]],[2,5,6]].conj@r()

Use @r option to recursively concatenate members until there isn’t any sequence member and return [1,2,3,2,5,6].

5

=[[1,2,3],[4,5,6]]

 

6

=A5.conj(~**2)

Return [2,4,6,8,10,12].

7

=A5.(~**2).conj()

Same result as A5.

When members of A are table sequences or record sequences

 

A

 

1

=demo.query("select  top 4 EID,NAME,GENDER from EMPLOYEE where GENDER = 'M' ")

2

=demo.query("select top 4 EID,NAME,GENDER  from EMPLOYEE where GENDER = 'F' ")

3

=[A1,A2].conj()

Compute concatenation of members of [A1,A2] and return result below:

4

=[A1,A2].conj(~.(NAME))

Compute concatenation of NAME fields of members of [A1,A2] and return

["Matthew","Ryan","Jacob","Daniel","Rebecca","Ashley","Rachel","Emily"]

5

=[A1,A2].(~.(NAME)).conj()

Same result as A4.

Return a pure sequence:

 

A

 

1

=[1,2,3].i()

Return a pure sequence.

2

=[4,5].i()

Return a pure sequence.

3

=[A1,A2].conj@v()

Use @v option to return a pure sequence.

4

=ifpure(A3)

Judge whether A3 is a pure sequence and return true.

ch .conj()

Description:

Attach a computation to a channel, which will split each of its records and perform union on the splitting result.

Syntax:

ch.conj(x)

Note:

The function attaches a computation to channel ch, which will split each of its records according to result of computing expression x into a sequence or a record sequence, union the result members or records, and return the original channel ch.

 

This is an attachment computation.

Parameter:

ch

A channel.

x

An expression that returns a record sequence/table sequence.

Return value:

Channel

Example:

 

A

 

1

=demo.cursor("select * from GYMNASTICSWOMEN")

Return a cursor.

The above is content of GYMNASTICSWOMEN table.

2

=channel()

Create a channel.

3

=A2.conj(create(ID,NAME,COUNTRY,SUBJECT,SCORES).record([ID,NAME,COUNTRY,"VAULT"

,VAULT,ID,NAME,COUNTRY,"UNEVENBARS",UNEVENBARS,ID,NAME,COUNTRY,

"BALANCEBEAM",BALANCEBEAM,ID,NAME,COUNTRY,"FLOOR",FLOOR]))

Attach a computation to channel A2, which will perform column-to-row transposition on VAULT, UNEVENBARS, BALANCEBEAM and FLOOR fields, and return the original channel.

3

=A2.fetch()

Execute the result set function in channel A2 and keep the current data in channel.

4

=A1.push(A2)

Be ready to push data in A1’s cursor into the channel, but the action needs to wait.

5

=A1.fetch()

Fetch data from cursor A1 while pushing data into the channel to execute the attached computation and keep the result.

6

=A2.result()

Get channel A2’s result:

cs .conj()

Description

Attach the action of splitting each of the records to a cursor and unioning the result members and return the original cursor.

Syntax

cs.conj()

Note

Attach a computation to cursor cs. The function computes expression x over each of the records in cursor cs, splits them into a sequence or a record sequence, unions the result members or records, and returns the original cursor cs.

 

This is a delayed function.

Parameter

cs

A cursor/multicursor

x

An expression that returns a record sequence (or a table sequence)

Return value

Cursor

Example

 

A

 

1

=demo.cursor("select * from GYMNASTICSWOMEN")

Return a cursor, whose data is as follows:

2

=A1.conj(create(ID,NAME,COUNTRY,SUBJECT,SCORES).record([ID,NAME,

COUNTRY,"VAULT",VAULT,ID,NAME,COUNTRY,"UNEVENBARS",

UNEVENBARS,ID,NAME,COUNTRY,"BALANCEBEAM",

BALANCEBEAM,ID,NAME,COUNTRY,"FLOOR",FLOOR]))

Attach a computation to cursor A1 on which a column-to-row transposition on the cursor’s VAULT, UNEVENBARS, BALANCEBEAM and FLOOR fields will be performed and return the original cursor A1.

3

=A1.fetch()

 

Fetch data from cursor A1 on which A2’s computation is already executed (it would be better to fetch data in batches when data amount is huge):

CS .conj()

Description:

Union the members of a cursor sequence, and return result as a multicursor.

Syntax:

CS.conj()

Note:

The function concatenates members of CS, a sequence of cursors, and returns result as a multicursor. This is actually the merging of data in the cursors. Each cursor in CS must have the same structure.

 

This is a delayed function.

Parameter:

CS

A sequence of cursors

Return value:

Multicursor

Example:

 

A

 

1

=connect("demo").cursor("SELECT  top 3 *  FROM scores where SUBJECT='English' ")

Return a cursor, whose data is as follows:

2

=connect("demo").cursor("SELECT  top 3 *  FROM scores where SUBJECT='Math' ")

Return a cursor, whose data is as follows:

3

=connect("demo").cursor("SELECT  top 3 *  FROM scores where SUBJECT='PE' ")

Return a cursor, whose data is as follows:

4

=[A1,A2,A3]

Return a sequence consisting of the three cursors.

5

=A4.conj()

Concatenate records of members cursors in A4’s sequence and return a cursor.

6

=A5.fetch()

Fetch data from cursor A5:

Related function:

A.merge()
CS.merge()

T.conj()

Description:

Define a computation on a pseudo table, which splits each of its records and concatenates the result records.

Syntax:

T.conj(x)

Note:

The function defines a computation on pseudo table T, where each record will be split into a sequence or a record sequence according to computing expression x and members or records in the splitting result will be concatenated, and returns a new pseudo table.

Parameter:

T

A pseudo table

x

An expression that returns a record sequence or a table sequence

Return value:

Pseudo table

Example:

 

A

 

1

=create(file).record(["gymn.ctx"])

Below is content of composite table gymn.ctx:

2

=pseudo(A1)

Return a pseudo table object.

3

=A2.conj(create(ID,NAME,COUNTRY,SUBJECT,SCORES).record([ID,NAME,COUNTRY

,"VAULT",VAULT,ID,NAME,COUNTRY,"UNEVENBARS",UNEVENBARS

,ID,NAME,COUNTRY,"BALANCEBEAM",BALANCEBEAM,ID,NAME,COUNTRY,"FLOOR",FLOOR]))

Define a computation on A2’s pseudo table, which splits each of its records and concatenates records in the splitting result, and return a new pseudo table.

4

=A3.cursor().fetch()

Fetch data from A3’s pseudo table while the defined computation in A3 is executed on A2’s pseudo table, and return the following content: