Last active
December 3, 2021 19:50
-
-
Save kennethkoontz/565346215dc60c886fe838377410b15b to your computer and use it in GitHub Desktop.
This file contains 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
// Cache a function's results by storing them. You may assume | |
// that the function only takes primitives as arguments. | |
// | |
// The function should return a function that, when called, will check if it has | |
// already computed the result and return that value instead if possible. | |
// | |
// Example: | |
// cacheAdd = myFunction(add); | |
// add(1,2) = 3 | |
// cacheAdd(1,2) = 3 --> executes add function | |
// cacheAdd(1,2) = 3 --> returns from cache | |
// cacheAdd(2,2) = 4--> executes add function | |
function cacher() {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment