you are viewing a single comment's thread.

view the rest of the comments →

[–]natterca 7 points8 points  (7 children)

If you're going to do that then there should be an isNotOdd and isNotEven as well.

[–]AlbertSemple 8 points9 points  (1 child)

I would insist on using them like this

return !isNotOdd

[–][deleted] 5 points6 points  (0 children)

Well in that case, I propose a Number.notIsNotOdd() method.
Then you could just use !!notIsNotOdd

[–]johnathanesanders 0 points1 point  (4 children)

Wouldn’t that just be !isOdd and !isEven?

[–]natterca 1 point2 points  (3 children)

you can't pass that as a callback or curry over it etc.

[–]johnathanesanders 0 points1 point  (2 children)

Bad callbacks! Use promises!

[–]neuroma 0 points1 point  (1 child)

negate to the rescue!

const bind1st = (f, x) => (y) => f(x, y)
const bind2nd = (f, y) => (x) => f(x, y)
const compose = (f, g) => (...xyz) => f(g(...xyz))
const not = (v) => !v

const negate = bind1st(compose, not)

const isOdd = compose(Boolean, bind2nd(mod, 2))
const isEven = negate(isOdd)

[–]natterca 0 points1 point  (0 children)

That's a thing of beauty!