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

Partition TypedPipe in two according to a predicate #986

Closed
rubanm opened this issue Jul 31, 2014 · 1 comment
Closed

Partition TypedPipe in two according to a predicate #986

rubanm opened this issue Jul 31, 2014 · 1 comment

Comments

@rubanm
Copy link
Contributor

rubanm commented Jul 31, 2014

Similar to scala collections.

def partition(p: T => Boolean): (TypedPipe[T], TypedPipe[T]) =
  (filter(p), filterNot(p))

I've run into this use-case a few of times. Seems handy to have. I can send a PR if this sounds sensible. Thanks.

@johnynek
Copy link
Collaborator

Sure that would be a good PR, but the implementation should probably be:

val forked = fork
(forked.filter(p), forked.filterNot(p))

Also we should comment that sometimes groupBy is what you really want in these cases.

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