unary transformation or binary comparator
the range to inspect
ranges or single values to exclude
New array of filtered results. If Rs is empty, then range is returned
1 assert([1, 2, 3].difference([0, 1, 2]).equal([3])); 2 assert([1, 2, 3].difference([1, 2]).equal([3])); 3 assert([1, 2, 3].difference([1], 2).equal([3])); 4 assert([1, 2, 3].difference([1], [3]).equal([2])); 5 assert([1, 2, 3].difference(3).equal([1, 2]));
1 // Implicitly convertible elements ok 2 assert([1.0, 2.0].difference(2).equal([1.0])); 3 4 // Implicitly convertible ranges ok 5 assert([1.0, 2.0].difference([2]).equal([1.0])); 6 7 // Non implicily convertible elements not ok 8 static assert(!__traits(compiles, [1].difference(1.0))); 9 10 // Non implicily convertible range not ok 11 static assert(!__traits(compiles, [1].difference([1.0])));
import std.math: ceil; assert([2.1, 1.2].difference!ceil([2.3, 3.4]).equal([1.2])); assert([9, 2, 3, 2, 3, 9].difference([7, 3, 1, 5]).equal([2, 2, 9, 9]));
0.0.1
Creates a range of values not included in the other given ranges.
You may pass in a unary or binary predicate. If a unary predicate is passed in, then a transformation will be appled to each element before comparing. If a binary predicate is passed in, it must be a comparator predicate that returns true if if a < b.
If pred is null or unary, and the range is sortable, a sort is applied followed by an optimized linear algorithm. If the range is already sorted and pred is null, then the linear algorithm is just used with the sorted rang's $(DDOX_NAMED_REF range.sortingpredicate, `sorting predicate`).