Skip to content

beginof(a) analogue to endof(a)? #23354

@stevengj

Description

@stevengj

Looping over 1:length(a) is wrong for AbstractVector because it fails for non 1-based arrays. eachindex(a) is correct, but occasionally you need to provide explicit indices, e.g. to loop only over odd indices as in #23267. start(a):endof(a) doesn't work because for views start(a) is a tuple. You can do first(eachindex(a)), but this is kind of klunky and non-obvious.

Can we export a function startof beginof(a) = first(eachindex(a)) analogous to endof(a)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions