別のキーワード
ライブラリ
- ビルトイン (255)
クラス
-
Enumerator
:: Lazy (250) - Range (5)
キーワード
- % (2)
- chunk (24)
- collect (12)
- drop (12)
-
drop
_ while (12) - filter (7)
-
filter
_ map (6) -
find
_ all (12) - map (12)
- reject (12)
- select (12)
-
slice
_ after (22) -
slice
_ before (36) -
slice
_ when (11) -
take
_ while (24) - zip (24)
検索結果
先頭5件
-
Enumerator
:: Lazy # take(n) -> Enumerator :: Lazy (18184.0) -
Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#take と同じですが、配列ではなくEnumerator::Lazy を返します。
n が大きな数 (100000とか) の場合に備えて再定義されています。
配列が必要な場合は Enumerable#first を使って下さい。
@param n 要素数を指定します。
@raise Argu......mentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.take(5)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:take(5)>
1.step.lazy.take(5).force
# => [1, 2, 3, 4, 5]
//}
@see Enumerable#take... -
Range
# step(s = 1) -> Enumerator (15182.0) -
範囲内の要素を s おきに繰り返します。
...。
@param s 次のステップへ遷移するたびに加算されるものを指定します。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence を返します。
@retur......Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
(10..0).step(-3) {|v| p v}
# => 10
# 7
# 4
# 1
//}
非数値の Range では、イ......に対する例][ruby]{
# Time の Range は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p... -
Range
# step(s = 1) -> Enumerator :: ArithmeticSequence (15182.0) -
範囲内の要素を s おきに繰り返します。
...。
@param s 次のステップへ遷移するたびに加算されるものを指定します。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence を返します。
@retur......Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
(10..0).step(-3) {|v| p v}
# => 10
# 7
# 4
# 1
//}
非数値の Range では、イ......に対する例][ruby]{
# Time の Range は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p... -
Range
# step(s = 1) {|item| . . . } -> self (15182.0) -
範囲内の要素を s おきに繰り返します。
...。
@param s 次のステップへ遷移するたびに加算されるものを指定します。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence を返します。
@retur......Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
(10..0).step(-3) {|v| p v}
# => 10
# 7
# 4
# 1
//}
非数値の Range では、イ......に対する例][ruby]{
# Time の Range は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (6173.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#take_while と同じですが、配列ではなく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 (6173.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#take_while と同じですが、配列ではなく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... -
Range
# %(s) -> Enumerator (82.0) -
範囲内の要素を s おきに繰り返します。
...。
@param s 次のステップへ遷移するたびに加算されるものを指定します。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence を返します。
@retur......Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
(10..0).step(-3) {|v| p v}
# => 10
# 7
# 4
# 1
//}
非数値の Range では、イ......に対する例][ruby]{
# Time の Range は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p... -
Range
# %(s) -> Enumerator :: ArithmeticSequence (82.0) -
範囲内の要素を s おきに繰り返します。
...。
@param s 次のステップへ遷移するたびに加算されるものを指定します。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence を返します。
@retur......Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
(10..0).step(-3) {|v| p v}
# => 10
# 7
# 4
# 1
//}
非数値の Range では、イ......に対する例][ruby]{
# Time の Range は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (49.0) -
Enumerable#drop と同じですが、配列ではなく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(10).force
# => [......4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
//}
@see Enumerable#drop... -
Enumerator
:: Lazy # collect {|item| . . . } -> Enumerator :: Lazy (43.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...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 }.take(10).force
# => [2, 3,......4, 5, 6, 7, 8, 9, 10, 11]
//}
@see Enumerable#map... -
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (43.0) -
Enumerable#select と同じですが、配列ではなく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? }.take(10).force
# => [2......, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # filter _ map {|item| . . . } -> Enumerator :: Lazy (43.0) -
Enumerable#filter_map と同じですが、配列ではなく Enumerator::Lazy を返します。
...します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.filter_map { |n| n * 2 if n.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: (1.step)>:filter_map>
1.step.lazy.filter_map { |n| n * 2 if n.even? }.take(10).force......# => [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
//}
@see Enumerable#filter_map... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (43.0) -
Enumerable#select と同じですが、配列ではなく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? }.take(10).force
# => [2......, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # map {|item| . . . } -> Enumerator :: Lazy (43.0) -
Enumerable#map と同じですが、配列ではなくEnumerator::Lazy を返します。
...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 }.take(10).force
# => [2, 3,......4, 5, 6, 7, 8, 9, 10, 11]
//}
@see Enumerable#map...