5 kyu
Lazy Repeater
5,685 of 8,853nklein
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:
const 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 | 15027 |
Total Skips | 1068 |
Total Code Submissions | 27487 |
Total Times Completed | 8853 |
JavaScript Completions | 5685 |
CoffeeScript Completions | 35 |
C# Completions | 541 |
Python Completions | 1634 |
Rust Completions | 181 |
Scala Completions | 59 |
TypeScript Completions | 600 |
C++ Completions | 322 |
Lua Completions | 14 |
Java Completions | 46 |
Haskell Completions | 6 |
OCaml Completions | 4 |
Total Stars | 208 |
% of votes with a positive feedback rating | 93% of 648 |
Total "Very Satisfied" Votes | 574 |
Total "Somewhat Satisfied" Votes | 61 |
Total "Not Satisfied" Votes | 13 |