Wolfram 语言

核心语言

代换系统

SubstitutionSystem 生成表示给定初始状态和按照基本规则迭代应用的演变的列表.

以下为初始状态和基本规则.

In[1]:=
Click for copyable input
init = "\[Wolf]"; rules = {"\[HappySmiley]" -> "\[Wolf]\[HappySmiley]", "\[Wolf]" -> "\[HappySmiley]"};

SubstitutionSystem 获取 8 个迭代后的演变.

In[2]:=
Click for copyable input
SubstitutionSystem[{"\[HappySmiley]" -> "\[Wolf]\[HappySmiley]", "\[Wolf]" -> "\[HappySmiley]"}, "\[Wolf]", 8] // Column
Out[2]=

用二维基本规则构建谢尔宾斯基地毯(Sierpiński carpet).

In[3]:=
Click for copyable input
rules2D = {1 -> {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, 0 -> ConstantArray[0, {3, 3}]};

RulePlot 可视化该代换系统.

In[4]:=
Click for copyable input
RulePlot@SubstitutionSystem[rules2D]
Out[4]=

生成谢尔宾斯基地毯.

In[5]:=
Click for copyable input
ArrayPlot /@ SubstitutionSystem[rules2D, {{1}}, 5]
Out[5]=

相关范例

de en es fr ja ko pt-br ru