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

generalized slice syntax #48

Open
mattkretz opened this issue Feb 9, 2023 · 0 comments
Open

generalized slice syntax #48

mattkretz opened this issue Feb 9, 2023 · 0 comments
Assignees
Labels
exploration New feature or request to be explored help wanted The assignee likely won't get this done without help

Comments

@mattkretz
Copy link
Owner

There seems to be a pattern that we need to explore:

We want slices of

  • simd,
  • contiguous_container (e.g. span, vector), and
  • (strided) slices for mdpsan.

More?

Many other languages have syntax to support this. E.g. Python:

a[start:stop]  # items start through stop-1
a[start:]      # items start through the rest of the array
a[:stop]       # items from the beginning through stop-1
a[:]           # a copy of the whole array
a[start:stop:step] # start through not past stop, by step
a[-1]      # last item in the array
a[-2:]     # last two items in the array
a[:-2]     # everything except the last two items
a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed

extract<0, 4>(v) could be written as v[0:4] with that syntax.

@mattkretz mattkretz added exploration New feature or request to be explored help wanted The assignee likely won't get this done without help labels Feb 9, 2023
@mattkretz mattkretz self-assigned this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exploration New feature or request to be explored help wanted The assignee likely won't get this done without help
Projects
Status: No status
Development

No branches or pull requests

1 participant