5 kyu
Lazy Repeater
5,419 of 8,050nklein
Description:
The makeLooper()
function (or make_looper
in your language) takes a string (of non-zero length) as an argument. It returns a function. The function it returns will return successive characters of the string on successive invocations. It will start back at the beginning of the string once it reaches the end.
For example:
var abc = makeLooper('abc');
abc(); // should return 'a' on this first call
abc(); // should return 'b' on this second call
abc(); // should return 'c' on this third call
abc(); // should return 'a' again on this fourth call
Different loopers should not affect each other, so be wary of unmanaged global state.
Iterators
Algorithms
Similar Kata:
Stats:
Created | Aug 2, 2013 |
Published | Aug 3, 2013 |
Warriors Trained | 13301 |
Total Skips | 1022 |
Total Code Submissions | 25704 |
Total Times Completed | 8050 |
JavaScript Completions | 5419 |
CoffeeScript Completions | 33 |
C# Completions | 490 |
Python Completions | 1399 |
Rust Completions | 150 |
Scala Completions | 47 |
TypeScript Completions | 522 |
C++ Completions | 198 |
Total Stars | 190 |
% of votes with a positive feedback rating | 93% of 604 |
Total "Very Satisfied" Votes | 534 |
Total "Somewhat Satisfied" Votes | 58 |
Total "Not Satisfied" Votes | 12 |