1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-13 17:22:27 +08:00

feat: merge some new functions from rc branch

This commit is contained in:
dudaodong
2024-03-04 16:36:20 +08:00
parent 48519aba2b
commit 928e3a390d
14 changed files with 1475 additions and 30 deletions

View File

@@ -59,6 +59,7 @@ import (
- [HideString](#HideString)
- [RemoveWhiteSpace](#RemoveWhiteSpace)
- [SubInBetween](#SubInBetween)
- [HammingDistance](#HammingDistance)
<div STYLE="page-break-after: always;"></div>
@@ -1307,4 +1308,36 @@ func main() {
// abc
// bc
}
```
### <span id="HammingDistance">HammingDistance</span>
<p>HammingDistance calculates the Hamming distance between two strings. The Hamming distance is the number of positions at which the corresponding symbols are different.</p>
<b>Signature:</b>
```go
HammingDistance(a, b string) (int, error)
```
<b>Example:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/strutil"
)
func main() {
result1, _ := strutil.HammingDistance("de", "de")
result2, _ := strutil.HammingDistance("a", "d")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// 0
// 1
}
```