205件ヒット
[1-100件を表示]
(0.333秒)
クラス
- Enumerator (22)
- Hash (56)
- Matrix (44)
-
Prime
:: PseudoPrimeGenerator (44)
モジュール
- Enumerable (39)
検索結果
先頭5件
-
Enumerable
# each _ with _ index(*args) -> Enumerator (18121.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx......]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (18121.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx......]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Matrix
# each _ with _ index(which = :all) -> Enumerator (18109.0) -
行列の各要素をその位置とともに引数としてブロックを呼び出します。
...ださい。
ブロックを省略した場合、 Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
puts "#{e} at #{row}, #{col}"
end
# => 1 at 0, 0
# => 2 at 0, 1
# => 3 at 1, 0
# => 4 at 1, 1
//}
@param which... -
Matrix
# each _ with _ index(which = :all) {|e , row , col| . . . } -> self (18109.0) -
行列の各要素をその位置とともに引数としてブロックを呼び出します。
...ださい。
ブロックを省略した場合、 Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
puts "#{e} at #{row}, #{col}"
end
# => 1 at 0, 0
# => 2 at 0, 1
# => 3 at 1, 0
# => 4 at 1, 1
//}
@param which... -
Prime
:: PseudoPrimeGenerator # each _ with _ index -> Enumerator (18109.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
...を返します。 ブロックを与えられなかった場合は 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_index... -
Prime
:: PseudoPrimeGenerator # each _ with _ index {|prime , index| . . . } -> self (18109.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
...を返します。 ブロックを与えられなかった場合は 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_index... -
Prime
:: PseudoPrimeGenerator # with _ index -> Enumerator (3009.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
...を返します。 ブロックを与えられなかった場合は 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_index... -
Prime
:: PseudoPrimeGenerator # with _ index {|prime , index| . . . } -> self (3009.0) -
与えられたブロックに対して、素数を0起点の連番を渡して評価します。
...を返します。 ブロックを与えられなかった場合は 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_index... -
Enumerable
# to _ h(*args) -> Hash (7.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}
//}......Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアと... -
Enumerable
# to _ h(*args) { . . . } -> Hash (7.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアと...