るりまサーチ

最速Rubyリファレンスマニュアル検索!
351件ヒット [1-100件を表示] (0.127秒)

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Matrix#each(which = :all) -> Enumerator (21251.0)

行列の各要素を引数としてブロックを呼び出します。

...:lower 対角成分とそれより下側の部分
* :upper対角成分とそれより上側の部分
* :strict_lower 対角成分の下側
* :strict_upper 対角成分の上側

ブロックを省略した場合、 Enumerator を返します。

//emlist[例][ruby]{
r
equire 'matrix'
Matrix[ [...
...1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
//}

@
param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@
see Matrix#each_with_index, Matrix#map...

Matrix#each(which = :all) {|e| ... } -> self (21151.0)

行列の各要素を引数としてブロックを呼び出します。

...:lower 対角成分とそれより下側の部分
* :upper対角成分とそれより上側の部分
* :strict_lower 対角成分の下側
* :strict_upper 対角成分の上側

ブロックを省略した場合、 Enumerator を返します。

//emlist[例][ruby]{
r
equire 'matrix'
Matrix[ [...
...1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
//}

@
param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@
see Matrix#each_with_index, Matrix#map...

Matrix#map(which = :all) -> Enumerator (18257.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...merator を返します。

@
param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each...
...の項目を参照して下さい。

//emlist[例][ruby]{
r
equire 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
p m.map(:diagonal) { |x| x * 10 } # => Matrix[[10, 2], [3, 40]]
//}

@
see Matrix#each, Matrix#map!...

Matrix#map(which = :all) {|x| ... } -> Matrix (18257.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...merator を返します。

@
param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each...
...の項目を参照して下さい。

//emlist[例][ruby]{
r
equire 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
p m.map(:diagonal) { |x| x * 10 } # => Matrix[[10, 2], [3, 40]]
//}

@
see Matrix#each, Matrix#map!...

Matrix#map -> Enumerator (18233.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...適用を繰り返した結果を、要素として持つ行列を生成します。

ブロックがない場合、 Enumerator を返します。


//emlist[例][ruby]{
r
equire 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
//}

@
see Matrix#each...

絞り込み条件を変える

Matrix#map {|x| ... } -> Matrix (18233.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...適用を繰り返した結果を、要素として持つ行列を生成します。

ブロックがない場合、 Enumerator を返します。


//emlist[例][ruby]{
r
equire 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
//}

@
see Matrix#each...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) -> Enumerator (15489.0)

node から到達可能な強連結成分についてのイテレータです。

...せん。

each
_strongly_connected_component_from は
tsort_each_node を呼びません。

@
param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
r
equire 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(no...
...de, &block)
fetch(node).each(&block)
end
end

non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}...
...}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@
see TSort.each_strongly_connected_component_from...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) {|nodes| ...} -> () (15489.0)

node から到達可能な強連結成分についてのイテレータです。

...せん。

each
_strongly_connected_component_from は
tsort_each_node を呼びません。

@
param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
r
equire 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(no...
...de, &block)
fetch(node).each(&block)
end
end

non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}...
...}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@
see TSort.each_strongly_connected_component_from...

Enumerator::Lazy#flat_map {|item| ... } -> Enumerator::Lazy (6274.0)

ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。

...つに繋げたものに対してイテレートするような
Enumerator::Lazy のインスタンスを返します。

//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}

ブロックの返した値 x は、以下の場合にのみ...
...るか、to_ary メソッドを持つとき
* x が each および force メソッドを持つ (例:Enumerator::Lazy) とき

それ以外のときは、x は分解されず、そのままの値として使われます。

//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1},...
...{:b=>2}]
//}

@
raise ArgumentError ブロックを指定しなかった場合に発生します。

@
see Enumerable#flat_map...

Object#enum_for(method = :each, *args) -> Enumerator (6271.0)

Enumerator.new(self, method, *args) を返します。

...Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@
param method メソッド名の文字列かシンボルです。
@
param args 呼び出...
...][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep...
...)
r
aise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
r
eturn to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
...

絞り込み条件を変える

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (6271.0)

Enumerator.new(self, method, *args) を返します。

...Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@
param method メソッド名の文字列かシンボルです。
@
param args 呼び出...
...][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep...
...)
r
aise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
r
eturn to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
...
<< 1 2 3 ... > >>