I am learning about pointfree functions and am trying to implement this recursive null remover in that style.
Works, but is not pointfree:
function removeNulls(obj) {
return R.ifElse(
R.either(R.is(Array), R.is(Object)),
R.pipe(
R.filter(R.pipe(R.isNil, R.not)),
R.map(removeNulls)
),
R.identity
)(obj)
}
module.exports = removeNulls
The following is my non-functioning attempt at it:
const removeNulls = R.ifElse(
R.either(R.is(Array), R.is(Object)),
R.pipe(
R.filter(R.pipe(R.isNil, R.not)),
// throws `ReferenceError: removeNulls is not defined`
R.map(removeNulls)
),
R.identity
)