This example starts a collection with the pairs (x, x+1) for x in 0 .. 10. It then adds any pairs (x+1,x) for which x is not a multiple of three. That excludes four pairs (for 0, 3, 6, and 9) which should leave us with 16 total pairs.
import std.algorithm : map, filter; import std.range : iota; // arrange Iteration iter; auto variable = iter.variable!(int, int)("source"); variable.insert(iota(10).map!(x => kvTuple(x, x + 1))); auto relation_ = relation!(int).from(iota(10).filter!(x => x % 3 == 0) .map!kvTuple); // act while (iter.changed) { variable.fromAntiJoin!((k, v) => kvTuple(v, k))(variable, relation_); } auto result = variable.complete; // assert result.should == relation!(int, int).from([[0, 1], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 8], [8, 7], [8, 9], [9, 8], [9, 10],]); //.map!(a => kvTuple(a[0], a[1])); result.length.should == 16;
Adds tuples from input1 whose key is not present in input2.