Functor
s, then it makes sense that contains
would work on them as well, since they should also be Foldable
(since contains
can be written in terms of reduce
).
contains
to work.
R.adjust(R.always(x)
was the closest I found
Right(result)
or Left(errorObject)
: https://gist.github.com/gilligan/66a1ac0431a0e77fdaae - this is not quite right. Can anyone help out ?
(b -> b -> c) -> (a -> b) -> a -> a -> c
it almost writes itself.
const on = curry((f, g, x, y) => f(g(x), g(y)));
c
, you only have one place to get it, the f
function. Well, the f
function needs two values of type b
, and you can only get those from the g
function. The g
function needs a value of type a
, and you have two of those: x
, and y
. So you be fair and send both values x
, and y
to g
, then send that to f
, and your function wrote itself.
on(f, identity) == f
you have no other choice for an implementation.
R.ap
, but a variant which is not going to do every permutation, but only apply first function to the first argument in the list, the second function to the second argument in the list, and so on:R.ap([R.multiply(2), R.add(3)], [1,2]); // => [2, 5]