1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 06:32:28 +08:00

feat: add Shuffle for string

This commit is contained in:
dudaodong
2024-09-03 15:54:05 +08:00
parent c32a19868d
commit 63216d9b1c
4 changed files with 82 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ import (
- [HammingDistance](#HammingDistance)
- [Concat](#Concat)
- [Ellipsis](#Ellipsis)
- [Shuffle](#Shuffle)
<div STYLE="page-break-after: always;"></div>
@@ -1576,7 +1577,7 @@ func main() {
func Ellipsis(str string, length int) string
```
<b>示例:<span style="float:right;display:inline-block;">[Run]()</span></b>
<b>示例:<span style="float:right;display:inline-block;">[运行]()</span></b>
```go
import (
@@ -1598,4 +1599,28 @@ func main() {
// 你好...
// 😀😃😄...
}
```
### <span id="Shuffle">Shuffle</span>
<p>打乱给定字符串中的字符顺序。</p>
<b>函数签名:</b>
```go
func Shuffle(str string) string
```
<b>示例:<span style="float:right;display:inline-block;">[运行]()</span></b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
result := strutil.Shuffle("hello")
fmt.Println(result) //olelh (random order)
}
```