Created
April 21, 2019 11:32
-
-
Save yairEO/d112b09a973b12cbfef72bd71b41dfa1 to your computer and use it in GitHub Desktop.
simple memoize
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
var foo = (memo => ()=> { | |
// if the function was already computed, return the computed value | |
if(memo) return memo; | |
// continue with regular logic and set "memo" to the output value for later calls | |
memo = 1; | |
return memo; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment