HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/ri/3.0.0/system/Array/repeated_combination-i.ri
U:RDoc::AnyMethod[iI"repeated_combination:ETI"Array#repeated_combination;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"]Calls the block with each repeated combination of length +n+ of the elements of +self+; ;TI"$each combination is an \Array; ;TI"Dreturns +self+. The order of the combinations is indeterminate.;To:RDoc::Markup::BlankLineo;
;	[I"\When a block and a positive \Integer argument +n+ are given, calls the block with each ;TI"?+n+-tuple repeated combination of the elements of +self+. ;TI"9The number of combinations is <tt>(n+1)(n+2)/2</tt>.;T@o;
;	[I"
+n+ = 1:;To:RDoc::Markup::Verbatim;	[I"a = [0, 1, 2]
;TI">a.repeated_combination(1) {|combination| p combination }
;T:@format0o;
;	[I"Output:;To;;	[I"	[0]
;TI"	[1]
;TI"	[2]
;T;
0o;
;	[I"
+n+ = 2:;To;;	[I">a.repeated_combination(2) {|combination| p combination }
;T;
0o;
;	[I"Output:;To;;	[I"[0, 0]
;TI"[0, 1]
;TI"[0, 2]
;TI"[1, 1]
;TI"[1, 2]
;TI"[2, 2]
;T;
0o;
;	[I"?If +n+ is zero, calls the block once with an empty \Array.;T@o;
;	[I"1If +n+ is negative, does not call the block:;To;;	[I"Fa.repeated_combination(-1) {|combination| fail 'Cannot happen' }
;T;
0o;
;	[I"1Returns a new \Enumerator if no block given:;To;;	[I"a = [0, 1, 2]
;TI"La.repeated_combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
;T;
0o;
;	[I"LUsing Enumerators, it's convenient to show the combinations and counts ;TI"for some values of +n+:;To;;	[I"#e = a.repeated_combination(0)
;TI"e.size # => 1
;TI"e.to_a # => [[]]
;TI"#e = a.repeated_combination(1)
;TI"e.size # => 3
;TI"!e.to_a # => [[0], [1], [2]]
;TI"#e = a.repeated_combination(2)
;TI"e.size # => 6
;TI"Ae.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]];T;
0:
@fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"parray.repeated_combination(n) {|combination| ... } -> self
array.repeated_combination(n) -> new_enumerator
;T0[I"	(p1);T@UFI"
Array;TcRDoc::NormalClass00