D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
repeated_combination-i.ri
back
Copy
U:RDoc::AnyMethod[iI"repeated_combination:ETI"Array#repeated_combination;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"YWith a block given, calls the block with each repeated combination of length +size+ ;TI" of the elements of +self+; ;TI"#each combination is an array; ;TI"Dreturns +self+. The order of the combinations is indeterminate.;To:RDoc::Markup::BlankLine o; ; [I"5If a positive integer argument +size+ is given, ;TI"\calls the block with each +size+-tuple repeated combination of the elements of +self+. ;TI"?The number of combinations is <tt>(size+1)(size+2)/2</tt>.;T@o; ; [I"Examples:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"+size+ is 1:;T@o:RDoc::Markup::Verbatim; [I"c = [] ;TI"L[0, 1, 2].repeated_combination(1) {|combination| c.push(combination) } ;TI"c # => [[0], [1], [2]] ;T:@format0o;;0; [o; ; [I"+size+ is 2:;T@o;; [I"c = [] ;TI"L[0, 1, 2].repeated_combination(2) {|combination| c.push(combination) } ;TI"=c # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]] ;T;0o; ; [I"AIf +size+ is zero, calls the block once with an empty array.;T@o; ; [I"4If +size+ is negative, does not call the block:;T@o;; [I"N[0, 1, 2].repeated_combination(-1) {|combination| fail 'Cannot happen' } ;T;0o; ; [I"3With no block given, returns a new Enumerator.;T@o; ; [I"PRelated: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"jrepeated_combination(size) {|combination| ... } -> self repeated_combination(size) -> new_enumerator ;T0[ I" (p1);T@?FI" Array;TcRDoc::NormalClass00