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

How do you get the index of a given string in a sequence of strings? #182

Open
binarykitchen opened this issue Mar 24, 2016 · 3 comments
Open

Comments

@binarykitchen
Copy link

This seems to be missing ... thanks for any hints

@binarykitchen binarykitchen changed the title For sequences, how do you get the index of a given value? How do you get the index of a given string in a sequence of strings? Mar 24, 2016
@hallettj
Copy link

There is an undocumented function keepIndexed that you can use in this fashion:

const kept = mori.keepIndexed((idx, string) => string === referenceString ? idx : null, strings)
const matchingIndex = mori.first(kept)

@binarykitchen
Copy link
Author

thanks @hallettj but why is it undocumented?

@hallettj
Copy link

hallettj commented Apr 5, 2016

I don't know why keepIndexed is not documented. I happened to get a pretty good look at that and other unadvertised functions while assembling type definitions for Mori.

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