Ramda 中有 R.notEquals 等价物吗?
Is there an R.notEquals equivalent in Ramda?
在 Ramda 中我可以做如下的事情(这只是假设的代码,只是为了说明我正在寻找的解决方案)
const highest = function(attribute) {
switch(attribute){
case 'score':
return 'John'
}
}
const hasHighestScore = R.compose(
R.equals,
R.toLower,
highest
)('score')
hasHighestScore('john') // true
是否有 R.equals 的等价物,returns 相反的值但与 R.equals 的作用相同?
这样假设的代码就可以工作了:
const hasNotHighestScore = R.compose(
R.notEquals,
R.toLower,
highest
)('score')
显然我可以反转之前的结果
const doesNotHaveHighestScore = x => !hasHighestScore(x)
但我想知道是否有类似 R.notEquals 的东西,或者我可以自己创建吗?谢谢
考虑以下(老实说,我是在阅读评论之前写的。我不知道为什么那个人不直接回答):
const notHasHighestScore = R.compose(
R.complement,
R.equals,
R.toLower,
highest
)('score')
在 Ramda 中我可以做如下的事情(这只是假设的代码,只是为了说明我正在寻找的解决方案)
const highest = function(attribute) {
switch(attribute){
case 'score':
return 'John'
}
}
const hasHighestScore = R.compose(
R.equals,
R.toLower,
highest
)('score')
hasHighestScore('john') // true
是否有 R.equals 的等价物,returns 相反的值但与 R.equals 的作用相同?
这样假设的代码就可以工作了:
const hasNotHighestScore = R.compose(
R.notEquals,
R.toLower,
highest
)('score')
显然我可以反转之前的结果
const doesNotHaveHighestScore = x => !hasHighestScore(x)
但我想知道是否有类似 R.notEquals 的东西,或者我可以自己创建吗?谢谢
考虑以下(老实说,我是在阅读评论之前写的。我不知道为什么那个人不直接回答):
const notHasHighestScore = R.compose(
R.complement,
R.equals,
R.toLower,
highest
)('score')