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

Array.find is missing? #12

Open
j-panasiuk opened this issue Jan 21, 2017 · 2 comments
Open

Array.find is missing? #12

j-panasiuk opened this issue Jan 21, 2017 · 2 comments

Comments

@j-panasiuk
Copy link

j-panasiuk commented Jan 21, 2017

Hi!

I'm curious why there is no find function either in core or here in extras?
I literally checked both three times, because I thought it's just me being blind
Wouldn't that be a useful addition?

find : (a -> Bool) -> Array a -> Maybe a

Also it would be natural to have its findLast counterpart
Maybe even call find as findFirst for clarity?

@robinheghan
Copy link
Contributor

My guess is because it can only be implemented in core, as it requires native code if you wan't it to be fast. The only implementation you could get without native code, is filter pred >> get 0

@j-panasiuk
Copy link
Author

But then why not expose the above implementation as find?
If you care about performance, you're on your own anyway. And if you don't care, you have a very convenient helper (and one people coming from other languages would probably expect to have). Implementation can then be improved at some later point

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

No branches or pull requests

3 participants