Last list item: Difference between revisions

No edit summary
Line 651:
(list, addleastreduce!(copy(list))) = ([6, 81, 243, 14, 25, 49, 123, 69, 11], [621])
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
===With and without sorting===
<lang Mathematica>list = {6, 81, 243, 14, 25, 49, 123, 69, 11};
 
Print[list]
Do[
poss = Ordering[list, 2];
extr = Extract[list, List /@ poss];
extr //= Total;
list = Delete[list, List /@ poss];
AppendTo[list, extr];
Print[list]
,
{Length[list] - 1}
]</lang>
{{out}}
<pre>{6,81,243,14,25,49,123,69,11}
{81,243,14,25,49,123,69,17}
{81,243,25,49,123,69,31}
{81,243,49,123,69,56}
{81,243,123,69,105}
{243,123,105,150}
{243,150,228}
{243,378}
{621}</pre>
 
=={{header|Nim}}==
1,111

edits