別のキーワード
キーワード
- * (24)
- <=> (12)
- [] (36)
- abbrev (12)
- all? (7)
- any? (11)
- assoc (12)
- at (12)
- bsearch (24)
-
bsearch
_ index (20) - collect (12)
- collect! (24)
- combination (24)
- compact! (12)
- count (36)
- cycle (24)
- delete (12)
-
delete
_ at (12) -
delete
_ if (24) - difference (7)
- dig (10)
-
drop
_ while (24) - each (24)
-
each
_ index (24) - fetch (12)
-
fetch
_ values (2) - fill (72)
- filter (14)
- filter! (14)
-
find
_ index (36) - first (24)
- flatten (12)
- flatten! (12)
- hash (12)
- include? (12)
- index (36)
- insert (12)
- inspect (12)
- intersect? (4)
- intersection (6)
- join (12)
-
keep
_ if (24) - last (12)
- length (12)
- map (12)
- map! (24)
- max (18)
- min (36)
- minmax (12)
- pack (21)
- permutation (24)
- pop (12)
- product (24)
- rassoc (12)
- reject (24)
- reject! (24)
-
repeated
_ combination (24) -
repeated
_ permutation (24) -
reverse
_ each (12) - rindex (36)
- sample (24)
- select (19)
- select! (19)
- shift (24)
- size (12)
- slice (36)
- slice! (36)
- sort (24)
- sort! (24)
-
sort
_ by! (12) - sum (18)
-
take
_ while (24) -
to
_ csv (12) -
to
_ s (12) - union (7)
- uniq (24)
- uniq! (24)
- unshift (12)
- zip (24)
検索結果
先頭5件
-
Array
# keep _ if {|item| . . . } -> self (6126.0) -
ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。
...list[例][ruby]{
a = %w{ a b c d e f }
a.keep_if {|v| v =~ /[aeiou]/} # => ["a", "e"]
a # => ["a", "e"]
//}
keep_if は常に self を返しますが、Array#select! は要素が 1 つ以上削除されれば self を、
1 つも削除されなければ nil を返します。
//emlist[例][ruby]......a b c d e f }
a.keep_if {|v| v =~ /[a-z]/ } # => ["a", "b", "c", "d", "e", "f"]
a # => ["a", "b", "c", "d", "e", "f"]
//}
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
@see Array#select!, Array#delete_if... -
Array
# permutation(n = self . length) -> Enumerator (6126.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a......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 len......した配列の各要素を引数としてブロックを実
行して 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 (6126.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a......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 len......した配列の各要素を引数としてブロックを実
行して 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 (6126.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.repeated_combination(1).to_......> [[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,......a.repeated_combination(0).to_a #=> [[]] # one combination of length 0
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| resu... -
Array
# repeated _ combination(n) { |c| . . . } -> self (6126.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.repeated_combination(1).to_......> [[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,......a.repeated_combination(0).to_a #=> [[]] # one combination of length 0
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| resu... -
Array
# repeated _ permutation(n) -> Enumerator (6126.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_......[[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 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
# repeated _ permutation(n) { |p| . . . } -> self (6126.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_......[[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 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
# take _ while -> Enumerator (6126.0) -
配列の要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。 このメソッドは自身を破壊的に変更しません。
...の要素までを配列として返します。
このメソッドは自身を破壊的に変更しません。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを省略した場合は Enumerator を返します。
@see Enumerable#take_while... -
Array
# take _ while {|element| . . . } -> Array (6126.0) -
配列の要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。 このメソッドは自身を破壊的に変更しません。
...の要素までを配列として返します。
このメソッドは自身を破壊的に変更しません。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを省略した場合は Enumerator を返します。
@see Enumerable#take_while... -
Array
# uniq -> Array (6126.0) -
uniq は配列から重複した要素を取り除いた新しい配列を返します。 uniq! は削除を破壊的に行い、削除が行われた場合は self を、 そうでなければnil を返します。
...uniq は配列から重複した要素を取り除いた新しい配列を返します。
uniq! は削除を破壊的に行い、削除が行われた場合は self を、
そうでなければnil を返します。
取り除かれた要素の部分は前に詰められます。
要素の重複判......//emlist[例][ruby]{
p [1, 1, 1].uniq # => [1]
p [1, 4, 1].uniq # => [1, 4]
p [1, 3, 2, 2, 3].uniq # => [1, 3, 2]
//}
ブロックが与えられた場合、ブロックが返した値が重複した要素を取り除いた
配列を返します。
//emlist[例][ruby]{
p [1, 3,......2, "2", "3"].uniq # => [1, 3, 2, "2", "3"]
p [1, 3, 2, "2", "3"].uniq { |n| n.to_s } # => [1, 3, 2]
//}
要素を先頭から辿っていき、最初に出現したものが残ります。...