Last list item: Difference between revisions

Added 11l
(ALGOL 68 →‎With sorting: Use new ALGOL 68-rows library)
(Added 11l)
Line 8:
<br>Show the unsorted list in output in case "Without sort"
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F add_least_reduce(&lis)
L lis.len > 1
V el1 = lis.pop(lis.index(min(lis)))
V el2 = lis.pop(lis.index(min(lis)))
lis.append(el1 + el2)
print(‘Interim list: ’lis)
R lis
 
V LIST = [6, 81, 243, 14, 25, 49, 123, 69, 11]
 
print(LIST‘ ==> ’add_least_reduce(&copy(LIST)))</lang>
 
{{out}}
<pre>
Interim list: [81, 243, 14, 25, 49, 123, 69, 17]
Interim list: [81, 243, 25, 49, 123, 69, 31]
Interim list: [81, 243, 49, 123, 69, 56]
Interim list: [81, 243, 123, 69, 105]
Interim list: [243, 123, 105, 150]
Interim list: [243, 150, 228]
Interim list: [243, 378]
Interim list: [621]
[6, 81, 243, 14, 25, 49, 123, 69, 11] ==> [621]
</pre>
 
=={{header|ALGOL 68}}==
1,480

edits