Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `∪ Union`
[ Previous | Next | Contents | Index | APL Home ]

# `∪` Union

Union returns all items which can be found in both the left and right arguments. The right argument can be of any shape or rank. The left argument must be a scalar or vector. The result is always a vector.

The result first contains all the items in the left argument (in the order in which they appear), followed by all the items found in the right argument but not in the left argument. If a particular item appears more than once in the left argument, it will also appear more than once in the result. Equally, if a particular item does not appear in the left argument, but does appear multiple times in the right argument, it will appear multiple times in the result.

This operation is affected by `⎕CT`, the comparison tolerance.

```       'THE QUALITY OF MERCY IS NOT STRAINED'∪'HIP HOP DOWN TO THE ZOO'
THE QUALITY OF MERCY IS NOT STRAINEDPPWZ

1 4 17 23 12 2 7 99 33∪¯1 4 17 99 100 101
1 4 17 23 12 2 7 99 33 ¯1 100 101

'THIS' 'THAT' 'THE' 'OTHER'∪'OTHER' 'THAN' 'THIS' 'AND' 'THAT'
THIS THAT THE OTHER THAN AND

⎕display (23 43 21) (⍳5) (2 2⍴'BLOT') ∪ (⍳5) ('BLOT')
┌→───────────────────────────────────┐
│ ┌→───────┐ ┌→────────┐ ┌→─┐ ┌→───┐ │
│ │23 43 21│ │1 2 3 4 5│ ↓BL│ │BLOT│ │
│ └~───────┘ └~────────┘ │OT│ └────┘ │
│                        └──┘        │
└∊───────────────────────────────────┘

```

See also the other 'set' operations: `∪` Unique, `~` Without and `∩` Intersection.

Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `∪ Union`
[ Previous | Next | Contents | Index | APL Home ]