roc/examples/algorithms/fibonacci.roc
2022-06-16 15:21:55 -04:00

14 lines
268 B
Plaintext

app "fibonacci"
packages { pf: "fibonacci-platform/main.roc" }
imports []
provides [main] to pf
main = \n -> fib n 0 1
# the clever implementation requires join points
fib = \n, a, b ->
if n == 0 then
a
else
fib (n - 1) b (a + b)