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

Add curried version of the multiple argument predicate functions #216

Merged
merged 2 commits into from
Feb 5, 2024

Conversation

DeviousStoat
Copy link
Contributor

This adds curried version of the predicate functions accepting multiple arguments.

So you can nicely do stuff like:

import pydash as pyd

assert pyd.filter_([1, 2, 3], pyd.gt_pred(2)) == [3]
assert pyd.filter_([1, 2, 3], pyd.in_range_pred(2, 3)) == [2]

Instead of having to write the whole function or manually currying:

import pydash as pyd

assert pyd.filter_([1, 2, 3], lambda value: value > 2) == [3]
assert pyd.filter_([1, 2, 3], pyd.curry_right(pyd.in_range)(3)(2)) == [2]

I am not very satisfied with the naming though, let me know what you think.

@coveralls
Copy link

coveralls commented Feb 2, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 15452a5 on DeviousStoat:curried-predicates
into 940a843 on dgilland:develop.

@dgilland
Copy link
Owner

dgilland commented Feb 4, 2024

I am not very satisfied with the naming though, let me know what you think.

Instead of suffixing with _pred, I'd suggest using _cmp (short for comparator).

@DeviousStoat
Copy link
Contributor Author

I am not very satisfied with the naming though, let me know what you think.

Instead of suffixing with _pred, I'd suggest using _cmp (short for comparator).

Makes more sense, thank you. I changed it.

@dgilland dgilland merged commit 0dfc47d into dgilland:develop Feb 5, 2024
12 checks passed
@DeviousStoat DeviousStoat deleted the curried-predicates branch February 7, 2024 17:03
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

Successfully merging this pull request may close these issues.

None yet

3 participants