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

Define nextind(x, i::Integer) or document existing methods #54870

Closed
jariji opened this issue Jun 20, 2024 · 1 comment
Closed

Define nextind(x, i::Integer) or document existing methods #54870

jariji opened this issue Jun 20, 2024 · 1 comment

Comments

@jariji
Copy link
Contributor

jariji commented Jun 20, 2024

nextind has a bunch of methods, only the AbstractString one is documented. I think a generic nextind(x, i::Integer) would be good. If that's not accepted, at least the existing methods should be documented.

julia> methods(nextind)
# 13 methods for generic function "nextind" from Base:
  [1] nextind(source::JuliaSyntax.SourceFile, i::Integer)
     @ JuliaSyntax ~/.julia/packages/JuliaSyntax/eqCSU/src/source_files.jl:127
  [2] nextind(source::Base.JuliaSyntax.SourceFile, i::Integer)
     @ Base.JuliaSyntax /cache/build/builder-amdci4-6/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/source_files.jl:127
  [3] nextind(s::String, i::Int64)
     @ strings/string.jl:171
  [4] nextind(s::SubString{String}, i::Int64)
     @ strings/substring.jl:104
  [5] nextind(s::AbstractString, i::Int64, n::Int64)
     @ strings/basic.jl:558
  [6] nextind(s::AbstractString, i::Integer, n::Integer)
     @ strings/basic.jl:554
  [7] nextind(s::AbstractString, i::Int64)
     @ strings/basic.jl:556
  [8] nextind(s::AbstractString, i::Integer)
     @ strings/basic.jl:555
  [9] nextind(::OrderedCollections.OrderedSet, i::Int64)
     @ OrderedCollections ~/.julia/packages/OrderedCollections/9C4Uz/src/ordered_set.jl:105
 [10] nextind(a::AbstractArray{<:Any, N}, i::CartesianIndex{N}) where N
     @ Base.IteratorsMD multidimensional.jl:149
 [11] nextind(::AbstractArray, i::Integer)
     @ abstractarray.jl:213
 [12] nextind(t::Tuple, i::Integer)
     @ tuple.jl:78
 [13] nextind(t::NamedTuple, i::Integer)
     @ namedtuple.jl:181

help?> nextind
search: nextind IndexCartesian MissingException current_exceptions InterruptException InvalidStateException

  nextind(str::AbstractString, i::Integer, n::Integer=1) -> Int


    •  Case n == 1
       If i is in bounds in s return the index of the start of the character whose encoding starts after index
       i. In other words, if i is the start of a character, return the start of the next character; if i is
       not the start of a character, move forward until the start of a character and return that index. If i
       is equal to 0 return 1. If i is in bounds but greater or equal to lastindex(str) return
       ncodeunits(str)+1. Otherwise throw BoundsError.

    •  Case n > 1
       Behaves like applying n times nextind for n==1. The only difference is that if n is so large that
       applying nextind would reach ncodeunits(str)+1 then each remaining iteration increases the returned
       value by 1. This means that in this case nextind can return a value greater than ncodeunits(str)+1.

    •  Case n == 0
       Return i only if i is a valid index in s or is equal to 0. Otherwise StringIndexError or BoundsError is
       thrown.
@nsajko
Copy link
Contributor

nsajko commented Jun 21, 2024

  1. On master, there's generic documentation due to Document the generic functions nextind() and prevind() #52658: https://docs.julialang.org/en/v1.12-dev/base/arrays/#Base.nextind
  2. The mentioned PR left the Markdown broken, thus nextind, prevind doc strings: correct the Markdown #54876

@jariji jariji closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants