The OpenD Programming Language

rcTroykaSeries

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

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

Members

Functions

rcTroykaSeries
auto rcTroykaSeries(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 = rcTroykaSeries!(
    (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