mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
Refactor codebase
This commit is contained in:
parent
07ae542e28
commit
a3f03fd067
15 changed files with 228 additions and 128 deletions
|
|
@ -1,8 +1,8 @@
|
|||
local function memoize<X, Y>(f: (X) -> Y): ((X) -> Y, { [X]: Y })
|
||||
local cache: { [X]: Y } = {}
|
||||
local function memoize<X, Y>(f: (X) -> Y): (X) -> Y
|
||||
local cache: { [X]: Y? } = {}
|
||||
|
||||
return function(x: X): Y
|
||||
local y: Y? = cache[x]
|
||||
local y = cache[x]
|
||||
|
||||
if not y then
|
||||
y = f(x)
|
||||
|
|
@ -10,7 +10,7 @@ local function memoize<X, Y>(f: (X) -> Y): ((X) -> Y, { [X]: Y })
|
|||
end
|
||||
|
||||
return y :: Y
|
||||
end, cache
|
||||
end
|
||||
end
|
||||
|
||||
return memoize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue