|
Further Examples: Apply (@@)
This substitutes New for Old at the head of the expression using the shorthand notation for Apply. (Neither New nor Old has a built-in meaning in Mathematica.)
In[1]:= 
Out[1]= 
This is the same thing.
In[2]:= 
Out[2]= 
The head of a product is Times.
In[3]:= 
Out[3]= 
The head of a list is List.
In[4]:= 
Out[4]= 
You can see heads explicitly using FullForm.
In[5]:= 
Out[5]//FullForm= 
In[6]:= 
Out[6]//FullForm= 
This substitutes Times for List.
In[7]:= 
Out[7]= 
This changes a line into a polygon.
In[8]:= 
Out[8]= 
This constructs a list of circles from a list of pairs of centers and radii.
In[9]:= 
Out[9]= 
Here is another way to write the previous expression.
In[10]:= 
Out[10]= 
Here, Apply replaces heads in subexpressions at level .
In[11]:= 
Out[11]= 
Here is a list.
In[12]:= 
This defines a function ff that permutes mm.
In[13]:= 
The permutation can be written as a list of ordered pairs.
In[14]:= 
Out[14]= 
Another way to write the permutation is as a list of rules.
In[15]:= 
Out[15]= 
These rules can be represented more compactly as a list of cycles.
In[16]:= 
This defines the function CyclesfromRules that finds all cycles from a list of rules.
In[17]:= 
In[18]:= 
In[19]:= 
Here are the cycles of ff using CyclesfromRules.
In[20]:= 
Out[20]= 
In[21]:= 
|