Say I have two arrays:
const data = [1, 2, 3, 4]
const predicateArray = [true, false, false, true]
I want the return value to be:
[1, 4]
So far, I have come up with:
pipe(
zipWith((fst, scnd) => scnd ? fst : null)),
reject(isNil)
)(data, predicateArray)
Is there a cleaner / inbuilt method of doing this?
Solution in Ramda is preferred.
This works in native JS (ES2016):
const results = data.filter((d, ind) => predicateArray[ind])