16件ヒット
[1-16件を表示]
(0.059秒)
クラス
-
Enumerator
:: Lazy (5)
モジュール
- Enumerable (11)
検索結果
-
Enumerator
:: Lazy # eager -> Enumerator (18134.0) -
自身を遅延評価しない Enumerator に変換して返します。
...ch.lazy
# select が遅延評価されるので終了する
p lazy_enum.class # => Enumerator::Lazy
p lazy_enum.select { |n| n.even? }.first(5)
# => [2, 4, 6, 8, 10]
# select が遅延評価されないので終了しない
enum = lazy_enum.eager
p enum.class # => Enumerator
p enum.select { |n| n.... -
Enumerable
# lazy -> Enumerator :: Lazy (21.0) -
自身を lazy な Enumerator に変換したものを返します。
...行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)......(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです...