るりまサーチ

最速Rubyリファレンスマニュアル検索!
446件ヒット [1-100件を表示] (0.098秒)
トップページ > クエリ:-[x] > クエリ:ruby[x] > クエリ:h[x] > クエリ:map[x]

別のキーワード

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

検索結果

<< 1 2 3 ... > >>

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

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

...ます。

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

//emlist[例][ruby]{
require '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 (15326.0)

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

...ます。

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

//emlist[例][ruby]{
require '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!...

Array#map -> Enumerator (15226.0)

各要素に対してブロックを評価した結果を全て含む配列を返します。

...してブロックを評価した結果を全て含む配列を返します。

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

//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}

@see Hash#to_h, Enumerable#collect, Enumerable#map...

Array#map {|item| ... } -> [object] (15226.0)

各要素に対してブロックを評価した結果を全て含む配列を返します。

...してブロックを評価した結果を全て含む配列を返します。

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

//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}

@see Hash#to_h, Enumerable#collect, Enumerable#map...

Enumerable#map -> Enumerator (15226.0)

各要素に対してブロックを評価した結果を全て含む配列を返します。

...配列を返します。

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

//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}

@see Hash#to_h, Array#collect, Array#map...

絞り込み条件を変える

Enumerable#map {|item| ... } -> [object] (15226.0)

各要素に対してブロックを評価した結果を全て含む配列を返します。

...配列を返します。

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

//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}

@see Hash#to_h, Array#collect, Array#map...

Encoding.locale_charmap -> String | nil (12342.0)

ロケールエンコーディングを決定するために用いる、locale charmap 名を返します。nl_langinfo 等がない環境では nil を、miniruby では ASCII_8BIT を返します。

...locale charmap 名を返します。nl_langinfo 等がない環境では nil を、miniruby では ASCII_8BIT を返します。

//emlist[Debian GNU/Linux + LANG=C][ruby]{
Encoding.locale_charmap #=> "ANSI_X3.4-1968"
//}

//emlist[LANG=ja_JP.EUC-JP][ruby]{
Encoding.locale_charmap #=> "EUC-JP"
//}...
...//emlist[SunOS 5 + LANG=C][ruby]{
Encoding.locale_charmap #=> "646"
//}

//emlist[SunOS 5 + LANG=ja][ruby]{
Encoding.locale_charmap #=> "eucJP"
//}

@see charmap(5)...

Rake::FileList#pathmap(spec = nil) -> Rake::FileList (12306.0)

各要素に String#pathmap を適用した新しい Rake::FileList を返します。

...各要素に String#pathmap を適用した新しい Rake::FileList を返します。

//emlist[][ruby]{
# Rakefile での記載例とする

task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new("test1.rb", "test2.rb", "test3.rb")
file_list.pathmap("%n") # => ["test1", "...
...test2", "test3"]
end
//}

@see String#pathmap...

TSort.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) -> Enumerator (6408.0)

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

...e と each_child でグラフを表します。

返す値は規定されていません。

TSort.each_strongly_connected_component_fromはTSortをincludeして
グラフを表現する必要のないクラスメソッドです。

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

@param each_child 引...
...す。

//emlist[使用例][ruby]{
require 'tsort'

graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_child = lambda {|n, &b| graph[n].each(&b) }
TSort.each_strongly_connected_component_from(1, each_child) {|scc|
p scc
}
# => [4]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component...

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

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

...e と each_child でグラフを表します。

返す値は規定されていません。

TSort.each_strongly_connected_component_fromはTSortをincludeして
グラフを表現する必要のないクラスメソッドです。

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

@param each_child 引...
...す。

//emlist[使用例][ruby]{
require 'tsort'

graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_child = lambda {|n, &b| graph[n].each(&b) }
TSort.each_strongly_connected_component_from(1, each_child) {|scc|
p scc
}
# => [4]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component...

絞り込み条件を変える

Hash#to_h -> self | Hash (6356.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。

//emlist[例][ruby]{
h
ash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true

class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas...
...# => MyHash
p my_hash.to_h.class # => Hash
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
h
ash = { "a" => 97, "b" => 98 }
h
ash.to_h {|key, value| [key.upcase, value-32] } # =>...
...{"A"=>65, "B"=>66}
//}

@see Enumerable#map...

Hash#to_h {|key, value| block } -> Hash (6356.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。

//emlist[例][ruby]{
h
ash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true

class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas...
...# => MyHash
p my_hash.to_h.class # => Hash
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
h
ash = { "a" => 97, "b" => 98 }
h
ash.to_h {|key, value| [key.upcase, value-32] } # =>...
...{"A"=>65, "B"=>66}
//}

@see Enumerable#map...

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

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

...

each_strongly_connected_component_from は
tsort_each_node を呼びません。

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

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

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &b...
...lock)
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...
<< 1 2 3 ... > >>