1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 07:02:29 +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>
@@ -1600,4 +1601,28 @@ func main() {
// 你好...
// 😀😃😄...
}
```
### <span id="Shuffle">Shuffle</span>
<p>Shuffle the order of characters of given string.</p>
<b>Signature:</b>
```go
func Shuffle(str string) string
```
<b>Example:<span style="float:right;display:inline-block;">[Run]()</span></b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
result := strutil.Shuffle("hello")
fmt.Println(result) //olelh (random order)
}
```