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

doc: update doc for function package

This commit is contained in:
dudaodong
2024-03-04 10:19:39 +08:00
parent e138043289
commit e95d7c82cd
4 changed files with 74 additions and 46 deletions

View File

@@ -644,7 +644,7 @@ func main() {
### <span id="AcceptIf">AcceptIf</span>
<p>TBD</p>
<p>AcceptIf函数会返回另一个函数该函数的签名与 apply 函数相同,但同时还会包含一个布尔值来表示成功或失败。</p>
<b>函数签名:</b>
@@ -664,31 +664,31 @@ import (
func main() {
adder := AcceptIf(
And(
func(x int) bool {
return x > 10
}, func(x int) bool {
return x%2 == 0
}),
func(x int) int {
return x + 1
},
)
adder := AcceptIf(
And(
func(x int) bool {
return x > 10
}, func(x int) bool {
return x%2 == 0
}),
func(x int) int {
return x + 1
},
)
result, ok := adder(20)
fmt.Println(result)
fmt.Println(ok)
result, ok := adder(20)
fmt.Println(result)
fmt.Println(ok)
result, ok = adder(21)
fmt.Println(result)
fmt.Println(ok)
result, ok = adder(21)
fmt.Println(result)
fmt.Println(ok)
// Output:
// 21
// true
// 0
// false
// Output:
// 21
// true
// 0
// false
}
```