You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Computes the multiset difference between this sequence and another sequence.
that: the sequence of elements to remove
returns: a new sequence which contains all elements of this sequence except some of occurrences of elements that also appear in that. If an element value x appears n times in that, then the first n occurrences of x will not form part of the result, but any following occurrences will.
use itertools::Itertools;
use itertools::EitherOrBoth::{Left, Right, Both};
let a = (0..=10).step_by(2);
let b = (0..=10).step_by(4);
let a_not_b = a
.merge_join_by(b, |i, j| i.cmp(j))
.flat_map(|either| {
match either {
Left(l) => Some(l),
_ => None
}
})
.collect::<Vec<i32>>();
assert_eq!(a_not_b, vec![2, 6, 10]);
But it would be nice with a .diff(&self, other: J) or .left_join(&self, other: J) to cut down the boiler plate!
I'm trying to find something similar to Scala's Stream.diff:
I see there's https://docs.rs/itertools/0.8.1/itertools/fn.diff_with.html, but it doesn't seem to do the same thing? Maybe we call it something else?
The text was updated successfully, but these errors were encountered: