why ```elixir
defmodule FibCache do
defp cache do
Agent.start_link(fn -> %{} end)
end
defp fetch(pid, k) do
Agent.get(pid, &(&1[k]))
end
defp put(pid, k, v) do
Agent.update(pid, &(Map.put(&1, k, v)))
end
defp fib(cache_pid, n) when n >= 0 do
cached_res = fetch(cache_pid, n)
if !cached_res do
res = if n <= 1,
do: n,
else: fib(n-1) + fib(n-2)
put(cache_pid, n, res)
res
else
cached_res
end
end
def makefib do
{:ok, pid} = cache()
&(fib(pid, &1))
end
end
fib = FibCache.makefib
IO.puts Enum.map(1..20, fib)
gives this
** (CompileError) jdoodle.exs:19: undefined function fib/1
(elixir 1.12.2) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
jdoodle.exs:1: (file)