827件ヒット
[201-300件を表示]
(0.117秒)
別のキーワード
クラス
- Array (96)
-
Enumerator
:: Lazy (100) - Exception (12)
- Hash (24)
- Matrix (76)
- Object (60)
-
ObjectSpace
:: WeakMap (12) -
Rake
:: FileList (12) - Set (24)
-
Thread
:: Backtrace :: Location (24) - Vector (148)
-
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (204)
- TSort (23)
キーワード
- == (12)
- []= (12)
-
absolute
_ path (12) -
chunk
_ while (12) - collect (96)
- collect! (64)
- collect2 (24)
-
default
_ event _ sources (12) -
each
_ strongly _ connected _ component _ from (23) -
elements
_ to _ f (12) -
elements
_ to _ i (12) -
elements
_ to _ r (12) -
enum
_ for (48) -
filter
_ map (18) -
flat
_ map (36) - grep (12)
-
grep
_ v (10) - inspect (12)
- lazy (12)
- map! (64)
- map2 (12)
- pathmap (12)
-
slice
_ after (24) -
slice
_ before (24) -
slice
_ when (12) -
sort
_ by (24) - sum (12)
- tap (12)
-
to
_ enum (48) -
to
_ h (14) -
to
_ proc (10)
検索結果
先頭5件
-
Vector
# map! {|element| . . . } -> self (6233.0) -
ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。
...素を置き換えます。
ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。
//emlist[例][ruby]{
require 'matrix'
v = Vector[1, 2, 3]
p v.map!{ |el| el * 2 } #=> Vector[2, 4, 6]
p v #=> Vector[2, 4, 6]
//}... -
Enumerator
:: Lazy # flat _ map {|item| . . . } -> Enumerator :: Lazy (6232.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 は、以下の場合にのみ......それ以外のときは、x は分解されず、そのままの値として使われます。
//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}
@raise ArgumentError ブロックを指定しなかった場合に発生します。
@see Enumerable#flat_map... -
Enumerable
# flat _ map -> Enumerator (6221.0) -
各要素をブロックに渡し、その返り値を連結した配列を返します。
...ックに渡し、その返り値を連結した配列を返します。
ブロックの返り値は基本的に配列を返すべきです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
//}... -
Enumerable
# flat _ map {| obj | block } -> Array (6221.0) -
各要素をブロックに渡し、その返り値を連結した配列を返します。
...ックに渡し、その返り値を連結した配列を返します。
ブロックの返り値は基本的に配列を返すべきです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
//}... -
Set
# map! {|o| . . . } -> self (6220.0) -
集合の各要素についてブロックを評価し、その結果で元の集合を置き換えます。
...集合の各要素についてブロックを評価し、その結果で元の集合を置き換えます。
//emlist[][ruby]{
require 'set'
set = Set['hello', 'world']
set.map! {|str| str.capitalize}
p set # => #<Set: {"Hello", "World"}>
//}
@see Enumerable#collect......集合の各要素についてブロックを評価し、その結果で元の集合を置き換えます。
//emlist[][ruby]{
set = Set['hello', 'world']
set.map! {|str| str.capitalize}
p set # => #<Set: {"Hello", "World"}>
//}
@see Enumerable#collect... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (6215.0) -
node から到達可能な強連結成分についてのイテレータです。
...返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node......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| . . . } -> () (6215.0) -
node から到達可能な強連結成分についてのイテレータです。
...返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node......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... -
Hash
# to _ proc -> Proc (6213.0) -
self のキーに対応する値を返す Proc オブジェクトを返します。
...self のキーに対応する値を返す Proc オブジェクトを返します。
//emlist[][ruby]{
h = {1 => 10, 2 => 20, 3 => 30}
[1, 2, 3].map(&h) # => [10, 20, 30]
//}... -
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (6125.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
...rep と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&......:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}
@see Enumerable#grep......:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}
@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (6125.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
...rep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&......:to_s).grep_v(/(\d).*\1/).take(15).force
# => ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}
@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep...