Matrix with two diagonals: Difference between revisions

Content added Content deleted
(Added Sidef)
(Added Arturo implementation)
Line 330: Line 330:
0 1 0 0 0 0 1 0
0 1 0 0 0 0 1 0
1 0 0 0 0 0 0 1</pre>
1 0 0 0 0 0 0 1</pre>

=={{header|Arturo}}==

<lang rebol>drawSquare: function [side][
loop 1..side 'x ->
print map 1..side 'y [
(any? @[x=y side=x+y-1])? -> 1 -> 0
]
]

drawSquare 6
print ""
drawSquare 9</lang>

{{out}}

<pre>1 0 0 0 0 1
0 1 0 0 1 0
0 0 1 1 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1

1 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 1 0 0
0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0
0 0 1 0 0 0 1 0 0
0 1 0 0 0 0 0 1 0
1 0 0 0 0 0 0 0 1</pre>


=={{header|AWK}}==
=={{header|AWK}}==
Line 365: Line 397:
1 0 0 0 0 0 1
1 0 0 0 0 0 1
</pre>
</pre>

=={{header|Basic}}==
=={{header|Basic}}==
<lang qbasic>100 REM
<lang qbasic>100 REM