HyperReduce
Description:
Background info
To be able to complete the kata, you will need to be able to comprehend these two resources:
Definition
With that in the back of our minds, let's make a wholly insane function! The idea is that our function returns a reduce function that is agnostic to the amount of function calls, arguments and array nests in between. What?! Let's look at some examples to clarify:
const adder = (accumulator, next) => accumulator + next;
const add = hyperReduce(adder, 0);
add
has become a function that would have the following inputs and outputs
add(3) //=> 3
add(3, 3, 3) //=> 9
add(3, 3, 3)(3) //=> 12
add(3, 3, 3)([3,3]) //=> 15
add(3, 3, 3)([3,[3]]) //=> 15
add([[[[[[[[[[3]]]]]]]]]])() => 3
Misc
You are also expected to be able to handle multiplication, division, concatenation and composition. Couldn't think of a legitimate use case except for code challenges. Enjoy implementing this :) If there's anything I left vague, look at the test cases. Anything else was unintentional so please let me know.
Stats:
Created | Mar 27, 2018 |
Published | Mar 27, 2018 |
Warriors Trained | 370 |
Total Skips | 32 |
Total Code Submissions | 535 |
Total Times Completed | 41 |
JavaScript Completions | 41 |
Total Stars | 22 |
% of votes with a positive feedback rating | 100% of 14 |
Total "Very Satisfied" Votes | 14 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |