6 kyu

Infinite Sequences

80 of 202Mackay

Description:

Write a method which defines an infinite sequence for a given rule, and allows use of the #take and #take_while methods (JS: take and takeWhile property) to get 'n' elements of the sequence, or all elements that match a condition.

Example:

sequence {|n| n}.take_while {|n| n < 10} => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sequence {|n| (n * n)}.take(10) => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Fundamentals

Stats:

CreatedOct 17, 2014
PublishedOct 17, 2014
Warriors Trained558
Total Skips113
Total Code Submissions614
Total Times Completed202
Ruby Completions80
JavaScript Completions127
Total Stars22
% of votes with a positive feedback rating94% of 76
Total "Very Satisfied" Votes69
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes2
Total Rank Assessments14
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Mackay Avatar
  • ZozoFouchtra Avatar
  • Voile Avatar
Ad