別のキーワード
ライブラリ
- ビルトイン (231)
キーワード
- [] (33)
- at (11)
- combination (11)
- cycle (22)
-
delete
_ at (11) - first (11)
- flatten (11)
- flatten! (11)
- insert (11)
- last (11)
- permutation (22)
- pop (11)
-
repeated
_ combination (11) -
repeated
_ permutation (11) - sample (22)
- shift (11)
検索結果
先頭5件
-
Array
# permutation(n = self . length) { |p| block } -> self (6319.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a......ermutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length......した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2) {|e| result << e} # => [1,2,3]
result # => [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
//}
@see Array#combination, Array#repeated_permutation... -
Array
# cycle(n=nil) {|obj| block } -> nil (6313.0) -
配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
...を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
ブロックを省略した場合は Enumerator を返します。
@param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッ......黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
//}... -
Array
# flatten!(lv = nil) -> self | nil (6313.0) -
flatten は自身を再帰的に平坦化した配列を生成して返します。flatten! は 自身を再帰的かつ破壊的に平坦化し、平坦化が行われた場合は self をそうでない 場合は nil を返します。 lv が指定された場合、lv の深さまで再帰的に平坦化します。
...flatten は自身を再帰的に平坦化した配列を生成して返します。flatten! は
自身を再帰的かつ破壊的に平坦化し、平坦化が行われた場合は self をそうでない
場合は nil を返します。
lv が指定された場合、lv の深さまで再帰的に......平坦化します。
@param lv 平坦化の再帰の深さを整数で指定します。nil を指定した場合、再
帰の深さの制限無しに平坦化します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の......試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
@raise ArgumentError 配列要素が自身を含むような無限にネストした配列に対して flatten を呼んだ場... -
Array
# combination(n) {|c| block } -> self (6219.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_......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 length 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
# permutation(n = self . length) -> Enumerator (6219.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a......ermutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length......した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2) {|e| result << e} # => [1,2,3]
result # => [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
//}
@see Array#combination, Array#repeated_permutation... -
Array
# repeated _ combination(n) { |c| . . . } -> self (6219.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.repeated_combination(1).......> [[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],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,......して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result << e} # => [1,2,3]
result #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
//}
@see Array#repeated_permutation, Array#combination... -
Array
# repeated _ permutation(n) { |p| . . . } -> self (6219.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_......], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0
//}
ブロック......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Array
# cycle(n=nil) -> Enumerator (6213.0) -
配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
...を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
ブロックを省略した場合は Enumerator を返します。
@param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッ......黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
//}... -
Array
# delete _ at(pos) -> object | nil (6213.0) -
指定された位置 pos にある要素を取り除きそれを返します。 pos が範囲外であったら nil を返します。
...ら nil を返します。
Array#at と同様に負のインデックスで末尾から位置を指定するこ
とができます。
@param pos 削除したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メ......暗黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
array = [0, 1, 2, 3, 4]
array.delete_at 2
p array #=> [0, 1, 3, 4]
//}... -
Array
# flatten(lv = nil) -> Array (6213.0) -
flatten は自身を再帰的に平坦化した配列を生成して返します。flatten! は 自身を再帰的かつ破壊的に平坦化し、平坦化が行われた場合は self をそうでない 場合は nil を返します。 lv が指定された場合、lv の深さまで再帰的に平坦化します。
...flatten は自身を再帰的に平坦化した配列を生成して返します。flatten! は
自身を再帰的かつ破壊的に平坦化し、平坦化が行われた場合は self をそうでない
場合は nil を返します。
lv が指定された場合、lv の深さまで再帰的に......平坦化します。
@param lv 平坦化の再帰の深さを整数で指定します。nil を指定した場合、再
帰の深さの制限無しに平坦化します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の......試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
@raise ArgumentError 配列要素が自身を含むような無限にネストした配列に対して flatten を呼んだ場...