Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for prevind/nextind on tuples and arrays is missing #42084

Closed
Seelengrab opened this issue Sep 1, 2021 · 1 comment · Fixed by #52658
Closed

Documentation for prevind/nextind on tuples and arrays is missing #42084

Seelengrab opened this issue Sep 1, 2021 · 1 comment · Fixed by #52658
Labels
domain:docs This change adds or pertains to documentation

Comments

@Seelengrab
Copy link
Contributor

Seelengrab commented Sep 1, 2021

Currently only prevind(::AbstractString, i::Integer, n::Integer=1) -> Int is documented, but quite a few more methods exist:

julia> methods(prevind)                                                                                             
# 8 methods for generic function "prevind":                                                                         
[1] prevind(t::Tuple, i::Integer) in Base at tuple.jl:74                                                            
[2] prevind(::AbstractArray, i::Integer) in Base at abstractarray.jl:183                                            
[3] prevind(t::NamedTuple, i::Integer) in Base at namedtuple.jl:135                                                 
[4] prevind(s::AbstractString, i::Int64) in Base at strings/basic.jl:494                                            
[5] prevind(s::AbstractString, i::Int64, n::Int64) in Base at strings/basic.jl:496                                  
[6] prevind(s::AbstractString, i::Integer) in Base at strings/basic.jl:493                                          
[7] prevind(s::AbstractString, i::Integer, n::Integer) in Base at strings/basic.jl:492                              
[8] prevind(a::AbstractArray{<:Any, N}, i::CartesianIndex{N}) where N in Base.IteratorsMD at multidimensional.jl:158

These are generic enough to be documented as well, no? It's the most generic way to the get previous index of any abstract vector (though the default implementation assumes Integers are used for indexing).

The same applies to nextind - both were added for NamedTuples in #37932

@Seelengrab Seelengrab changed the title Documentation for prevind on tuples and arrays is missing Documentation for prevind/nextind on tuples and arrays is missing Sep 1, 2021
@stevengj stevengj added the domain:docs This change adds or pertains to documentation label Sep 7, 2021
@aplavin
Copy link
Contributor

aplavin commented Mar 22, 2023

Also, nextind(A, i::Integer, n::Integer=1) methods would be nice for all supported types. Currently, 3-arg only works for strings, while vectors and tuples only have 2-arg (without n)`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
3 participants