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

[Feature Request] racket/vector does not have a index-of #3423

Open
jestarray opened this issue Oct 3, 2020 · 3 comments
Open

[Feature Request] racket/vector does not have a index-of #3423

jestarray opened this issue Oct 3, 2020 · 3 comments
Labels
feature request Feature Request

Comments

@jestarray
Copy link
Contributor

(define (vector-index-of v p?)
  (for/first ([x (in-vector v)]
              [i (in-naturals)]
              #:when (p? x))
    i))
(vector-index-of #(1 3 5 8 9) even?) ; returns 3

There is index-of for lists but it does not work on a vector. I suggest adding one for vector!

@sleepnova
Copy link

Seems more like index-where instead of index-of?

@jestarray
Copy link
Contributor Author

ohh yeah, index-where is what i meant.

@jackfirth jackfirth added the feature request Feature Request label Oct 13, 2020
@jackfirth
Copy link
Sponsor Contributor

Would a version that worked on arbitrary sequences instead of just vectors work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants