ライブラリ
クラス
-
ARGF
. class (238) - Addrinfo (22)
- Array (625)
- Date (66)
- Dir (106)
- Enumerator (194)
-
Enumerator
:: ArithmeticSequence (84) -
Enumerator
:: Chain (36) -
Enumerator
:: Lazy (389) -
Enumerator
:: Yielder (27) -
Etc
:: Group (22) -
Etc
:: Passwd (22) -
Gem
:: SourceIndex (22) - Hash (310)
- IO (304)
- Integer (88)
- Matrix (214)
- Numeric (84)
- Object (70)
- OpenStruct (22)
- Pathname (114)
- Prime (44)
-
Prime
:: PseudoPrimeGenerator (77) -
Psych
:: Nodes :: Node (22) -
REXML
:: Parent (88) - Range (84)
- StopIteration (11)
- String (190)
- StringIO (166)
- Struct (78)
- Vector (145)
-
Zlib
:: GzipReader (66)
モジュール
- Enumerable (721)
- Find (22)
- Kernel (55)
- ObjectSpace (44)
- TSort (120)
オブジェクト
- ENV (244)
-
Readline
:: HISTORY (22)
キーワード
- % (12)
- + (6)
- << (11)
- == (6)
- ArithmeticSequence (6)
- Chain (6)
- Enumerable (11)
- Fiber (11)
- Lazy (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
- Yielder (11)
- ascend (22)
- begin (6)
- bsearch (44)
-
bsearch
_ index (18) - build (22)
- bytes (42)
- chain (6)
- chars (42)
- chunk (33)
-
chunk
_ while (19) - codepoints (42)
- collect (99)
- collect! (46)
- collect2 (22)
-
collect
_ concat (33) - combination (22)
- combine (14)
- compact (3)
- cycle (44)
-
delete
_ if (88) - descend (22)
- detect (22)
- downto (44)
- drop (11)
-
drop
_ while (55) - each (574)
- each2 (22)
-
each
_ byte (110) -
each
_ char (88) -
each
_ child (84) -
each
_ codepoint (88) -
each
_ cons (22) -
each
_ entry (26) -
each
_ grapheme _ cluster (14) -
each
_ index (44) -
each
_ key (44) -
each
_ line (198) -
each
_ object (44) -
each
_ pair (88) -
each
_ prime (22) -
each
_ slice (22) -
each
_ strongly _ connected _ component (40) -
each
_ strongly _ connected _ component _ from (40) -
each
_ value (44) -
each
_ with _ index (66) -
each
_ with _ object (22) - eager (5)
- end (6)
-
enum
_ for (44) -
exclude
_ end? (6) - feed (11)
- filter (66)
- filter! (36)
-
filter
_ map (15) - find (66)
-
find
_ all (33) -
find
_ index (99) - first (12)
-
flat
_ map (33) - force (11)
- foreach (88)
- grep (11)
-
grep
_ v (9) -
group
_ by (22) - gsub (77)
- gsub! (44)
- hash (6)
- index (66)
- inspect (12)
-
keep
_ if (66) - last (12)
- lazy (22)
- lines (98)
- loop (22)
- map (99)
- map! (46)
- map2 (11)
-
max
_ by (44) -
min
_ by (44) -
minmax
_ by (22) - new (35)
- next (11)
-
next
_ values (11) - optparse (11)
- partition (22)
- peek (11)
-
peek
_ values (11) - permutation (22)
- prime (11)
- produce (5)
- reject (99)
- reject! (66)
-
repeated
_ combination (22) -
repeated
_ permutation (22) - result (11)
-
reverse
_ each (44) - rewind (28)
- rindex (33)
-
ruby 1
. 9 feature (11) - select (121)
- select! (66)
- size (23)
-
slice
_ after (42) -
slice
_ before (55) -
slice
_ when (21) -
sort
_ by (22) -
sort
_ by! (22) - step (140)
- take (11)
-
take
_ while (66) - then (12)
- times (22)
-
to
_ enum (44) -
to
_ proc (5) -
transform
_ keys (17) -
transform
_ keys! (17) -
transform
_ values (16) -
transform
_ values! (16) -
tsort
_ each (40) - uniq (16)
- upto (44)
-
with
_ index (54) -
with
_ object (44) - yield (11)
-
yield
_ self (14) - zip (22)
検索結果
先頭5件
- Enumerator
# rewind -> self - 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
# rewind -> self (21006.0) -
列挙状態を巻き戻します。
...が rewind メソッドを持つとき(respond_to?(:rewind) に
真を返すとき) は、その rewind メソッドを呼び出します。
@see Enumerator#next
//emlist[例][ruby]{
str = "xyz"
enum = str.each_byte
p enum.next # => 120
p enum.next # => 121
enum.rewind
p enum.next # => 120
//}... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (3150.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) #=> [1,1,2,2,3,3]
def repeat(n)
ra......map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerator のときは Enumerator に、
# もとが Lazy のときは Lazy になる
//}... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (3150.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) #=> [1,1,2,2,3,3]
def repeat(n)
ra......map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerator のときは Enumerator に、
# もとが Lazy のときは Lazy になる
//}... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy (3150.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) #=> [1,1,2,2,3,3]
def repeat(n)
ra......map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerator のときは Enumerator に、
# もとが Lazy のときは Lazy になる
//}... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (3150.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) #=> [1,1,2,2,3,3]
def repeat(n)
ra......map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
# Lazy#to_enum のおかげで、repeat の返り値は
# もとが Enumerator のときは Enumerator に、
# もとが Lazy のときは Lazy になる
//}... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (3148.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... -
Enumerator
:: Lazy # take _ while {|item| . . . } -> Enumerator :: Lazy (3148.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... -
Enumerator
:: Lazy . new(obj , size=nil) {|yielder , *values| . . . } -> Enumerator :: Lazy (3145.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 # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (3141.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#grep と同じですが、配列ではなく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::INFINIT......Y).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 (3141.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#grep_v と同じですが、配列ではなく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::INFINIT......Y).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...