Skip to content

Instantly share code, notes, and snippets.

@Msirkovsky
Created January 13, 2023 08:24
Show Gist options
  • Save Msirkovsky/934ca62376cd135e67a08a2ded037453 to your computer and use it in GitHub Desktop.
Save Msirkovsky/934ca62376cd135e67a08a2ded037453 to your computer and use it in GitHub Desktop.
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