Instead of A[:,2,3,4:7] you can call slice(A,:,2,3,4:7) and it will drop scalar dimensions. That's available now, and in 0.4 it's fast.
The difference between what we have now and what we will have in the future is that A[...] will likely become an alias for slice(A,...). So, no need to lead a frustrated life. --Tim On Wednesday, April 16, 2014 12:54:59 PM Bob Nnamtrop wrote: > I completely agree with you and would love to see julia drop singleton > dimensions indexed with scalar. There is an issue on this with lots of > discussion, which was left at the point of waiting til someone implements > some code to give it a try (see > https://github.com/JuliaLang/julia/issues/5949). Maybe after 0.3 is > released there will be some action on this (I am willing to try myself but > it does seem like a hard 1st problem to deal with the julia internals). > IMO, there is some underlying tension in julia that revolves around people > who primarily use arrays as containers (who generally want this changed) > and those who use one and two dimensional arrays as a linear algebra system > (some of who do not want it implemented). I am firmly in the camp of using > arrays primarily as containers and, in addition to this issue, find it very > annoying that the elementwise operators are all are 2nd class citizens > (i.e., you must use .*, ./, .+, .-, etc). The fact that the 1st class > versions only work on a subset of arrays (i.e., those 1 and 2 dimensional) > seems like a poor design choice to me. But this is different to the > dripping dimensions indexed by scalars issue where there is still hope for > a change. > > As a practical version of your function example in your second email is the > plot command. You are plotting some slices from some higher dimensional > arrays, e.g. > > plot(x[2,3,7,:,9], y[2,3,7,:,9]) > > and you just want to get two one dimensional slices passed into plot with > no fuss. > > Bob > > On Wed, Apr 16, 2014 at 12:13 PM, Paweł Biernat <[email protected]>wrote: > > Adding a real life use case: > > > > x=[j+10*i for i=1:2, j=1:2] > > > > function f(x::Array{Int,1}) > > > > x > > > > end > > > > and then > > > > julia> f(x[1:2,1]) > > > > 2-element Array{Int64,1}: > > 11 > > 21 > > > > julia> f(x[1,1:2]) > > ERROR: no method f(Array{Int64,2})
