diff --git a/README.md b/README.md index 4fd39a4..8894bc8 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ import "github.com/duke-git/lancet/v2/condition" [[play](https://go.dev/play/p/W1SSUmt6pvr)] - **Or** : returns false if neither a nor b is truthy. [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition.md#Or)] - [[play](https://go.dev/play/p/UlQTxHaeEkq)] + [[play](https://go.dev/play/p/UlQTxHaeEkq)]] - **Xor** : returns true if a or b but not both is truthy. [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition.md#Xor)] [[play](https://go.dev/play/p/gObZrW7ZbG8)] diff --git a/README_zh-CN.md b/README_zh-CN.md index 91d9a21..62b3eae 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -170,7 +170,7 @@ import "github.com/duke-git/lancet/v2/condition" [[play](https://go.dev/play/p/g2j08F_zZky) - **Xnor** : 如果 a 和 b 都是真的或 a 和 b 均是假的,则返回 true。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition_zh-CN.md#Xnor)] - [[play](https://go.dev/play/p/OuDB9g51643)] + [[play](https://go.dev/play/p/OuDB9g51643)]] - **Nand** : 如果 a 和 b 都为真,返回 false,否则返回 true [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition_zh-CN.md#Nand)] [[play](https://go.dev/play/p/vSRMLxLIbq8)] diff --git a/algorithm/search.go b/algorithm/search.go index b44b1a6..0d85cad 100644 --- a/algorithm/search.go +++ b/algorithm/search.go @@ -10,6 +10,7 @@ import "github.com/duke-git/lancet/v2/lancetconstraints" // LinearSearch return the index of target in slice base on equal function. // If not found return -1 +// Play: Todo func LinearSearch[T any](slice []T, target T, equal func(a, b T) bool) int { for i, v := range slice { if equal(v, target) { diff --git a/concurrency/channel.go b/concurrency/channel.go index c235018..8629e87 100644 --- a/concurrency/channel.go +++ b/concurrency/channel.go @@ -20,7 +20,7 @@ func NewChannel[T any]() *Channel[T] { } // Generate creates channel, then put values into the channel. -// Play: +// Play: Todo func (c *Channel[T]) Generate(ctx context.Context, values ...T) <-chan T { dataStream := make(chan T) @@ -40,7 +40,7 @@ func (c *Channel[T]) Generate(ctx context.Context, values ...T) <-chan T { } // Repeat create channel, put values into the channel repeatly until cancel the context. -// Play: +// Play: Todo func (c *Channel[T]) Repeat(ctx context.Context, values ...T) <-chan T { dataStream := make(chan T) @@ -61,7 +61,7 @@ func (c *Channel[T]) Repeat(ctx context.Context, values ...T) <-chan T { // RepeatFn create a channel, excutes fn repeatly, and put the result into the channel // until close context. -// Play: +// Play: Todo func (c *Channel[T]) RepeatFn(ctx context.Context, fn func() T) <-chan T { dataStream := make(chan T) @@ -79,7 +79,7 @@ func (c *Channel[T]) RepeatFn(ctx context.Context, fn func() T) <-chan T { } // Take create a channel whose values are taken from another channel with limit number. -// Play: +// Play: Todo func (c *Channel[T]) Take(ctx context.Context, valueStream <-chan T, number int) <-chan T { takeStream := make(chan T) @@ -99,7 +99,7 @@ func (c *Channel[T]) Take(ctx context.Context, valueStream <-chan T, number int) } // FanIn merge multiple channels into one channel. -// Play: +// Play: Todo func (c *Channel[T]) FanIn(ctx context.Context, channels ...<-chan T) <-chan T { out := make(chan T) @@ -127,7 +127,7 @@ func (c *Channel[T]) FanIn(ctx context.Context, channels ...<-chan T) <-chan T { } // Tee split one chanel into two channels, until cancel the context. -// Play: +// Play: Todo func (c *Channel[T]) Tee(ctx context.Context, in <-chan T) (<-chan T, <-chan T) { out1 := make(chan T) out2 := make(chan T) @@ -154,7 +154,7 @@ func (c *Channel[T]) Tee(ctx context.Context, in <-chan T) (<-chan T, <-chan T) } // Bridge link multiply channels into one channel. -// Play: +// Play: Todo func (c *Channel[T]) Bridge(ctx context.Context, chanStream <-chan <-chan T) <-chan T { valStream := make(chan T) @@ -186,7 +186,7 @@ func (c *Channel[T]) Bridge(ctx context.Context, chanStream <-chan <-chan T) <-c } // Or read one or more channels into one channel, will close when any readin channel is closed. -// Play: +// Play: Todo func (c *Channel[T]) Or(channels ...<-chan T) <-chan T { switch len(channels) { case 0: @@ -220,7 +220,7 @@ func (c *Channel[T]) Or(channels ...<-chan T) <-chan T { } // OrDone read a channel into another channel, will close until cancel context. -// Play: +// Play: Todo func (c *Channel[T]) OrDone(ctx context.Context, channel <-chan T) <-chan T { valStream := make(chan T) diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go index 0a8ffe2..4ce167e 100644 --- a/mathutil/mathutil.go +++ b/mathutil/mathutil.go @@ -55,6 +55,7 @@ func Factorial(x uint) uint { } // Percent calculate the percentage of value to total. +// Play: Todo func Percent(val, total float64, n int) float64 { if total == 0 { return float64(0) diff --git a/strutil/string.go b/strutil/string.go index 8dd0ba2..1dcc45d 100644 --- a/strutil/string.go +++ b/strutil/string.go @@ -283,6 +283,7 @@ func SplitEx(s, sep string, removeEmptyString bool) []string { } // Substring returns a substring of the specified length starting at the specified offset position. +// Play: Todo func Substring(s string, offset int, length uint) string { rs := []rune(s) size := len(rs)