Created
March 30, 2021 13:33
-
-
Save mflatt/a61fe84c933503082207cdc8876108f1 to your computer and use it in GitHub Desktop.
Fibonacci (the fast way) in MSDscript
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
_let pair = _fun (a) _fun (b) | |
_fun(sel) | |
_if sel _then a _else b | |
_in _let fst = _fun (p) p(_true) | |
_in _let snd = _fun (p) p(_false) | |
_in _let fib = _fun (fib) | |
_fun (x) | |
_if x == 0 | |
_then pair(1)(1) | |
_else _if x == 1 | |
_then pair(1)(1) | |
_else _let p = fib(fib)(x + -1) | |
_in pair(fst(p) + snd(p))(fst(p)) | |
_in fst(fib(fib)(30)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment