るりまサーチ

最速Rubyリファレンスマニュアル検索!
129件ヒット [1-100件を表示] (0.025秒)
トップページ > クエリ:IO[x] > クラス:Array[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io each
  4. io each_line
  5. io readlines

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Array#combination(n) -> Enumerator (6102.0)

サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。

...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 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#combination(n) {|c| block } -> self (6102.0)

サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。

...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 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#intersection(*other_arrays) -> Array (6102.0)

自身と引数に渡された配列の共通要素を新しい配列として返します。 要素が重複する場合は、そのうちの1つのみを返します。 要素の順序は自身の順序を維持します。

...要素が重複する場合は、そのうちの1つのみを返します。
要素の順序は自身の順序を維持します。

@param other_arrays 自身と共通要素を取りたい配列を指定します。
配列以外のオブジェクトを指定した場合は to_a...
...発生します。

intersectionはObject#hashとObject#eql?を使って比較を行います。

//emlist[例][ruby]{
[1, 1, 3, 5].intersection([3, 2, 1]) # => [1, 3]
["a", "b", "z"].intersection(["a", "b", "c"], ["b"]) # => ["b"]
["a"].intersection...
...# => ["a"]
//}

@see Set#intersection, Array#&...

Array#permutation(n = self.length) -> Enumerator (6102.0)

サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。

...ation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(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 4
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して 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#permutation(n = self.length) { |p| block } -> self (6102.0)

サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。

...ation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(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 4
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して 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) -> Enumerator (6102.0)

サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。

...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],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.repeated_combination(4).to_...
...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,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_combination(n) { |c| ... } -> self (6102.0)

サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。

...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],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.repeated_combination(4).to_...
...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,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) -> Enumerator (6102.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...ermutation(1).to_a #=> [[1], [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 l...
...ロックを実
行して 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#repeated_permutation(n) { |p| ... } -> self (6102.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...ermutation(1).to_a #=> [[1], [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 l...
...ロックを実
行して 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#union(*other_arrays) -> Array (6102.0)

集合の和演算です。self と other_arrays の配列にどれかに含まれる要素を 全て含む新しい配列を返します。重複する要素は取り除かれます。

...算です。self と other_arrays の配列にどれかに含まれる要素を
全て含む新しい配列を返します。重複する要素は取り除かれます。

要素の重複判定は、Object#eql? と Object#hash により行われます。

@param other_arrays 0個以上の配列を...
...指定します。

//emlist[例][ruby]{
["a", "b", "c"].union([ "c", "d", "a" ]) #=> ["a", "b", "c", "d"]
["a"].union(["e", "b"], ["a", "c", "b"]) #=> ["a", "e", "b", "c"]
["a"].union # => ["a"]
//}

@see Array#|...

絞り込み条件を変える

Array#to_csv(**options) -> String (102.0)

CSV.generate_line(self, options) と同様です。

...CSV.generate_line(self, options) と同様です。

Array
オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。

@param options CSV.generate_line と同様のオプションを指定します。

//emlist[][ruby]{
require 'csv'

p [1, 'Matz', :Ruby, Dat...
<< 1 2 > >>