種類
- インスタンスメソッド (302)
- 特異メソッド (11)
- クラス (11)
ライブラリ
- ビルトイン (324)
クラス
-
Enumerator
:: Lazy (302)
モジュール
- Enumerable (11)
キーワード
- Lazy (11)
- chunk (22)
- collect (11)
-
collect
_ concat (11) - drop (11)
-
drop
_ while (11) - filter (6)
-
filter
_ map (5) -
find
_ all (11) -
flat
_ map (11) - grep (11)
-
grep
_ v (9) - lazy (11)
- map (11)
- new (11)
- reject (11)
- select (11)
-
slice
_ after (20) -
slice
_ before (33) -
slice
_ when (10) - take (11)
-
take
_ while (22) -
with
_ index (10) - zip (22)
検索結果
先頭5件
-
Enumerator
:: Lazy # force(*args) -> [object] (32107.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]
//}... -
Enumerator
:: Lazy . new(obj , size=nil) {|yielder , *values| . . . } -> Enumerator :: Lazy (14261.0) -
Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を 指定できます。
...Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに
よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ
ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を
指定で......ter_map と、その遅延評価版を定義する例][ruby]{
module Enumerable
def filter_map(&block)
map(&block).compact
end
end
class Enumerator::Lazy
def filter_map
Lazy.new(self) do |yielder, *values|
result = yield *values
yielder << result if result
end
end
en......d
1.step.lazy.filter_map{|i| i*i if i.even?}.first(5)
# => [4, 16, 36, 64, 100]
//}
@raise ArgumentError 引数を指定しなかった場合、ブロックを指定しなかった場合に発生します。
@see Enumerator.new... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (14254.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...じですが、配列ではなく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.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.force.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}
@see Enumerable#take_while... -
Enumerator
:: Lazy # take _ while {|item| . . . } -> Enumerator :: Lazy (14254.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...じですが、配列ではなく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.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.force.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}
@see Enumerable#take_while... -
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (14247.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
...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/).take(10).force
#......=> ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}
@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (14247.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
...く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/).take(15).force
#......=> ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}
@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep... -
Enumerator
:: Lazy # zip(*lists) -> Enumerator :: Lazy (14247.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:z......ip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see Enumerable#zip... -
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (14243.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.laz......y.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (14243.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.laz......y.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (14243.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.laz......y.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # slice _ before {|elt| bool } -> Enumerator :: Lazy (14243.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...が、配列ではなく 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...