enum()

Read(1611) Label: enumeration, group,

Here’s how to use enum() function.

P.enum()

Description:

Generate a new record sequence by performing enumeration grouping on an record sequence according to another record sequence.

Syntax:

P.enum(E, y)

Note:

The function generates a new record sequence by grouping the record sequence P according to the record sequence/sequence E.

Parameter:

P

Record sequence to be grouped

E

Record sequence/sequence

y

A field name or an expression in P. y is allowed to be omitted

Option:

@r

Repetitive enum, that is, allocate a certain record of P to multiple groups

@p

The return value is composed of the ordinal numbers of members that exist in P

@n

Group P’s records according to E’s members and return the result groups. In the result set, there is a group to store the unaligned member(s)

Function keyword:

?

It represents the value of y

Return value:

Record sequence

Example:

E is a sequence:

 

A

 

1

=["?<=60","?>=60 && ?<=90","?>=90"]

Use y to replace ? in the group condition when computing.

2

=demo.query("select * from SCORES")

 

3

=A2.enum(A1,SCORE)

3 groups in total, and a member will not appear in multiple groups.

4

=A2.enum@r(A1,SCORE)

3 groups in total; 60 and 90 are allocated to multiple groups.

5

=A2.enum@p(A1,SCORE)

3 groups in total; return the ordinal numbers of members that exist in A2 by group.

6

=["?<=60","?>=60 && ?<=90"]

 

7

=A2.enum@n(A6,SCORE)

3 groups in total, group 1 for those not greater than 60, group 2 for those greater than 60 and not greater than 90, and group 3 for the remaining values.

Note:

p.enum() is mainly used to conduct the enum grouping on a single record sequence. The grouping result is a sequence composed of multiple record sets, and each record set is a group. This sequence is in an order exactly equal to that of E. Therefore, you can retrieve the associated group information from E via the ordinal numbers. The group result is not a record sequence, so no new data structure will be generated

Related function:

E.penum()