Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sum with a reduce
let nums = [1, 2, 3, 6, 16, 4]
let reducer: (Int, Int) -> Int = { (sum, increment) in
sum + increment
let sum = nums.reduce(0, reducer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment