#pragma once
|
|
#include "combinations/tuple.hpp"
|
|
|
|
namespace cl{
|
|
|
|
template<typename a, typename ...c>
|
|
class compose_t{
|
|
// f . next
|
|
a f;
|
|
compose_t<c...> next;
|
|
public:
|
|
compose_t(a fn1, c ...oth)
|
|
: f{fn1}
|
|
, next{oth...}
|
|
{}
|
|
template<typename ...t>
|
|
auto operator()(t ...Args){
|
|
return next(f(Args...));
|
|
}
|
|
|
|
};
|
|
|
|
template<typename a>
|
|
class compose_t<a>{
|
|
// f . g
|
|
a f;
|
|
public:
|
|
compose_t(a fn1)
|
|
: f{fn1}
|
|
{}
|
|
template<typename ...t>
|
|
auto operator()(t ...Args){
|
|
return f(Args...);
|
|
}
|
|
|
|
};
|
|
|
|
template<typename a, typename ...c>
|
|
auto compose(a fn1, c ...oth)
|
|
{
|
|
return function(compose_t(fn1,oth...));
|
|
}
|
|
|
|
template<typename a, typename b>
|
|
auto operator*(a fn1, b fn2)
|
|
{
|
|
return compose(fn1, fn2);
|
|
}
|
|
}
|