File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 6
6
[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/mxschmitt/golang-combinations )] ( https://goreportcard.com/report/github.com/mxschmitt/golang-combinations )
7
7
[ ![ License] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
8
8
9
- This package provides a method to generate all ordered combinations out of a given string array.
9
+ This package provides a method to generate all ordered combinations out of a given generic array.
10
10
This essentially creates the powerset of the given array except that the empty set is disregarded.
11
11
12
12
## Examples
Original file line number Diff line number Diff line change 1
- // Package combinations provides a method to generate all combinations out of a given string array.
1
+ // Package combinations provides a method to generate all combinations out of a given generic array.
2
2
package combinations
3
3
4
4
import "math/bits"
5
5
6
- // All returns all combinations for a given string array.
6
+ // All returns all combinations for a given generic array.
7
7
// This is essentially a powerset of the given set except that the empty set is disregarded.
8
8
func All [T any ](set []T ) (subsets [][]T ) {
9
9
length := uint (len (set ))
@@ -27,7 +27,7 @@ func All[T any](set []T) (subsets [][]T) {
27
27
return subsets
28
28
}
29
29
30
- // Combinations returns combinations of n elements for a given string array.
30
+ // Combinations returns combinations of n elements for a given generic array.
31
31
// For n < 1, it equals to All and returns all combinations.
32
32
func Combinations [T any ](set []T , n int ) (subsets [][]T ) {
33
33
length := uint (len (set ))
You can’t perform that action at this time.
0 commit comments