BoundsError using reduce function (Julia 1.3.1)

This does what you want:

reduce((x, y) -> x + y[2], a, init = 0.0)

To better understand what was going on in your example, try

reduce((x, y) -> (@show x y; x[1] + y[1]), a)
3 Likes