I’d like to split a list into two lists, one which can be handled directly, and the other being the remainder, which will be passed down a chain to other handlers.
Input:
- One list of items
- a filtering method to determine which list to include the item in.
Output:
- a “true” list
- a “false” list
Does this already exist? Perhaps a Linq method that I’m not thinking of at the moment? Otherwise, does anyone have a good C# example?
Here is one simple method. Note that
ToLookupeagerly evaluates the input sequence.You can use
GroupByto get lazy evaluation of the input sequence, but it’s not quite as pretty: