Open abelbraaksma opened 2 years ago
For what it's worth, System.Linq.Enumerable.Except
behaves the same way, and its summary
says simply:
Produces the set difference of two sequences.
The remarks
section adds:
The set difference of two sets is defined as the members of the first set that don't appear in the second set.
This method returns those elements in
first
that don't appear insecond
. It doesn't return those elements insecond
that don't appear infirst
. Only unique elements are returned.
For one reason or another, I always thought that
Seq.except
takes a sequence and removes all elements from it that are in theitemsToExclude
sequence. The tooltip says this:This isn't wrong, but it is fairly easy to read over the "with the distinct elements of the second sequence" bit. This function actually does a set-except operation. Basically, it makes the sequence distinct (i.e., drops all elements that are hashset-equal to another element), plus it removes those elements that are in the
itemsToExclude
sequence.Since sequences are not sets, this was a bit surprising to me when I naively started implementing this same operation in
TaskSeq
. Just because it is not a set, something likeexceptDistinct
seems to make more sense (also, it seems like a "remove all elements that are in sequence X from sequence Y" does not exist forseq
).Anyway, not suggesting a change or wanting to add a new function. Here's an attempt at a better wording, but other suggestions welcome before I'd open a PR to do so.
Suggestion:
We should probably also update the example given in the docs to make this particular behavior clear.