Four sides of square: Difference between revisions

no edit summary
(Created Nim solution.)
imported>Maxima enthusiast
No edit summary
Line 952:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">Manipulate[ArrayPad[ConstantArray[0, {1, 1} n - 1], 1, 1] // Grid, {n, 2, 20, 1}]</syntaxhighlight>
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
/* Function that returns a square matrix with square pattern in their entries */
square(n):=genmatrix(lambda([x,y],if x=1 or y=1 or x=n or y=n then 1 else 0),n,n)$
 
/* Example */
square(6);
</syntaxhighlight>
{{out}}
<pre>
matrix(
[1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1]
)
</pre>
 
=={{header|Nim}}==