Wolfram Research

Function Repository Resource:

JoinTo

Source Notebook

Equivalent to Join, but redefines the first argument to the result

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["JoinTo"][expr,list1,list2,]

equivalent to Join[expr,list1,list2,] but sets expr to the result.

ResourceFunction["JoinTo"][expr,list1,list2,,n]

joins the objects at level n in each of the expr,list1,list2,.

Details and Options

The listi and expr do not need to have the head List, but they must all have the same head.

Examples

Basic Examples

Join some lists:

In[1]:=
expr = {a, b, c};
ResourceFunction["JoinTo"][expr, {x, y}, {u, v, w}]
Out[2]=

The value of expr has changed:

In[3]:=
expr
Out[3]=

JoinTo works with associations:

In[4]:=
assoc = <|"a" -> 1|>;
ResourceFunction["JoinTo"][assoc, <|"b" -> 2, "c" -> 3|>]
Out[5]=
In[6]:=
assoc
Out[6]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information