compose/compose.libsonnet

20 lines
388 B
Plaintext
Raw Normal View History

2020-07-29 13:53:46 +00:00
// the tail of an array
local tail(array) = std.makeArray(
std.length(array) -1,
function(x) array[x + 1],
);
local compose(functions) =
if std.length(functions) == 0
then
function(object) object
else
function(object) compose(
tail(
functions,
)
)(
functions[0](object)
);
// compose an array of functions
compose