ReplaceList
Usage
Notes
Further Examples
Replace returns the first possible result obtained by applying a rule.
In[1]:=
|
Out[1]=
|
If a single rule can be applied in several ways, ReplaceList gives a list of all possible results.
In[2]:=
|
Out[2]=
|
ReplaceList gives a list of all possible results from each rule that applies.
In[3]:=
|
Out[3]=
|
Here only the first results are given.
In[4]:=
|
Out[4]=
|
The defined function ReplaceAllList extends ReplaceList to also work on all subexpressions.
In[5]:=
|
In[6]:=
|
Out[6]=
|
In[7]:=
|
Out[7]=
|
Here is a function that returns all permutations of the list {1, 1, 2, 2, ... , n, n}, such that there is 1 number between the two occurrences of 1, 2 numbers between the two occurrences of 2,... and n numbers between the two occurrences of n.
In[8]:=
|
In[9]:=
|
Out[9]=
|
In[10]:=
|
|