I am trying to create a curriable function that returns whether or not the specified length of a string is equal or not. I would like it to work as follows:
checkLength(3)('asdf') // => false
checkLength(4)('asdf') // => true
At first I tried this, but the order of the arguments is reversed, because it returns a curried function equals
:
const checkLength = R.compose(R.equals(), R.prop('length'))
checkLength('asdf')(4)
I can fix it by wrapping it in a function like this:
const checkLength = (len) => R.compose(R.equals(len), R.prop('length'))
But it seems that a functional library can be used to solve this problem. Does anyone have any idea?
source
share