5 kyu
Function Cache
10,003 of 10,077BattleRattle
Description:
If you are calculating complex things or execute time-consuming API calls, you sometimes want to cache the results. In this case we want you to create a function wrapper, which takes a function and caches its results depending on the arguments, that were applied to the function.
Usage example:
var complexFunction = function(arg1, arg2) { /* complex calculation in here */ };
var cachedFunction = cache(complexFunction);
cachedFunction('foo', 'bar'); // complex function should be executed
cachedFunction('foo', 'bar'); // complex function should not be invoked again, instead the cached result should be returned
cachedFunction('foo', 'baz'); // should be executed, because the method wasn't invoked before with these arguments
Fundamentals
Similar Kata:
Stats:
Created | Oct 8, 2013 |
Published | Oct 8, 2013 |
Warriors Trained | 21234 |
Total Skips | 4146 |
Total Code Submissions | 158940 |
Total Times Completed | 10077 |
JavaScript Completions | 10003 |
Total Stars | 345 |
% of votes with a positive feedback rating | 86% of 567 |
Total "Very Satisfied" Votes | 444 |
Total "Somewhat Satisfied" Votes | 88 |
Total "Not Satisfied" Votes | 35 |