зеркало из https://github.com/github/ruby.git
17 строки
566 B
YAML
17 строки
566 B
YAML
prelude: |
|
|
num = (1..).lazy.take(100)
|
|
ary2 = [[1,2]].cycle.lazy.take(10)
|
|
ary10 = [[*1..10]].cycle.lazy.take(10)
|
|
ary20 = [[*1..20]].cycle.lazy.take(10)
|
|
ary50 = [[*1..50]].cycle.lazy.take(10)
|
|
ary100 = [[*1..100]].cycle.lazy.take(10)
|
|
|
|
benchmark:
|
|
num3: num.flat_map {|x| x}.take(3).to_a
|
|
num10: num.flat_map {|x| x}.take(3).to_a
|
|
ary2: ary2.flat_map {|x| x}.take(3).to_a
|
|
ary10: ary10.flat_map {|x| x}.take(3).to_a
|
|
ary20: ary20.flat_map {|x| x}.take(3).to_a
|
|
ary50: ary50.flat_map {|x| x}.take(3).to_a
|
|
ary100: ary100.flat_map {|x| x}.take(3).to_a
|