Mosaic matrix: Difference between revisions

m
→‎{{header|RPL}}: formatted layout
(→‎K: add)
m (→‎{{header|RPL}}: formatted layout)
Line 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,463 ⟶ 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,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
 
1,150

edits