Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Swap values of symbols using a temporary variable
ResourceFunction["SwapSymbolValues"][x,y] swaps the values of symbols x and y. |
Swap values:
In[1]:= | ![]() |
In[2]:= | ![]() |
Out[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
You cannot reassign raw objects:
In[4]:= | ![]() |
Out[4]= | ![]() |
Use symbols to swap their values:
In[5]:= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License