6 kyu
Function iteration
1,685 of 2,869myTerminal
Description:
The purpose of this kata is to write a higher-order function returning a new function that iterates on a specified function a given number of times. This new function takes in an argument as a seed to start the computation from.
For instance, consider the function getDouble
.
When run twice on value 3
, yields 12
as shown below.
getDouble(3) => 6
getDouble(6) => 12
Let us name the new function createIterator
and we should be able to obtain the same result using createIterator
as shown below:
var doubleIterator = createIterator(getDouble, 2); // This means, it runs *getDouble* twice
doubleIterator(3) => 12
For the sake of simplicity, all function inputs to createIterator
would be functions returning a small number and number of iterations would always be integers.
Algorithms
Similar Kata:
Stats:
Created | Jan 14, 2015 |
Published | Jan 14, 2015 |
Warriors Trained | 8321 |
Total Skips | 1509 |
Total Code Submissions | 14931 |
Total Times Completed | 2869 |
JavaScript Completions | 1685 |
Python Completions | 831 |
Java Completions | 256 |
Haskell Completions | 86 |
Go Completions | 110 |
Total Stars | 179 |
% of votes with a positive feedback rating | 89% of 390 |
Total "Very Satisfied" Votes | 324 |
Total "Somewhat Satisfied" Votes | 48 |
Total "Not Satisfied" Votes | 18 |