The OpenD Programming Language

troykaSeries

Constructs union using three functions to handle each intersection case separately.

template troykaSeries(alias lfun, alias cfun, alias rfun)
troykaSeries
(
IndexIterL
IterL
size_t LN
SliceKind lkind
IndexIterR
IterR
size_t RN
SliceKind rkind
)
(
Series!(IndexIterL, IterL, LN, lkind) lhs
,
Series!(IndexIterR, IterR, RN, rkind) rhs
)

Members

Functions

troykaSeries
auto troykaSeries(Series!(IndexIterL, IterL, LN, lkind) lhs, Series!(IndexIterR, IterR, RN, rkind) rhs)

Parameters

lfun

binary function that accepts left side key and left side value

cfun

trinary function that accepts left side key, left side value, and right side value

rfun

binary function that accepts right side key and right side value

Examples

import mir.ndslice;
auto a = [1, 2, 3, 9].sliced.series(iota!int([4], 1));
auto b = [0, 2, 4, 9].sliced.series(iota!int([4], 1) * 10.0);
alias unionAlgorithm = troykaSeries!(
    (key, left) => left,
    (key, left, right) => left + right,
    (key, right) => -right,
);
auto c = unionAlgorithm(a, b);
assert(c.index == [0, 1, 2, 3, 4, 9]);
assert(c.data == [-10, 1, 22, 3, -30, 44]);

Meta