Flatten a list: Difference between revisions

RPL: add section
(Better code example)
(RPL: add section)
Line 3,474:
<pre>
"1, 2, 3, 4, 5, 6, 7, 8"
</pre>
 
=={{header|RPL}}==
Soberly recursive.
{{works with|Halcyon Calc|4.2.7}}
≪ '''IF''' DUP SIZE '''THEN'''
{ } 1 LAST '''FOR''' j
OVER j GET
'''IF''' DUP TYPE 5 == '''THEN FLATL END'''
+ '''NEXT'''
SWAP DROP '''END'''
≫ ‘'''FLATL'''’ STO
{{1} 2 {{3 4} 5} {{{}}} {{{6}}} 7 8 {}} '''FLATL'''
{{out}}
<pre>
1: { 1 2 3 4 5 6 7 8 }
</pre>
 
1,150

edits