Mosaic matrix: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|RPL}}: slightly optimized)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(2 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'''
'''NEXT NEXT'''
≫ ≫ '<span style="color:blue">'''MOZTX'''</span>' STO
 
Line 1,450 ⟶ 1,465:
[ 0 1 0 1 ]]
</pre>
'''AnotherFilling approachthe stack'''
 
The 1-0-1-.. sequence is created in the stack, then converted into a matrix.
« → n
« 1 n '''FOR''' j
Line 1,460 ⟶ 1,473:
n DUP 2 →LIST →ARRY
» » '<span style="color:blue">'''MOZTX'''</span>' STO
'''Direct approach'''
Latest RPL versions can do it even shorter:
 
Latest RPL versions have a specific instruction to generate a matrix ruled by a formula.
≪ DUP 'NOT(I+J) MOD 2' LCXM →NUM ≫ '<span style="color:blue">'''MOZTX'''</span>' STO
 
Line 1,491 ⟶ 1,506:
=={{header|Wren}}==
===Text based===
<syntaxhighlight lang="ecmascriptwren">var mosaicMatrix = Fn.new { |n|
for (i in 0...n) {
for (j in 0...n) {
Line 1,517 ⟶ 1,532:
{{libheader|DOME}}
{{libheader|Go-fonts}}
<syntaxhighlight lang="ecmascriptwren">import "dome" for Window
import "graphics" for Canvas, Color, Font, ImageData
 
9,476

edits