Shift list elements to left by 3: Difference between revisions
Shift list elements to left by 3 (view source)
Revision as of 07:46, 7 September 2023
, 9 months ago→{{header|RPL}}: by list reversing
imported>Maxima enthusiast No edit summary |
(→{{header|RPL}}: by list reversing) |
||
Line 1,664:
=={{header|RPL}}==
====Using the stack (idiomatic)====
≪ LIST→ → size
≪ <span style="color:red">1 3</span> '''START''' size ROLL '''NEXT'''
size →LIST
≫ ≫ '<span style="color:blue">SLL3</span>' STO
====Following ''Programming Pearls''' Problem B algorithm====
{ 1 2 3 4 5 6 7 8 } SLL3▼
{{works with|HP|48G}}
≪ <span style="color:red">3</span> DUP2 <span style="color:red">1</span> SWAP SUB REVLIST
ROT ROT <span style="color:red">1</span> + OVER SIZE SUB REVLIST
+ REVLIST
≫ ‘<span style="color:blue">SLL3</span>’ STO
▲ { 1 2 3 4 5 6 7 8 } <span style="color:blue">SLL3</span>
{{out}}
<pre>
|