別のキーワード
種類
- インスタンスメソッド (239)
- 文書 (17)
- クラス (11)
- 特異メソッド (11)
ライブラリ
- ビルトイン (261)
クラス
-
Enumerator
:: Lazy (250)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (4) - chunk (22)
- collect (11)
- drop (11)
-
drop
_ while (11) - filter (6)
-
filter
_ map (5) -
find
_ all (11) - force (11)
- map (11)
- new (11)
- reject (11)
- select (11)
-
slice
_ after (20) -
slice
_ before (33) -
slice
_ when (10) - take (11)
-
take
_ while (22) - zip (22)
検索結果
先頭5件
-
Enumerator
:: Lazy (18054.0) -
map や select などのメソッドの遅延評価版を提供するためのクラス。
...* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブジェクトは、Enumerable#lazyメソッドによって生成されます。
Lazyから値を取り出すには、Enumerator::Lazy#force または
Enumerable#first を呼びます。
//emlist[例][ruby]{......して偶数になるような整数を、小さい方から5個表示する
p 1.step.lazy.select{|n| (n**2).even?}.first(5)
# LTSV (http://ltsv.org/) 形式のログファイルから検索を行う
# Enumerator::Lazy#map は配列ではなく Enumerator を返すため、
# 巨大な配列を確......保しようとしてメモリを使い切ったりはしない
open("log.txt"){|f|
f.each_line.lazy.map{|line|
Hash[line.split(/\t/).map{|s| s.split(/:/, 2)}]
}.select{|hash|
hash["req"] =~ /GET/ && hash["status"] == "200"
}.each{|hash|
p hash
}
}
//}... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (3166.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').c... -
Enumerator
:: Lazy # take _ while {|item| . . . } -> Enumerator :: Lazy (3166.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').c... -
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (3161.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.even... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (3161.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.even... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (3161.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.even... -
Enumerator
:: Lazy # collect {|item| . . . } -> Enumerator :: Lazy (3160.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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 }.ta... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (3160.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.even... -
Enumerator
:: Lazy # map {|item| . . . } -> Enumerator :: Lazy (3160.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...ではなく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 }.ta... -
Enumerator
:: Lazy # select {|item| . . . } -> Enumerator :: Lazy (3160.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.even... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (3159.0) -
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
...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... -
Enumerator
:: Lazy # drop _ while {|item| . . . } -> Enumerator :: Lazy (3159.0) -
Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...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...