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.
const findLens = pred => R.lens(
R.find(pred)
, (v, ar) => R.adjust(R.always(v), R.findIndex(pred, ar), ar)
)
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.