| Frühere | Chronologischer Index | Spätere | ||
| Vorherige | Thematischer Index | Nächste |
Liebe Freundinnen und Freunde von Kleinstspielereien,man fertige einen Einzeiler cantorD[], der die nullbasierte Cantornummerierung eines zweidimensionalen Arrays herstellt sowie als weiteren Einzeiler die inverse Abbildung cantorInverseD[] von cantorD[]:
In[7]:= cantorD /@ Range[0, 20]
Out[7]= {{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2,
1}, {1, 2}, {0, 3}, {0, 4}, {1, 3}, {2, 2}, {3, 1}, {4, 0}, {5,
0}, {4, 1}, {3, 2}, {2, 3}, {1, 4}, {0, 5}}
In[8]:= cantorD[#, 1] & /@ Range[0, 20]
Out[8]= {{0, 0}, {0, 1}, {1, 0}, {2, 0}, {1, 1}, {0, 2}, {0, 3}, {1,
2}, {2, 1}, {3, 0}, {4, 0}, {3, 1}, {2, 2}, {1, 3}, {0, 4}, {0,
5}, {1, 4}, {2, 3}, {3, 2}, {4, 1}, {5, 0}}
In[9]:= cantorD[#, 1] & /@ Range[0, 20] ==
Reverse /@ cantorD /@ Range[0, 20]
Out[9]= True
In[12]:= cantorD[2009]
Out[12]= {56, 6}
In[13]:= cantorInverseD[{56, 6}]
Out[13]= 2009
In[10]:= cantorInverseD /@ (cantorD /@ Range[0, 15008]) ==
Range[0, 15008]
Out[10]= True
und
In[11]:= GraphicsGrid[{{
Graphics[
Style[Arrow[#, 0.1] & /@
Partition[cantorD[#, 1] & /@ Range[0, 45], 2, 1], Blue],
Frame -> True],
Graphics[
Style[Arrow[#, 0.1] & /@
Partition[cantorD /@ Range[0, 45], 2, 1], Red], Frame -> True]
}}]
gibt das Bildchen im Anhang.
Mit den besten Gruessen
Udo.
cantorDV.jpeg
Description: JPEG image
| Frühere | Chronologischer Index | Spätere | ||
| Vorherige | Thematischer Index | Nächste |
DMUG-Archiv, http://www.mathematica.ch/archiv.html