-
Notifications
You must be signed in to change notification settings - Fork 240
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
Generic function maps? #334
Comments
You can always just use This: $sqrts = Map\Single::sqrt($xs); Is nicer to read than $sqrts = array_map(
function ($x) {
return sqrt($x);
},
$xs
); To make a generic one that will work with most of the built-in PHP functions, then the interface goes from something like this: $sqrts = Map\Single::sqrt($xs); To this: $sqrts = Map\Single::generic('sqrt', $xs); It is less work for library writers, but more work for library users. I think a library should provide as simple an interface as possible to make the lives of library users easier at the expense of the library writers having to do more work. Kind of like Spock's the needs of the many outweigh the needs of the few. |
My intention was more for one-off use cases. I’m mapping the signum function in one PCA test, and was considering adding a single map for it, but then thought that a generic one that I proposed here could serve more purposes. This isn’t to replace the more heavily used Single Maps. |
Sure. Go ahead and add it. It sounds more like something that would be used internally in places like testing and probably not something to document for end users to use, which is fine. Not every useful utility class or method needs to be documented. |
As this library gets larger, the selection of native php functions that are needed as Functions\Map\Single::foo() will increase. What do you think about generating a generic one:
The text was updated successfully, but these errors were encountered: