feat: add ShuffleCopy

This commit is contained in:
dudaodong committed 2025-02-14 16:33:22 +08:00
1 parent 2e619e48a3
commit 0e7297cb97
5 files changed
+113 -1

No files matched your search

+22
View File
@@ -950,6 +950,28 @@ func ExampleReverseCopy() {
// [a b c d]
}
func ExampleShuffle() {
strs := []string{"a", "b", "c", "d"}
Shuffle(strs)
fmt.Println(len(strs))
// Output:
// 4
}
func ExampleShuffleCopy() {
strs := []string{"a", "b", "c", "d"}
shuffledStrs := ShuffleCopy(strs)
fmt.Println(len(shuffledStrs))
fmt.Println(strs)
// Output:
// 4
// [a b c d]
}
func ExampleIsAscending() {
result1 := IsAscending([]int{1, 2, 3, 4, 5})