Spiral matrix: Difference between revisions

m
m (→‎{{header|RPL}}: comments)
 
(One intermediate revision by the same user not shown)
Line 4,922:
{{works with|RPL|HP48-R}}
« { 0 1 } → n step
« { 1 1 } n DUP 2 →LIST -1 CON <span style="color:grey">@ empty cell = -1</span>
01 n SQ 1 - '''FOR''' j
OVER j PUT
DUP2 SWAP step ADD
'''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 EVALREVLIST R→C{ 1 (0,-1) *} C→R 2 →LIST* 'step' STO '''END''' <span style="color:grey">@ then turn right</span>
SWAP step ADD SWAP
'''NEXT'''
1,150

edits