Mallas a partir de arreglos
Ahora en la versión 11 es fácil generar tetrominós de color y construir tableros de ajedrez o formas geométricas arbitrarias a partir de patrones .
In[1]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_5.png)
arrays = {\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "0", "0", "0"},
{"1", "0", "0", "0"},
{"1", "0", "0", "0"},
{"1", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), \!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "1", "0", "0"},
{"0", "1", "0", "0"},
{"0", "1", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), \!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "1", "0", "0"},
{"1", "0", "0", "0"},
{"1", "0", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), \!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", "1", "0", "0"},
{"1", "1", "0", "0"},
{"0", "1", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\),
\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "0", "0", "0"},
{"1", "1", "0", "0"},
{"0", "1", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), \!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "1", "0", "0"},
{"1", "1", "0", "0"},
{"0", "0", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), \!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "1", "0", "0"},
{"0", "1", "1", "0"},
{"0", "0", "0", "0"},
{"0", "0", "0", "0"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {},
"ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\)};
In[2]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_6.png)
col = ColorData[97, "ColorList"];
In[3]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_7.png)
Table[ArrayMesh[arrays[[i]], MeshCellStyle -> {2 -> col[[i]]}], {i,
7}]
Out[3]=
![](assets.es/mesh-from-arrays/O_7.png)
Construya un tablero de ajedrez en 3D.
In[4]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_8.png)
m = Join @@
ConstantArray[{{{0}, {1}, {0}, {1}, {0}, {1}, {0}, {1}}, {{1}, \
{0}, {1}, {0}, {1}, {0}, {1}, {0}}}, 4];
In[5]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_9.png)
p = First /@ Position[Flatten[m], 1];
In[6]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_10.png)
style = {{1, All} -> {Thick, Black}, {3, All} ->
White, {3, #} & /@ p -> Black};
In[7]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_11.png)
r = ArrayMesh[ConstantArray[1, {8, 8, 1}], MeshCellStyle -> style]
Out[7]=
![](assets.es/mesh-from-arrays/O_8.png)
Construya una malla de Seidel, una región con túneles que van en toda dirección sin cruzarse.
muestre la entrada completa de Wolfram Language
In[9]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_13.png)
transparentMesh[ArrayMesh[seidelArray[{2, 2, 2}]]]
Out[9]=
![](assets.es/mesh-from-arrays/O_9.png)
Implemente el Juego de la Vida de Conway.
In[10]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_14.png)
gameOfLife = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}};
board = RandomInteger[1, {40, 40}];
In[11]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_15.png)
sim = NestList[Last[CellularAutomaton[gameOfLife, #, {{0, 1}}]] &,
board, 70];
In[12]:=
![Click for copyable input](assets.es/mesh-from-arrays/In_16.png)
ListAnimate[ArrayMesh /@ sim]
Out[12]=
![](assets.es/index.es/Flash_1.png)