The best thing you can do, is to use 2 variables:
fib_ = fn
0, f -> 0
1, f -> 1
n, f -> f.(n-1) + f.(n-2)
end
fib = fn(n) -> fib_(n, fib_) end
IO.puts fib.(10)
Please beware the autocorrection.
The best thing you can do, is to use 2 variables:
fib_ = fn
0, f -> 0
1, f -> 1
n, f -> f.(n-1) + f.(n-2)
end
fib = fn(n) -> fib_(n, fib_) end
IO.puts fib.(10)
Please beware the autocorrection.