Created
January 21, 2011 17:06
-
-
Save deanrad/790002 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
memoizer = {}; | |
function memosin(arg){ | |
if( memoizer[arg] ){ | |
return memoizer[arg] | |
} | |
else{ | |
memoizer[arg] = mysin(arg) | |
return memoizer[arg] | |
} | |
} | |
function mysin(arg){ | |
console.log('Recomputing sin for ' + arg) | |
return Math.sin(arg) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment