Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Combination ¶
Combination 组合
Example ¶
slice := []int{1, 2, 3, 4, 5, 6} combination := Combination(slice, 5) fmt.Println(combination)
Output: [[1 2 3 4 5] [1 2 3 4 6] [1 2 3 5 6] [1 2 4 5 6] [1 3 4 5 6] [2 3 4 5 6]]
func Permutation ¶
func Permutation[T any](slice []T) [][]T
Permutation 全排列
Example ¶
slice := []int{1, 2, 3} permutation := Permutation(slice) fmt.Println(permutation)
Output: [[1 2 3] [1 3 2] [2 1 3] [2 3 1] [3 2 1] [3 1 2]]
func Product ¶
func Product[T1, T2 any](sliceA []T1, sliceB []T2) []*tuple.Tuple2[T1, T2]
Product 计算两个切片的笛卡尔积
Example ¶
sliceA := []string{"A", "B", "C"} sliceB := []int{1, 2, 3} r := Product(sliceA, sliceB) fmt.Println(r)
Output: [("A", 1) ("A", 2) ("A", 3) ("B", 1) ("B", 2) ("B", 3) ("C", 1) ("C", 2) ("C", 3)]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.