0

I would like to filter all elements that don't match a condition. I was able to get this to work:

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]

But I feel like there has to be a simpler approach :)

JuanCaicedo
  • 3,132
  • 2
  • 14
  • 36

1 Answers1

5

R.reject is what you're after:

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}
Scott Christopher
  • 6,458
  • 23
  • 26