Four sides of square: Difference between revisions

Created Nim solution.
(→‎See also: More to see also)
(Created Nim solution.)
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|Nim}}==
There are several ways to draw the square. Here is one of them:
<syntaxhighlight lang="Nim">import std/[sequtils, strutils]
 
proc drawSquare(n: Positive) =
let s1 = repeat(1, n).join(" ")
let s2 = (1 & repeat(0, n - 2) & 1).join(" ")
echo s1
for i in 2..<n: echo s2
echo s1
 
drawSquare(7)
</syntaxhighlight>
 
{{out}}
<pre>1 1 1 1 1 1 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 1 1 1 1 1 1
</pre>
 
=={{header|Perl}}==
256

edits