Created
May 8, 2018 01:13
-
-
Save ryu1-1uyr/bb85ca4569bb1842abfa4f1cc4213ac9 to your computer and use it in GitHub Desktop.
javascriptでSKIとかTFの実装とか
This file contains hidden or 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 I = x => x; | |
| const K = x => y => x; | |
| const S = x => y => z => x(z)(y(z)); | |
| const p = console.log; | |
| const T = x => y => x; | |
| const F = x => y => y; | |
| //p(T(1)(0)); | |
| //p(F(1)(0)); | |
| //T,Fの関数を引数に渡す | |
| const toBool = b => b(true)(false); | |
| const toNum = b => b(1)(0); | |
| const IF = b => t => f => b(t)(f); | |
| const AND = p => q => (p)(q)(F); | |
| const OR = p => q => (p)(T)(q); | |
| const NOT = q => (q)(F)(T); | |
| const NAND = p => q => ((p)(q)(F))(F)(T); //NOT(AND) | |
| const f = NAND; | |
| p(f(T)(T)); | |
| p(f(T)(F)); | |
| p(f(F)(T)); | |
| p(f(F)(F)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment