memoize
import { memoize } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/fn.ts";Memoize a unary function using a Map. This means that this algorithm puposefully leaks memory.
TODO: Extend memoize to be variadic.
@example
import * as F from "./fn.ts";
// Big old expensive recursive algorithm
const fib = (n: number): number =>
n < 1 ? 0 :
n <= 1 ? 1 :
fib(n - 2) + fib(n - 1);
const mfib = F.memoize(fib);
const result1 = mfib(10); // 55
const result2 = mfib(10); // 55 but does not recompute