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
Split #18
Comments
Funcy already has such function. And it's named |
You might also want to look at whatever. It could be used like this: from funcy import split
from whatever import _
over, under = split(_.age >= 21, users) |
Wow. I'm flabbergasted that I missed that. Sorry! |
That's a good use case. I had been using the _ from fn.py -- curious if there are differences? |
whatever is faster, and it's small single purpose library. |
Good to know |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
users_over_21, users_under_21 = split(lambda user: user.age >= 21, users)
thoughts? doing it manually is cumbersome, but maybe you have a better way.
over_21 = lambda user: user.age >= 21
users_over_21 = filter(over_21, users)
users_under_21 = filter(complement(over_21), users)
i'd be happy to implement.
The text was updated successfully, but these errors were encountered: