Complete the code to create a lazy enumerator from an array.
numbers = [1, 2, 3, 4, 5] lazy_enum = numbers.[1]
The lazy method converts an enumerable into a lazy enumerator, allowing deferred computation.
Complete the code to get the first 3 even numbers lazily.
numbers = (1..Float::INFINITY).lazy result = numbers.select { |n| n.even? }.[1](3).force
The take method selects the first N elements lazily before forcing evaluation.
Fix the error in the code to lazily map and select odd numbers.
numbers = (1..10).lazy result = numbers.[1] { |n| n * 2 }.select(&:odd?).force
The map method transforms each element lazily before selection.
Fill both blanks to create a lazy enumerator that drops the first 5 elements and takes the next 3.
numbers = (1..100).lazy result = numbers.[1](5).[2](3).force
drop skips the first N elements lazily, and take selects the next N elements lazily.
Fill all three blanks to create a lazy enumerator that maps numbers to their squares and selects those greater than 10.
numbers = (1..10).lazy result = numbers.[1] { |n| n * n }.[2] { |n| n [3] 10 }.force
map transforms numbers to their squares, select filters those greater than 10.