On Tuesday, December 01, 2015 03:19:33 PM Eric Forgy wrote:
> A scalar is distinct from a vector so size(a) = () makes sense. getindex for
> a scalar does not make sense and should probably be removed on the grounds
> of mathematical elegance :) Any code that depends on referencing a scalar
> via an index is probably flawed in the first place.

Conversely, there are many people who seem to want Julia to treat scalars and 
1-vectors indistinguishably (ala Matlab).

For what it's worth, here's a (contrived) example to justify the current 
behavior:

function sum_over_dims(A, dims)
    for d in dims
        A = sum(A, d)
    end
    A
end

sum_over_dims(A, [2,3])
sum_over_dims(A, 2)

Why should I write sum_over_dims(A, [2]) in the latter case?

Best,
--Tim

Reply via email to