-
Notifications
You must be signed in to change notification settings - Fork 2
Home
psttf edited this page May 5, 2017
·
2 revisions
Fibonacci numbers:
[
numeral = @top => [
zero = @ numeral => [
case = @ zero => \ z => \ s => z,
succ = @ zero => (zero.case := \ z => \ s => s zero).val := zero.val + 1,
val = @ zero => 0,
pred = @ this => this.case (numeral.zero) (\ x => x),
add = @ this => \ that => this.case (that) (\x => x.add (that.succ))
],
fib = @ numeral => \ n => n.case (numeral.zero) (\ x => x.case (n) (
\y => (numeral.fib x).add (numeral.fib y)))
],
main = @ top => ((top.numeral.fib) (top.numeral.zero.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ)).val
].main