The OpenD Programming Language

equal

Compares two or more slices for equality, as defined by predicate pred.

template equal(alias pred = "a == b")
@safe
static if(__traits(isSame, naryFun!pred, pred))
bool
equal
(
Slices...
)
(
Slices slices
)
if (
Slices.length >= 2
)

Members

Functions

equal
bool equal(Slices slices)

Parameters

pred

The predicate.

Examples

Ranges and arrays

import std.range : iota;
auto r = iota(6);
assert(r.equal([0, 1, 2, 3, 4, 5]));
import mir.ndslice.allocation : slice;
import mir.ndslice.topology : iota;

// 0 1 2
// 3 4 5
auto sl1 = iota(2, 3);
// 1 2 3
// 4 5 6
auto sl2 = iota([2, 3], 1);

assert(equal(sl1, sl1));
assert(sl1 == sl1); //can also use opEquals for two Slices
assert(equal!"2 * a == b + c"(sl1, sl1, sl1));

assert(equal!"a < b"(sl1, sl2));

assert(!equal(sl1[0 .. $ - 1], sl1));
assert(!equal(sl1[0 .. $, 0 .. $ - 1], sl1));

See Also

$(NDSLICEREF slice, Slice.opEquals)

Meta