Add the values in a list
Add every item once. Repeated values still count each time they occur.
sum
Simple example
Add one, two and three.
Start1 · 2 · 3
Result6
function main()
values = [1, 2, 3]
println(sum(values))
end
main()
6
Advertisements
Everyday examples
Add the three amounts on a receipt.
Start5 · 5 · 8
Result18
function main()
values = [5, 5, 8]
println(sum(values))
end
main()
18
How many passengers boarded at the three stops?
Start2 · 7 · 1
Result10
function main()
values = [2, 7, 1]
println(sum(values))
end
main()
10
How many exercise books arrived in three boxes?
Start10 · 8 · 9
Result27
function main()
values = [10, 8, 9]
println(sum(values))
end
main()
27