conj()

Read(844) 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.

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:

A 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]

 

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"]

 

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:

Split each of the records in a channel, union the members and return the resulting union as a channel.

Syntax:

ch.conj()

Note:

The function computes a given expression over the records in channel ch to split each of them into a sequence or a records sequence, union the members and return the resulting union as a channel. This is an attached computation.

Parameter:

ch

Channel

An expression that returns a record sequence/table sequence

Return value:

Channel

Example:

 

A

 

1

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

The above is the 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]))

Split up the records in A2’s channel into a sequence, union the records and return the union result as a channel

3

=A2.fetch()

Attach ch.fetch() function that gets the final result set to A2’s channel to fetch and store the existing data in the channel

4

=A1.push(A2)

Be ready to push data in A1’s cursor into the channel, but the action needs to wait; data in A1’s cursor is pushed into the channel and operations are performed as the fetch() operation is performed over A1

5

=A1.fetch()

 

6

=A2.result()

cs .conj()

Description

 Split each of the records in a cursor, union the members and return the original cursor.

Syntax

cs.conj()

Note

The function computes the expression over the records in cursor cs to split each of them into a sequence or a record sequence, union the members and return the original cursor.

Parameter

cs

A cursor/multicursor

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

Return value

The original cursor cs

Example

 

A

 

1

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

The above is the content of GYMNASTICSWOMEN table

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]))

 

3

=A2.fetch()

CS .conj()

Description:

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

Syntax:

CS.conj()

Note:

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

Parameter:

CS

A sequence of cursors

Return value:

Cursor

Example:

 

A

B

 

1

=directory@p("D://txt//")

=[]

Below are the three files in the txt folder

2

for A1.len()

 

 

3

 

=file(A1(A2))

 

4

 

=B3.cursor@t()

 

5

 

>B1=B1|B4

Store the cursor sequence in B1

6

=B1.conj()

 

Union the cursors

7

=A6.fetch()

 

Fetch data from the cursor

Related function:

A.merge()
CS.merge()

T.conj()

Description:

Split each record of a pseudo table and concatenate the splitting results.

Sytnax:

T.conj()

Note:

The function splits each record of pseudo table T into a table sequence or a record sequence according to expression …, concatenates members or records of the splitting result set, and returns a new pseudo table.

Parameter:

T

A pseudo table

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]))

Split each record of the pseudo table and concatenate the splitting results

4

=A3.import()

Below is content of the pseudo table returned by A3: