A .union()

Read(489) Label: sequence, union,

Description:

Compute the union of sequence-type members in a sequence.

Synatax:

 A.union()

Note:

The function computes the union of sequence-type members in sequence A so as to get a sequence in which identical members won’t appear repeatedly. Duplicate members in the same sub-sequence will be retained. 

Parameters:

A

A sequence whose members are sequences

Return value:

A new sequence created through the union of members of sequence A

Example:

 

A

 

1

=[[1,2,3,4,5],[3,7,8]].union()

[1,2,3,4,5,7,8] “3” only appears once

2

=[[1,2,2],[3,4,4],4].union()

[1,2,2,3,4,4] The duplicate “4” is stripped out. Identical members in the same sub-sequence are not regarded as duplicate ones

3

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

[1,2,2,2,3] There are three “2s” in the second sub-sequence, so the final result also include three “2s”

Related functions:

A.conj()

A.diff()

A.isect()

A.xunion()