JuliaArrays / JuliaArrays/StaticArrays.jl
Length inferred a[3:end]?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
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)])?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing StaticArrays.jl's existing indexing behavior, including the SOneTo example in the issue. Determine whether an established idiom already provides a statically sized result or whether a new API is warranted; done requires a settled approach and an agreed scope for implementation and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100