The OpenD Programming Language

pipe

Composes passed-in functions fun[0], fun[1], ... returning a function f(x) that in turn returns ...(fun[1](fun[0](x))).... Each function can be a regular functions, a delegate, a lambda, or a string.

template pipe(fun...)
ref
static if(fun.length != 1)
static if(f.length == fun.length && Filter!(_needNary, f).length == 0)
pipe
(
Args...
)
(
auto ref Args args
)

Members

Functions

pipe
auto ref pipe(Args args)

Examples

assert(pipe!("a + b", a => a * 10)(2, 3) == 50);

pipe can return by reference.

int a;
assert(&pipe!("a", "a")(a) == &a);

Template bloat reduction

enum  a = "a * 2";
alias b = e => e + 2;

alias p0 = pipe!(pipe!(a, b), pipe!(b, a));
alias p1 = pipe!(a, b, b, a);

static assert(__traits(isSame, p0, p1));

Meta