Created
November 6, 2017 04:28
-
-
Save rsp/475bce3e5b83f9b6c6a900706c112a55 to your computer and use it in GitHub Desktop.
Language Wars - Church numerals - ES6 JavaScript
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 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info: https://github.com/rsp/languagewars-churchnumerals-es6