Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Scope with compounding expressions
ResourceFunction["CompoundScope"][{x=x0,y=y0,…},expr] specifies that all occurences of the symbols x,y,… in expr should be replaced by values x0,y0,… where each value can depend on all the previous values. | |
ResourceFunction["CompoundScope"][{x=x0,code,y=y0,…},expr] also evaluates code that may depend on previously assigned values. | |
ResourceFunction["CompoundScope"][x=x0;code;y=y0;…,expr] is the same as ResourceFunction["CompoundScope"][{x=x0,code,y=y0,…},expr]. | |
Evaluate an expression with x locally set to 7 and y to its square:
In[1]:= |
Out[1]= |
Echo an intermediate assigned value:
In[2]:= |
Out[2]= |
Use CompoundExpression instead of a List to separate assignments:
In[3]:= |
Out[3]= |
Use different scoping functions:
In[4]:= |
Out[4]= |
Using Module introduces module variables:
In[5]:= |
Out[5]= |
Standard scoping constructs do not allow values to depend on previously assigned values:
In[6]:= |
Out[6]= |
CompoundScope does compound assignments:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License