D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
repeated_permutation-i.ri
back
Copy
U:RDoc::AnyMethod[iI"repeated_permutation:ETI"Array#repeated_permutation;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"YWith a block given, calls the block with each repeated permutation of length +size+ ;TI" of the elements of +self+; ;TI"#each permutation is an array; ;TI"Dreturns +self+. The order of the permutations 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 permutation of the elements of +self+. ;TI"<The number of permutations is <tt>self.size**size</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"p = [] ;TI"L[0, 1, 2].repeated_permutation(1) {|permutation| p.push(permutation) } ;TI"p # => [[0], [1], [2]] ;T:@format0o;;0; [o; ; [I"+size+ is 2:;T@o;; [I"p = [] ;TI"L[0, 1, 2].repeated_permutation(2) {|permutation| p.push(permutation) } ;TI"Up # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [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_permutation(-1) {|permutation| 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_permutation(size) {|permutation| ... } -> self repeated_permutation(size) -> new_enumerator ;T0[ I" (p1);T@?FI" Array;TcRDoc::NormalClass00