This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original and function | |
const _notEqual = (x) => (y) => cond(not(y))(y)(x) | |
// this function can also be written as: | |
// λx.λy.cond y (not y) x | |
// it uses `cond` internally which can be written as: | |
// cond = λe1.λe2.λc.c e1 e2 | |
// it uses `not` internally which can be written as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original and function | |
const _equal = (x) => (y) => cond(y)(not(y))(x) | |
// this function can also be written as: | |
// λx.λy.cond y (not y) x | |
// it uses `cond` internally which can be written as: | |
// cond = λe1.λe2.λc.c e1 e2 | |
// it uses `not` internally which can be written as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original and function | |
const _or = (x) => (y) => cond(TRUE)(y)(x) | |
// this function can also be written as: | |
// λx.λy.cond TRUE y x | |
// it uses `cond` internally which can be written as: | |
// cond = λe1.λe2.λc.c e1 e2 | |
// let's grab the function body and start reducing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original and function | |
const _and = (x) => (y) => cond(y)(FALSE)(x) | |
// this function can also be written as: | |
// λx.λy.cond y FALSE x | |
// it uses `cond` internally which can be written as: | |
// cond = λe1.λe2.λc.c e1 e2 | |
// let's grab the function body and start reducing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const notEqual = (x) => (y) => cond(not(y))(y)(x) | |
notEqual(TRUE)(FALSE) // => TRUE | |
notEqual(FALSE)(TRUE) // => TRUE | |
notEqual(FALSE)(FALSE) // => FALSE | |
notEqual(TRUE)(TRUE) // => FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const equal = (x) => (y) => cond(y)(not(y))(x) | |
equal(TRUE)(FALSE) // => FALSE | |
equal(FALSE)(TRUE) // => FALSE | |
equal(FALSE)(FALSE) // => TRUE | |
equal(TRUE)(TRUE) // => TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const and = (x) => (y) => cond(y)(FALSE)(x) | |
and(TRUE)(FALSE) // => FALSE | |
and(FALSE)(TRUE) // => FALSE | |
and(FALSE)(FALSE) // => FALSE | |
and(TRUE)(TRUE) // => TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const or = (x) => (y) => cond(TRUE)(y)(x) | |
or(TRUE)(FALSE) // => TRUE | |
or(FALSE)(FALSE) // => FALSE | |
or(FALSE)(TRUE) // => TRUE | |
or(TRUE)(TRUE) // => TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const not = (x) => cond(FALSE)(TRUE)(x) | |
not(FALSE) // => TRUE | |
not(TRUE) // => FALSE | |
cond('Foo')('Bar')(not(TRUE)) // => 'Bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FALSE = (x) => (y) => y | |
FALSE('foo')('bar') // => 'bar' | |
FALSE(10)(5) // => 5 |
NewerOlder