The function comp for functional composition is applied using reverse ordering when used with the toFn() function.
I would expect that comp(f,g) would result in a function f(g(x)), as confirmed in the example given for the function:
var inc = function(n) { return n + 1 };
var double = function(n) { return n * 2 };
var incDouble = t.comp(double, inc);
incDouble(3); // 8
However, looking at the toFn function, the doc example (and experimentation) provide a result as g(f(x)):
var arr = [0,1,2,3,4,5],
var apush = function(arr, x) { arr.push(x); return arr; },
var xf = t.comp(t.map(inc),t.filter(isEven));
arr.reduce(t.toFn(xf, apush), []); // [2,4,6]
Were the composition consistent with the first example, the expected result of composing the mapping of increment to the even values of the input array should always be an array of exclusively odd values. Instead, it appears that we are filtering the even values of the incremented input array, i.e. it looks more like we should expect from t.comp(t.filter(isEven), t.map(inc)).
The function
comp
for functional composition is applied using reverse ordering when used with thetoFn()
function.I would expect that
comp(f,g)
would result in a functionf(g(x))
, as confirmed in the example given for the function:However, looking at the
toFn
function, the doc example (and experimentation) provide a result asg(f(x))
:Were the composition consistent with the first example, the expected result of composing the mapping of increment to the even values of the input array should always be an array of exclusively odd values. Instead, it appears that we are filtering the even values of the incremented input array, i.e. it looks more like we should expect from
t.comp(t.filter(isEven), t.map(inc))
.