在朱莉娅,没有内置函数来汇总一组数字?
x = rand(10)
sum(x) # or sum(x, 1)
ERROR: MethodError: objects of type Float64 are not callable
Run Code Online (Sandbox Code Playgroud)
我的意思是我可以写一个for循环来总结如下,
sum = 0.0
for i in 1:length(x)
sum += x[i]
end
Run Code Online (Sandbox Code Playgroud)
但是如果朱莉娅没有把它建在某个地方,我只会感到惊讶吗?
julia ×1