我了解ramda的complement函数的使用,该函数会反转谓词的返回。我无法理解的是为什么使用“complement” 作为名称。
const invertPredicate = R.complement(R.identity)
invertPredicate(false) //true
有人可以对此提供一些见解吗?
最佳答案
“在集合论中,集合A的补码是指不在A中的元素”
https://en.m.wikipedia.org/wiki/Complement_(set_theory)
因此,R.complement
将为所有不满足提供的谓词的值生成一个谓词。
关于functional-programming - 为什么在ramda.js中将“complement”用作函数的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51662504/