Jump to content

Spiral matrix: Difference between revisions

m
→‎{{header|RPL}}: simplified code
m (→‎{{header|RPL}}: comments)
m (→‎{{header|RPL}}: simplified code)
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>
0 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

Cookies help us deliver our services. By using our services, you agree to our use of cookies.