Last active
May 2, 2019 16:00
-
-
Save matteodelabre/e5d595c9f79f1ec95eec3884c2505686 to your computer and use it in GitHub Desktop.
Fixed point in JavaScript
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
// s-m-n | |
const s = "(f, x) => `y => (${f})(${x}, y)`"; | |
// fixed point | |
const e = q => { | |
const n = `(x, y) => (${q})((${s})(x, x), y)`; | |
const p = eval(`(${s})(n, n)`); | |
return `(${p})(0)`; | |
}; | |
// test | |
const q = "(x, y) => x"; | |
const fix = e(q); | |
eval(`(${q})(${fix})`) === eval(`${fix}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment