Skip to content

Commit a5aed68

Browse files
committed
adds comb_w_repl to the docs
1 parent ed7ce40 commit a5aed68

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ evaluation wherever possible.
3535
##### Combinatoric fuctions
3636
[product](#product)<br />
3737
[combinations](#combinations)<br />
38+
[combinations_with_replacement](#combinations_with_replacement)
3839
[permutations](#permutations)<br />
3940
[powerset](#powerset)<br />
4041

@@ -536,16 +537,33 @@ for (auto&& t : product(v1,v2,v3,v4)) {
536537
combinations
537538
-----------
538539

539-
Generates n length unique sequences of the input range, there is also a
540-
combinations_with_replacement
540+
Generates n length unique sequences of the input range.
541541

542542
Example usage:
543543
```c++
544-
std::vector<int> v = {1,2,3,4,5};
544+
vector<int> v = {1,2,3,4,5};
545545
for (auto&& i : combinations(v,3)) {
546-
//std::cout << i << std::endl;
547-
for (auto&& j : i ) std::cout << j << " ";
548-
std::cout<<std::endl;
546+
//cout << i << std::endl;
547+
for (auto&& j : i ) cout << j << " ";
548+
cout << '\n';
549+
}
550+
```
551+
552+
combinations_with_replacement
553+
-----------------------------
554+
Like combinations, but with replacment of each element. The
555+
below is printed by the loop that follows:
556+
```
557+
{A, A}
558+
{A, B}
559+
{A, C}
560+
{B, B}
561+
{B, C}
562+
{C, C}
563+
```
564+
```c++
565+
for (auto&& v : combinations_with_replacement(s, 2)) {
566+
cout << '{' << v[0] << ", " << v[1] << "}\n";
549567
}
550568
```
551569

0 commit comments

Comments
 (0)