2015-05-11 6 views

risposta

3

Non ancora, ma puoi aiutare te stesso se vuoi.

import Base.getindex, Base.setindex! 
    const .. = Val{:...} 

    setindex!{T}(A::AbstractArray{T,1}, x, ::Type{Val{:...}}, n) = A[n] = x 
    setindex!{T}(A::AbstractArray{T,2}, x, ::Type{Val{:...}}, n) = A[ :, n] = x 
    setindex!{T}(A::AbstractArray{T,3}, x, ::Type{Val{:...}}, n) = A[ :, :, n] =x 

    getindex{T}(A::AbstractArray{T,1}, ::Type{Val{:...}}, n) = A[n] 
    getindex{T}(A::AbstractArray{T,2}, ::Type{Val{:...}}, n) = A[ :, n] 
    getindex{T}(A::AbstractArray{T,3}, ::Type{Val{:...}}, n) = A[ :, :, n] 

Poi si può scrivere

> rand(3,3,3)[.., 1] 
    3x3 Array{Float64,2}: 
    0.0750793 0.490528 0.273044 
    0.470398 0.461376 0.01372 
    0.311559 0.879684 0.531157 

Se volete più elaborato affettare, è necessario generare/ampliare la definizione o l'uso funzioni in scena.

+1

e c'è più discussione (inc da voi) sul problema github: https://github.com/JuliaLang/julia/issues/5405 – paddyg