| Author |
Comment/Response |
Bill Simpson
|
05/30/12 4:02pm
1. Create a list to choose from by appending the next larger element to your previous list.
2. Randomly select any element from that list.
3. Append that selection to your old list.
4. Optionally sort the result
OR all wrapped up into a single line:
In[1]:= f[v_]:=Sort[Join[v,{Join[v,{Last[v]+1}][[RandomInteger,Length[v]+1]]}]];
A={1,2,3,4,5,6};
A=f[A]
Out[3]= {1,2,3,3,4,5,6}
In[4]:= A=f[A]
Out[4]= {1,2,3,3,4,5,6,7}
In[5]:= A=f[A]
Out[5]= {1,2,3,3,4,5,6,6,7}
In[6]:= A=f[A]
Out[6]= {1,2,3,3,4,5,6,6,7,8}
Take that function apart piece by piece until you understand how it was constructed and how it works.
URL: , |
|