Ramda 过滤如果不匹配

Ramda filter if not match

我想过滤所有不符合条件的元素。我能够让它工作:

var a = [1,2,3];
function notSame(x,y) {
  R.pipe(
    R.equals,
    R.not
  )
}

R.filter(
  R.pipe(
    R.equals(1),
    R.not),
  a
) // [2,3]

但我觉得必须有一个更简单的方法:)

R.reject 是你想要的:

var isOdd = (n) => n % 2 === 1;
R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}