listunion/3—determine the union of two lists

The listunion/3 operation determines the union of two  lists. The syntax for this function is as follows:

listunion($LIST1,$LIST2,$LIST)
$LIST=listunion($LIST1,$LIST2)

listunion/3 arguments

Argument

Mode

Type

Description

$LIST1

Input

LIST_OF ANY

Specifies the first list to be compared

$LIST2

Input

LIST_OF ANY

Specifies the second list to be compared with the first list

$LIST

Output

LIST_OF ANY

Union of the two lists

Use the listunion/3 operation to construct a new list $LIST, which is the union of lists $LIST1 and $LIST2. The union of $LIST1 and $LIST2 will include all the elements of the two lists. If there are elements duplicated between the two lists, the duplicated elements will be listed only once in $LIST. If there are elements duplicated within a single list, those elements will be duplicated in the resulting list.

 Consider the following example. The union of these two list ($LIST1 and $LIST2)is shown in the figure 2.

$LIST1=[a,b,a,c]
$LIST2=[b,d,e,e]

The union of the previously two lists:

$LIST=[a,b,a,c,d,e,e]
  • $LIST contains two a characters because $LIST1 has two a characters. 
  • $LIST contains two e characters because $LIST2 has two e characters. 
  • $LIST contains only one b because there is one b in $LIST1 and one b in $LIST2.

listunion/3 example

$MY_BAD_SLOTS=listunion($E.mc_bad_slot_names,[my_slot1,my_slot2]);
Was this page helpful? Yes No Submitting... Thank you

Comments