Function memoize

Memoizes a function, caching results based on arguments. Works best with pure functions with small input spaces.

const expensiveSum = (a: number, b: number) => {
console.log('computing...');
return a + b;
};
const memoized = memoize(expensiveSum);
memoized(2, 3); // logs 'computing...'
memoized(2, 3); // returns cached result