-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
arraysAbstractArray interface and array operationsAbstractArray interface and array operationsfeaturefeatures and feature requestsfeatures and feature requests
Description
I'm wishing to do things like a[3:end]
but have it return an SVector
. I found a way to do this:
julia> a = SVector(1,2,3,4)
4-element SArray{Tuple{4},Int64,1,4} with indices SOneTo(4):
1
2
3
4
julia> a[3:end] # Length not inferred
2-element Array{Int64,1}:
3
4
julia> reverse(reverse(a)[SOneTo(2)]) # Length inferred
2-element SArray{Tuple{2},Int64,1,2} with indices SOneTo(2):
3
4
Is there an establish idiom for this? Would it be worth adding this to the package say as a special type (a[SToEnd(3)]
)?
Metadata
Metadata
Assignees
Labels
arraysAbstractArray interface and array operationsAbstractArray interface and array operationsfeaturefeatures and feature requestsfeatures and feature requests