Skip to content

Instantly share code, notes, and snippets.

@rsp
Created November 6, 2017 04:28
Show Gist options
  • Save rsp/475bce3e5b83f9b6c6a900706c112a55 to your computer and use it in GitHub Desktop.
Save rsp/475bce3e5b83f9b6c6a900706c112a55 to your computer and use it in GitHub Desktop.
Language Wars - Church numerals - ES6 JavaScript
const suc = a => b => c => b(a(b)(c));
const add = a => b => c => d => a(c)(b(c)(d));
const mul = a => b => c => a(b(c));
const exp = a => b => b(a);
const pre = a => b => c => a(d => e => e(d(b)))(f => c)(g => g);
const sub = a => b => b(pre)(a);
const ntc = n => n > 0 ? a => b => a(ntc(n - 1)(a)(b)) : a => b => b;
const ctn = a => a(x => x + 1)(0);
@rsp
Copy link
Author

rsp commented Nov 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment