x.nodes@r(Fi,...)

Read(320) Label: recursion, referencing field,

Description:

Expand the referencing field(s) through multilevel of recursion.

Syntax:

x.nodes@r(Fi,...)

Note:

The function expands the referencing fields in parameter x through multilevel of recursion.

 

When parameter x is a single value, return an empty sequence;

 

When parameter x is a record and if the specified Fi,… fields all have single values, return a sequence consisting of x; otherwise return x.Fi.nodes@r(Fi,... )|...;

 

When parameter x is a sequence or a record sequence, return x.conj(~.nodes@r(Fi,...)).

 

When parameter Fi is absent, traverse all fields of x.

Parameter:

x

A single value/a sequence/a record.

Fi

The field name.

Return value:

Sequence

Example:

When parameter x is a single value:

 

A

 

1

=rand(10)

Return random values within 10

2

=A1.nodes@r()

Return [].

 

When parameter x is a single record or a sequence:

 

A

 

1

=demo.query("select  * from DEPARTMENT").keys(DEPT)

Return a table sequence:

2

=demo.query("select NAME,ABBR from STATES").keys(NAME)

Return a table sequence:

3

=demo.query("select top 10 EID,NAME,DEPT,STATE from EMPLOYEE")

Return a table sequence:

4

>A3.switch(DEPT,A1:DEPT)

Convert A3’s DEPT field into the referencing field according to the corresponding value of A1’s key field DEPT.

5

>A3.switch(STATE,A2:NAME)

Convert A3’s STATE field into the referencing field according to the corresponding value of A2’s key field NAME; After A4 and A5 are successfully executed, A3’s sequence becomes this:

6

=A3.select@1(NAME=="Ashley")

Get the first record where NAME value is Ashley from A3:

7

=A6.nodes@r(EID,NAME)

Get records where both EID field and NAME field are single values and return them as a sequence.

8

=A6.nodes@r(DEPT,STATE)

Get records where both DEPT field and STATE field are single values and return them as a sequence:

9

=A6.nodes@r(DEPT)

Get the record where DEPT field is the single value and return it as a sequence:

10

=A3.nodes@r()

As parameter Fi is absent, traverse all fields of A3 to get records where all fields are single values and return them as a sequence: