Skip to content

Length inferred a[3:end]? #824

Open
Open
@dlfivefifty

Description

@dlfivefifty

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

No one assigned

    Labels

    arraysAbstractArray interface and array operationsfeaturefeatures and feature requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions