39件ヒット
[1-39件を表示]
(0.076秒)
検索結果
先頭5件
-
Enumerable
# lazy -> Enumerator :: Lazy (18363.0) -
自身を lazy な Enumerator に変換したものを返します。
...自身を lazy な Enumerator に変換したものを返します。
この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* r......のみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみlazy)
以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の組) を
列挙するプログラムです。
//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat......数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです
# 100より小さいピタゴラス数を表示する
p pythagorean_triples.take_while { |*, z| z < 100 }.force
//}
@see Enumerator::Lazy... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (12370.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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.e......ven? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (9270.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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.e......ven? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (6271.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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.e......ven? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (6271.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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.e......ven? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select...