Created
January 13, 2023 08:24
-
-
Save Msirkovsky/934ca62376cd135e67a08a2ded037453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const memoized = new Map() | |
function compute(... args) { | |
const key = #[...args] // magic is here | |
if (memoized.has(key)) | |
{ | |
return memoized.get(key) | |
} | |
else { | |
const value = carrySlowComputation(...args) | |
memoized[key] = value | |
return value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment