Last list item: Difference between revisions

m
→‎{{header|Julia}}: bang function
(julia example)
m (→‎{{header|Julia}}: bang function)
Line 313:
<lang julia>list = [6, 81, 243, 14, 25, 49, 123, 69, 11]
 
function addleastreduce!(lis)
while length(lis) > 1
push!(lis, popat!(lis, last(findmin(lis))) + popat!(lis, last(findmin(lis))))
Line 320:
end
 
@show list, addleastreduce!(copy(list)) # (list, addleastreduce!(copy(list))) = ([6, 81, 243, 14, 25, 49, 123, 69, 11], [621])
</lang>
 
4,102

edits