compose

Composes passed-in functions fun[0], fun[1], ....

template compose (
fun...
) if (
fun.length > 0
) {}

Parameters

fun

the call-able(s) or string(s) to compose into one function

Return Value

A new function f(x) that in turn returns fun[0](fun[1](...(x)))....

Examples

import std.algorithm.comparison : equal;
import std.algorithm.iteration : map;
import std.array : split;
import std.conv : to;

// First split a string in whitespace-separated tokens and then
// convert each token into an integer
assert(compose!(map!(to!(int)), split)("1 2 3").equal([1, 2, 3]));

See Also

Meta