Skip to content

Instantly share code, notes, and snippets.

@mflatt
Created March 30, 2021 13:33
Show Gist options
  • Save mflatt/a61fe84c933503082207cdc8876108f1 to your computer and use it in GitHub Desktop.
Save mflatt/a61fe84c933503082207cdc8876108f1 to your computer and use it in GitHub Desktop.
Fibonacci (the fast way) in MSDscript
_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