REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: union

union  set1  set2  /case  /skip  size

Returns the union of two data sets.


set1 [block! string! binary! bitset! typeset!] - first set

set2 [block! string! binary! bitset! typeset!] - second set


/case - Use case-sensitive comparison

/skip - Treat the series as records of fixed size

size [integer!]

See also:

difference   intersect   exclude   unique  


Returns all elements present within two blocks or strings ignoring the duplicates.

lunch: [ham cheese bread carrot]
dinner: [ham salad carrot rice]
probe union lunch dinner
[ham cheese bread carrot salad rice]
probe sort union [1 3 2 4] [3 5 4 6]
[1 2 3 4 5 6]
string1: "CBDA"    ; A B C D scrambled
string2: "EDCF"    ; C D E F scrambled
probe sort union string1 string2
items: [1 1 2 3 2 4 5 1 2]
probe union items items  ; get unique set
[1 2 3 4 5]
str: "abcacbaabcca"
probe union str str

To obtain a unique set (to remove duplicate values) you can use UNIQUE.

Note that performing this function over very large data sets can be CPU intensive.

  TOC < Back Next > - WIP Wiki Feedback Admin