Skip to content

Instantly share code, notes, and snippets.

@ryu1-1uyr
Created May 8, 2018 01:13
Show Gist options
  • Select an option

  • Save ryu1-1uyr/bb85ca4569bb1842abfa4f1cc4213ac9 to your computer and use it in GitHub Desktop.

Select an option

Save ryu1-1uyr/bb85ca4569bb1842abfa4f1cc4213ac9 to your computer and use it in GitHub Desktop.
javascriptでSKIとかTFの実装とか
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