別のキーワード
クラス
- Enumerator (1)
-
Enumerator
:: Lazy (1) - Hash (6)
-
Prime
:: PseudoPrimeGenerator (4)
モジュール
- Enumerable (4)
キーワード
-
each
_ with _ index (4) - filter! (2)
-
keep
_ if (2) - select! (2)
-
to
_ h (2)
検索結果
先頭5件
- Prime
:: PseudoPrimeGenerator # with _ index -> Enumerator - Prime
:: PseudoPrimeGenerator # with _ index {|prime , index| . . . } -> self - Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object - Enumerator
:: Lazy # with _ index(offset = 0) {|(*args) , idx| . . . } -> Enumerator :: Lazy - Prime
:: PseudoPrimeGenerator # each _ with _ index -> Enumerator
-
Prime
:: PseudoPrimeGenerator # with _ index -> Enumerator (63352.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
@return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は Enumerator を返します。
//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}
@see Enumerator#with_ind... -
Prime
:: PseudoPrimeGenerator # with _ index {|prime , index| . . . } -> self (63352.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
@return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は Enumerator を返します。
//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}
@see Enumerator#with_ind... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (54682.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。
インデックスは offset から始まります。
ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringi... -
Enumerator
:: Lazy # with _ index(offset = 0) {|(*args) , idx| . . . } -> Enumerator :: Lazy (54646.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。
インデックスは offset から始まります。
ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}
@see Enumerator#with_index -
Prime
:: PseudoPrimeGenerator # each _ with _ index -> Enumerator (27352.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
@return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は Enumerator を返します。
//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}
@see Enumerator#with_ind... -
Prime
:: PseudoPrimeGenerator # each _ with _ index {|prime , index| . . . } -> self (27352.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
@return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は Enumerator を返します。
//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}
@see Enumerator#with_ind... -
Enumerable
# each _ with _ index(*args) -> Enumerator (18700.0) -
要素とそのインデックスをブロックに渡して繰り返します。
要素とそのインデックスをブロックに渡して繰り返します。
ブロックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
#... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (18700.0) -
要素とそのインデックスをブロックに渡して繰り返します。
要素とそのインデックスをブロックに渡して繰り返します。
ブロックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
#... -
Enumerable
# to _ h(*args) -> Hash (322.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
self を [key, value] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ... -
Enumerable
# to _ h(*args) { . . . } -> Hash (322.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
self を [key, value] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ... -
Hash
# filter! -> Enumerator (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!... -
Hash
# filter! {|key , value| . . . } -> self | nil (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!... -
Hash
# keep _ if -> Enumerator (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!... -
Hash
# keep _ if {|key , value| . . . } -> self (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!... -
Hash
# select! -> Enumerator (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!... -
Hash
# select! {|key , value| . . . } -> self | nil (112.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
キーと値を引数としてブロックを評価した結果が真であるような要素を self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select!...