Initial commit

This commit is contained in:
aaron 2023-08-08 21:33:11 +01:00
commit cb002f4f27
50 changed files with 4666 additions and 0 deletions

17
src/memoize.luau Normal file
View file

@ -0,0 +1,17 @@
local function memoize<X, Y>(f: (X) -> Y): ((X) -> Y, { [X]: Y })
local cache: { [X]: Y } = {}
return function(x: X): Y
local y: Y? = cache[x]
if not y then
y = f(x)
cache[x] = y
end
return y :: Y
end, cache
end
return memoize