Julia built in function for sum of array?

Viewed 20240

In Julia are there no built in functions to sum an array of numbers?

x = rand(10)
sum(x) # or sum(x, 1)

ERROR: MethodError: objects of type Float64 are not callable

I mean I could write a for loop to sum it as follows,

sum = 0.0    
for i in 1:length(x)
    sum += x[i]
end

but it just surprises me if julia don't have this built in somewhere?

2 Answers
Related