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

Stats:

CreatedJan 14, 2015
PublishedJan 14, 2015
Warriors Trained8321
Total Skips1509
Total Code Submissions14931
Total Times Completed2869
JavaScript Completions1685
Python Completions831
Java Completions256
Haskell Completions86
Go Completions110
Total Stars179
% of votes with a positive feedback rating89% of 390
Total "Very Satisfied" Votes324
Total "Somewhat Satisfied" Votes48
Total "Not Satisfied" Votes18
Ad
Contributors
  • myTerminal Avatar
  • joh_pot Avatar
  • cemunds Avatar
  • googleben Avatar
  • ParanoidUser Avatar
  • docgunthrop Avatar
  • JohanWiltink Avatar
  • user8436785 Avatar
  • LosBlobbos Avatar
Ad