6 kyu
Iterate function
55 of 116phaul
Description:
Write the method Object#iterate
that given an object takes a block as argument and an optional count n
.
If n
is given it returns an array of length n
where each element can obtained by the successive application of the block on the object, starting with the object.
If n
is not given, it returns an Enumerator
that yields the successive application of the block on the object indefinitely.
Example:
'str'.iterate(3) {|s| s * 2 } # => ["str", "strstr", "strstrstrstr"]
Functional Programming
Fundamentals
Similar Kata:
Stats:
Created | Sep 12, 2017 |
Published | Sep 12, 2017 |
Warriors Trained | 661 |
Total Skips | 21 |
Total Code Submissions | 2075 |
Total Times Completed | 116 |
Ruby Completions | 55 |
JavaScript Completions | 62 |
Total Stars | 28 |
% of votes with a positive feedback rating | 82% of 41 |
Total "Very Satisfied" Votes | 30 |
Total "Somewhat Satisfied" Votes | 7 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |