A.groupc( g ; v )

Description:

Perform row-to-column/column-to-row transposition on member sequences of a sequence.

Syntax:

A.groupc(g;v)

Note:

The function performs row-to-column/column-to-row transposition on member sequences of sequence A; default is row-to-column transposition.

 

Members of sequence A are also sequences. Both g and v are sequences consisting of sequence numbers of certain members of member sequences of A. Use syntax ~(i) or ~i to reference a member of the member sequence of A.

 

Group members of sequence A according to g and put members of v to corresponding sequences in each group and return a sequence of sequences.

Parameter:

A

A sequence of sequences

g

A sequence consisting of sequence numbers of certain members of member sequences of A

v

A sequence consisting of sequence numbers of certain members of member sequences of A

Option:

@r(g;v;k)

Perform column-to-row transposition. k is an integer; group v every k members, concatenate each group with g to form a new sequence, and return a sequence consisting of these new sequences

Return value:

Sequence of sequences

Example:

 

A

 

1

=file("t3.txt").cursor@w().fetch()

Return a sequence of sequences:

2

=A1.groupc(~(1);[(~2),(~3)])

Perform row-to-column transposition on A1’s members: group A1 by the 1st member of its member sequences, put the 2nd and the 3rd members of the member sequences to corresponding sequences in each group, and return the following result:

3

=A2.groupc@r(~1;[~2,~3,~4,~5,~6,~7];2)

@r option enables column-to-row transposition on A2: put every two members from the 2nd to the 7th in order in each member sequence of A2 in one group, combine each group with the 1st member of A2’s member sequences to form a new member sequence, and return the following result:

4

=A2.groupc@r(~1;~.to(2,);2)

@r option enables column-to-row transposition on A2: put every two members from the 2nd to the last in order in each member sequence of A2 in one group, combine each group with the 1st member of A2’s member sequences to form a new member sequence, and return a result same as A1.

 

When parameter g has multiple members:

 

A

 

1

=connect("demo").query("select top 9 * from scores").array@b()

Return a sequence of sequences:

2

=A1.groupc([~1,~2];[~3,~4])

Perform row-to-column transposition on A1’s members: group A1 by the 1st and 2nd members of its member sequences, put the 3rd and the 4th members of the member sequences to corresponding sequences in each group, and return the following result:

3

=A2.groupc@r([~1,~2];~.to(3,);2)

@r option enables column-to-row transposition on A2: put every two members from the 3rd to the last in order in each member sequence of A2 in one group, combine each group with the 1st and the 2nd members of A2’s member sequences to form a new member sequence, and return a result same as A1.

Related concept:

A.pivot()

P.groupc()