Spiral matrix: Difference between revisions
Content added Content deleted
(added RPL) |
m (→{{header|RPL}}: comments) |
||
Line 4,922: | Line 4,922: | ||
{{works with|RPL|HP48-R}} |
{{works with|RPL|HP48-R}} |
||
« { 0 1 } → n step |
« { 0 1 } → n step |
||
« { 1 1 } n DUP 2 →LIST -1 CON |
« { 1 1 } n DUP 2 →LIST -1 CON <span style="color:grey">@ empty cell = -1</span> |
||
0 n SQ 1 - '''FOR''' j |
0 n SQ 1 - '''FOR''' j |
||
OVER j PUT |
OVER j PUT |
||
DUP2 SWAP step ADD |
DUP2 SWAP step ADD |
||
'''IF IFERR''' GET '''THEN''' DROP2 1 '''ELSE''' -1 ≠ '''END''' |
'''IF IFERR''' GET '''THEN''' DROP2 1 '''ELSE''' -1 ≠ '''END''' <span style="color:grey">@ if next step is out of border or an already written cell</span> |
||
'''THEN''' step EVAL R→C (0,-1) * C→R 2 →LIST 'step' STO '''END''' |
'''THEN''' step EVAL R→C (0,-1) * C→R 2 →LIST 'step' STO '''END''' <span style="color:grey">@ then turn right</span> |
||
SWAP step ADD SWAP |
SWAP step ADD SWAP |
||
'''NEXT''' |
'''NEXT''' |