I have a higher order function: let's say for simplicity
const divideLeftToRight = x => y => x/y;
I would like to have a function that performs the division but from 'right to left'. In other words, I need to have:
const divideRightToLeft = x => y => y/x;
I thought about doing:
const divideRightToLeft = R.curry((x,y) => divideLeftToRight(y)(x));
I am wondering if there is a more elegant way to do it
You are looking for the flip
function:
const divideRightToLeft = R.flip(divideLeftToRight)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With