Module ddash.algorithm.pull

Removes elements from a range

Example

int[] arr = [1, 2, 3, 4, 5];
arr.pull(1, [2, 5]);
assert(arr == [3, 4]);

import std.math: ceil;
double[] farr = [2.1, 1.2];
assert(farr.pull!ceil([2.3, 3.4]) == [1.2]);

farr = [2.1, 1.2];
assert(farr.pull!((a, b) => ceil(a) == ceil(b))([2.3, 3.4]) == [1.2]);

arr = [1, 2, 3, 4, 5];
assert(arr.pull!"a == b - 1"(4, 6) == [1, 2, 4]);

Example

struct A {
    int x;
    int y;
}

auto arr = [A(1, 2), A(3, 4), A(5, 6)];
assert(arr.pullBy!"y"(2, 6) == [A(3, 4)]);

Functions

NameDescription
pull(range, values) Removes elements from a range.
pullBy(range, values) Removes elements from a range by a publicly visible field of ElemntType!Range
pullIndices(range, indices) Returns a range excluding the specified indices.