別のキーワード
キーワード
- & (12)
- * (24)
- + (12)
- - (12)
- << (12)
- <=> (12)
- == (12)
- [] (36)
- []= (36)
- abbrev (12)
- all? (21)
- any? (30)
- append (8)
- assoc (12)
- at (12)
- bsearch (24)
-
bsearch
_ index (20) - clear (12)
- clone (12)
- collect (24)
- collect! (24)
- combination (24)
- compact (12)
- compact! (12)
- concat (21)
- count (36)
- cycle (24)
- delete (24)
-
delete
_ at (12) -
delete
_ if (24) - difference (7)
- dig (10)
- drop (12)
-
drop
_ while (24) - dup (12)
- each (24)
-
each
_ index (24) - empty? (12)
- eql? (12)
- fetch (36)
- 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 (24)
- length (12)
- map (24)
- map! (24)
- max (36)
- min (36)
- minmax (12)
- none? (21)
- one? (21)
- pack (21)
- permutation (24)
- pop (24)
- prepend (8)
- product (24)
- push (12)
- rassoc (12)
- reject (24)
- reject! (24)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - replace (12)
- reverse (12)
- reverse! (12)
-
reverse
_ each (24) - rindex (36)
- rotate (12)
- rotate! (12)
- sample (48)
- select (24)
- select! (24)
- shift (24)
- shuffle (24)
- shuffle! (24)
- size (12)
- slice (36)
- slice! (36)
- sort (24)
- sort! (24)
-
sort
_ by! (24) - sum (18)
- take (12)
-
take
_ while (24) -
to
_ a (12) -
to
_ ary (12) -
to
_ csv (12) -
to
_ h (19) -
to
_ s (12) - transpose (12)
- union (7)
- uniq (24)
- uniq! (24)
- unshift (12)
-
values
_ at (12) - zip (24)
- | (12)
検索結果
先頭5件
-
Array
# repeated _ combination(n) { |c| . . . } -> self (26.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.repe......して 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 (26.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).......ロックを実
行して 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 (26.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).......ロックを実
行して 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
# sample -> object | nil (26.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securer... -
Array
# sample(n) -> Array (26.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securer... -
Array
# sample(n , random: Random) -> Array (26.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securer... -
Array
# sample(random: Random) -> object | nil (26.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securer... -
Array
# to _ h -> Hash (26.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...して
返します。
//emlist[例][ruby]{
bar], [1, 2.to_h # => {:foo => :bar, 1 => 2}
//}
ブロックを指定すると配列の各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
["foo", "bar"].to_h {|s| [s.ord, s... -
Array
# to _ h { block } -> Hash (26.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...して
返します。
//emlist[例][ruby]{
bar], [1, 2.to_h # => {:foo => :bar, 1 => 2}
//}
ブロックを指定すると配列の各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
["foo", "bar"].to_h {|s| [s.ord, s... -
Array
# uniq -> Array (26.0) -
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...