396件ヒット
[1-100件を表示]
(0.113秒)
別のキーワード
モジュール
- Enumerable (72)
キーワード
- === (12)
- [] (72)
-
_ dump (12) - combination (24)
- fetch (36)
-
force
_ quotes? (12) - inject (36)
-
marshal
_ dump (12) - permutation (12)
- reduce (36)
-
repeated
_ combination (24) - slice (72)
- synchronize (12)
-
write
_ headers? (12)
検索結果
先頭5件
-
ERB
# result(b=TOPLEVEL _ BINDING) -> String (21349.0) -
ERB を b の binding で実行し、結果の文字列を返します。
...ERB を b の binding で実行し、結果の文字列を返します。
@param b eRubyスクリプトが実行されるときのbinding
//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test1 = "foo"
test2 = "bar"
puts erb.result
# test foo
# test bar
//......}
@see ERB#result_with_hash... -
Array
# combination(n) -> Enumerator (6243.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
.../emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of l......th 0
a.combination(5).to_a #=> [] : no combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # =......> [1,2,3,4]
result #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
//}
@see Array#permutation, Array#repeated_combination... -
Array
# combination(n) {|c| block } -> self (6243.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
.../emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of l......th 0
a.combination(5).to_a #=> [] : no combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # =......> [1,2,3,4]
result #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
//}
@see Array#permutation, Array#repeated_combination... -
Array
# repeated _ combination(n) -> Enumerator (6243.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.repeated_combination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],......3]]
a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3],
# [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3],
# [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
a.repeated_combination(0).to_a......]] # one combination of length 0
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result << e} # => [1,2,3]
result #=> [[1,1... -
Array
# repeated _ combination(n) { |c| . . . } -> self (6243.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.repeated_combination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],......3]]
a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3],
# [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3],
# [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
a.repeated_combination(0).to_a......]] # one combination of length 0
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result << e} # => [1,2,3]
result #=> [[1,1... -
Enumerable
# inject(init = self . first) {|result , item| . . . } -> object (3381.0) -
リストのたたみこみ演算を行います。
...ロックを実行せずに nil を返します。
@param init 最初の result の値です。任意のオブジェクトが渡せます。
@param sym ブロックの代わりに使われるメソッド名を表す Symbol オブジェクトを指定します。
実行結果に対......が呼ばれます。
//emlist[例][ruby]{
# 合計を計算する。
p [2, 3, 4, 5].inject {|result, item| result + item } #=> 14
# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}
この式は......以下のように書いても同じ結果が得られます。
//emlist[例][ruby]{
result = 0
[1, 2, 3, 4, 5].each {|v| result += v }
p result # => 15
p [1, 2, 3, 4, 5].inject(:+) #=> 15
p ["b", "c", "d"].inject("abbccddde", :squeeze) #=> "abcde"
//}... -
Enumerable
# reduce(init = self . first) {|result , item| . . . } -> object (3381.0) -
リストのたたみこみ演算を行います。
...ロックを実行せずに nil を返します。
@param init 最初の result の値です。任意のオブジェクトが渡せます。
@param sym ブロックの代わりに使われるメソッド名を表す Symbol オブジェクトを指定します。
実行結果に対......が呼ばれます。
//emlist[例][ruby]{
# 合計を計算する。
p [2, 3, 4, 5].inject {|result, item| result + item } #=> 14
# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}
この式は......以下のように書いても同じ結果が得られます。
//emlist[例][ruby]{
result = 0
[1, 2, 3, 4, 5].each {|v| result += v }
p result # => 15
p [1, 2, 3, 4, 5].inject(:+) #=> 15
p ["b", "c", "d"].inject("abbccddde", :squeeze) #=> "abcde"
//}... -
Enumerable
# inject(init , sym) -> object (3281.0) -
リストのたたみこみ演算を行います。
...ロックを実行せずに nil を返します。
@param init 最初の result の値です。任意のオブジェクトが渡せます。
@param sym ブロックの代わりに使われるメソッド名を表す Symbol オブジェクトを指定します。
実行結果に対......が呼ばれます。
//emlist[例][ruby]{
# 合計を計算する。
p [2, 3, 4, 5].inject {|result, item| result + item } #=> 14
# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}
この式は......以下のように書いても同じ結果が得られます。
//emlist[例][ruby]{
result = 0
[1, 2, 3, 4, 5].each {|v| result += v }
p result # => 15
p [1, 2, 3, 4, 5].inject(:+) #=> 15
p ["b", "c", "d"].inject("abbccddde", :squeeze) #=> "abcde"
//}... -
Enumerable
# inject(sym) -> object (3281.0) -
リストのたたみこみ演算を行います。
...ロックを実行せずに nil を返します。
@param init 最初の result の値です。任意のオブジェクトが渡せます。
@param sym ブロックの代わりに使われるメソッド名を表す Symbol オブジェクトを指定します。
実行結果に対......が呼ばれます。
//emlist[例][ruby]{
# 合計を計算する。
p [2, 3, 4, 5].inject {|result, item| result + item } #=> 14
# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}
この式は......以下のように書いても同じ結果が得られます。
//emlist[例][ruby]{
result = 0
[1, 2, 3, 4, 5].each {|v| result += v }
p result # => 15
p [1, 2, 3, 4, 5].inject(:+) #=> 15
p ["b", "c", "d"].inject("abbccddde", :squeeze) #=> "abcde"
//}...