Mosaic matrix: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
mNo edit summary |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 925:
1 0 1 0 1
</syntaxhighlight>
=={{header|K}}==
K6
<syntaxhighlight lang="k">mosaic: {x=/:x}2!!:
mosaic 6</syntaxhighlight>
{{out}}
<pre>(1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1)</pre>
=={{header|Maxima}}==
Line 1,435 ⟶ 1,448:
=={{header|RPL}}==
'''Filling a matrix'''
≪ → n
≪ n DUP 2 →LIST 0 CON
1 n '''FOR''' r
1 n '''FOR''' c
r c 2 →LIST r c + 2 MOD NOT PUT
'''NEXT NEXT'''
≫ ≫
4 <span style="color:blue">'''MOZTX'''</span>
Line 1,450 ⟶ 1,465:
[ 0 1 0 1 ]]
</pre>
'''Filling the stack'''
« → n
≪ DUP 2 →LIST DUP 0 CON SWAP SIGN '''DO''' DUP ∑LIST 2 MOD NOT PUTI '''UNTIL''' -64 FS? '''END''' DROP ≫ ‘<span style="color:blue">'''MOZTX'''</span>’ STO▼
« 1 n '''FOR''' j
j 2 MOD
≪ DUP 'NOT(I+J)MOD 2' LCXM →NUM ≫ ‘<span style="color:blue">'''MOZTX'''</span>’ STO▼
2 n '''START''' DUP NOT '''NEXT'''
'''NEXT'''
n DUP 2 →LIST →ARRY
'''Direct approach'''
Latest RPL versions have a specific instruction to generate a matrix ruled by a formula.
▲ ≪ DUP
=={{header|Sidef}}==
Line 1,483 ⟶ 1,506:
=={{header|Wren}}==
===Text based===
<syntaxhighlight lang="
for (i in 0...n) {
for (j in 0...n) {
Line 1,509 ⟶ 1,532:
{{libheader|DOME}}
{{libheader|Go-fonts}}
<syntaxhighlight lang="
import "graphics" for Canvas, Color, Font, ImageData
|