検索結果
先頭5件
- Enumerator
:: Lazy - Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy - Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy - Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy - Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy
-
Enumerator
:: Lazy (63187.0) -
map や select などのメソッドの遅延評価版を提供するためのクラス。
map や select などのメソッドの遅延評価版を提供するためのクラス。
動作は通常の Enumerator と同じですが、以下のメソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (37129.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 (37129.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 (37129.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 (37129.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) ... -
Enumerable
# lazy -> Enumerator :: Lazy (28087.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 # take _ while -> Enumerator :: Lazy (27859.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 (27859.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 . new(obj , size=nil) {|yielder , *values| . . . } -> Enumerator :: Lazy (27778.0) -
Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を 指定できます。
Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに
よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ
ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を
指定できます。
//emlist[Enumerable#filter_map と、その遅延評価版を定義する例][ruby]{
module Enumerable
def filter_map(&block)
map(&block).compact
end
end
class Enumerator::... -
Enumerator
:: Lazy # take(n) -> Enumerator :: Lazy (27748.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>>:...