Function Repository Resource:

UnionTo

Source Notebook

Equivalent to Union but redefines the first argument to the result

Contributed by: Taliesin Beynon (Wolfram Research)

ResourceFunction["UnionTo"][s,l]

sets the value of s to be a union of the elements of s and l.

ResourceFunction["UnionTo"][s,l1,l2,]

sets the value of s to be a union of the elements of s and all the li.

Details and Options

The heads of s and all the ls must match, but need not be List.

Examples

Basic Examples (5) 

Assign a list to l:

In[1]:=
l = {x}
Out[1]=

Join elements to a list:

In[2]:=
ResourceFunction["UnionTo"][l, {y, x}]
Out[2]=

Ask for the elements in a list:

In[3]:=
l
Out[3]=

Add more elements:

In[4]:=
ResourceFunction["UnionTo"][l, {z, y}]
Out[4]=

Add more lists:

In[5]:=
ResourceFunction["UnionTo"][l, {r, t}, {}, {r, z}]
Out[5]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 14 February 2019

License Information