クラス
-
Enumerator
:: Lazy (34)
モジュール
- Enumerable (3)
- GC (1)
キーワード
- chunk (2)
-
chunk
_ while (1) - collect (1)
-
collect
_ concat (1) - drop (1)
-
drop
_ while (1) -
enum
_ for (2) - filter (1)
-
find
_ all (1) -
flat
_ map (1) - force (1)
-
garbage
_ collect (1) - grep (1)
-
grep
_ v (1) - map (1)
- reject (1)
- select (1)
-
slice
_ after (2) -
slice
_ before (3) -
slice
_ when (1) - sum (2)
- take (1)
-
take
_ while (2) -
to
_ enum (2) - uniq (2)
- zip (2)
検索結果
先頭5件
-
Enumerator
:: Lazy # lazy -> self (63457.0) -
self を返します。
self を返します。
//emlist[例][ruby]{
lazy = (100..Float::INFINITY).lazy
p lazy.lazy # => #<Enumerator::Lazy: 100..Infinity>
p lazy == lazy.lazy # => true
//} -
Enumerable
# lazy -> Enumerator :: Lazy (54754.0) -
自身を lazy な Enumerator に変換したものを返します。
自身を lazy な Enumerator に変換したものを返します。
この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみl... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (9496.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (9496.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy (9496.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (9496.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (9469.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/).... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (9469.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/).t... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (9454.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>
1.step.lazy.... -
Enumerator
:: Lazy # take _ while {|item| . . . } -> Enumerator :: Lazy (9454.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>
1.step.lazy.... -
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (9439.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:find_all>
1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6,... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (9439.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:find_all>
1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6,... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (9439.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:find_all>
1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6,... -
Enumerator
:: Lazy # collect {|item| . . . } -> Enumerator :: Lazy (9436.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>
1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4, 5, 6, 7, 8,... -
Enumerator
:: Lazy # collect _ concat {|item| . . . } -> Enumerator :: Lazy (9436.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
ブロックの実行結果をひとつに繋げたものに対してイテレートするような
Enumerator::Lazy のインスタンスを返します。
//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結されます。
* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッドを持つ (例:Enumerator::Lazy) ... -
Enumerator
:: Lazy # flat _ map {|item| . . . } -> Enumerator :: Lazy (9436.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
ブロックの実行結果をひとつに繋げたものに対してイテレートするような
Enumerator::Lazy のインスタンスを返します。
//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結されます。
* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッドを持つ (例:Enumerator::Lazy) ... -
Enumerator
:: Lazy # map {|item| . . . } -> Enumerator :: Lazy (9436.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>
1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4, 5, 6, 7, 8,... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (9433.0) -
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
@param n 要素数を指定します。
@raise ArgumentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.drop(3)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop(3)>
1.step.lazy.drop(3).take(10).force
# => [4, 5, 6, 7, 8, 9, 10, 1... -
Enumerator
:: Lazy # drop _ while {|item| . . . } -> Enumerator :: Lazy (9433.0) -
Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.drop_while { |i| i < 42 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop_while>
1.step.lazy.drop_while { |i| i < 42 }.take(10).force
# => [42, 43, 44, 45, 46, 47, 48, 49, 50, 51]
//... -
Enumerator
:: Lazy # reject {|item| . . . } -> Enumerator :: Lazy (9433.0) -
Enumerable#reject と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#reject と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.reject { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:reject>
1.step.lazy.reject { |i| i.even? }.take(10).force
# => [1, 3, 5, 7, ... -
Enumerator
:: Lazy # take(n) -> Enumerator :: Lazy (9433.0) -
Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
n が大きな数 (100000とか) の場合に備えて再定義されています。
配列が必要な場合は Enumerable#first を使って下さい。
@param n 要素数を指定します。
@raise ArgumentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.take(5)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:... -
Enumerator
:: Lazy # zip(*lists) -> Enumerator :: Lazy (9433.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle)... -
Enumerator
:: Lazy # slice _ before {|elt| bool } -> Enumerator :: Lazy (9421.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5], [6... -
Enumerator
:: Lazy # slice _ before(initial _ state) {|elt , state| bool } -> Enumerator :: Lazy (9421.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5], [6... -
Enumerator
:: Lazy # slice _ before(pattern) -> Enumerator :: Lazy (9421.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5], [6... -
Enumerator
:: Lazy # chunk {|elt| . . . } -> Enumerator :: Lazy (9418.0) -
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>
1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5... -
Enumerator
:: Lazy # chunk(initial _ state) {|elt , state| . . . } -> Enumerator :: Lazy (9418.0) -
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>
1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5... -
Enumerator
:: Lazy # slice _ after {|elt| bool } -> Enumerator :: Lazy (9418.0) -
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>
1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3], [4, 5, 6], [... -
Enumerator
:: Lazy # slice _ after(pattern) -> Enumerator :: Lazy (9418.0) -
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>
1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3], [4, 5, 6], [... -
Enumerator
:: Lazy # slice _ when {|elt _ before , elt _ after| bool } -> Enumerator :: Lazy (9415.0) -
Enumerable#slice_when と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#slice_when と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007fce84118348>:each>>
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }.take(5).force
# => [[1, 2]... -
Enumerator
:: Lazy # uniq -> Enumerator :: Lazy (9364.0) -
Enumerable#uniq と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#uniq と同じですが、配列ではなく Enumerator::Lazy を返します。 -
Enumerator
:: Lazy # uniq {|item| . . . } -> Enumerator :: Lazy (9364.0) -
Enumerable#uniq と同じですが、配列ではなく Enumerator::Lazy を返します。
Enumerable#uniq と同じですが、配列ではなく Enumerator::Lazy を返します。 -
Enumerator
:: Lazy # chunk _ while {|elt _ before , elt _ after| . . . } -> Enumerator :: Lazy (9361.0) -
Enumerable#chunk_while と同じですが、Enumerator ではなく Enumerator::Lazy を返します。
Enumerable#chunk_while と同じですが、Enumerator ではなく Enumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。 -
Enumerator
:: Lazy # zip(*lists) {|v1 , v2 , . . . | . . . } -> nil (9133.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle)... -
Enumerator
:: Lazy # force(*args) -> [object] (9094.0) -
全ての要素を含む配列を返します。Lazy から実際に値を取り出すのに使います。
全ての要素を含む配列を返します。Lazy から実際に値を取り出すのに使います。
Enumerable#to_a のエイリアスです。
//emlist[例][ruby]{
1.step.lazy.take(10).force
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1.step.lazy.take(10).to_a
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//} -
Enumerable
# sum(init=0) -> object (28.0) -
要素の合計を返します。
要素の合計を返します。
ブロックが与えられた場合、加算する前に各要素にブロックが適用されます。
selfが空の場合、initを返します。
//emlist[例][ruby]{
{ 1 => 10, 2 => 20 }.sum {|k, v| k * v } # => 50
(1..10).sum # => 55
(1..10).sum {|v| v * 2 } # => 110
('a'..'z').sum # => TypeError
... -
Enumerable
# sum(init=0) {|e| expr } -> object (28.0) -
要素の合計を返します。
要素の合計を返します。
ブロックが与えられた場合、加算する前に各要素にブロックが適用されます。
selfが空の場合、initを返します。
//emlist[例][ruby]{
{ 1 => 10, 2 => 20 }.sum {|k, v| k * v } # => 50
(1..10).sum # => 55
(1..10).sum {|v| v * 2 } # => 110
('a'..'z').sum # => TypeError
... -
GC
# garbage _ collect(full _ mark: true , immediate _ sweep: true) -> nil (28.0) -
ガーベージコレクトを開始します。
ガーベージコレクトを開始します。
GC.start や ObjectSpace.#garbage_collect と同じ働きをします。
GC.disable により GC が禁止されている場合でもガベージコレクトを開始します。
nil を返します。
@param full_mark マイナー GC を動作させる場合は false を、そうでない場
合は true を指定します。
@param immediate_sweep sweep を遅らせる(Lazy Sweep を行う)場合は false
を、そう...