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

feat: add IsAscending, Isdescending

This commit is contained in:
dudaodong
2023-02-09 19:25:58 +08:00
parent d231d9f572
commit abf392117a
3 changed files with 72 additions and 0 deletions

View File

@@ -685,6 +685,38 @@ func ExampleReverse() {
// [d c b a]
}
func ExampleIsAscending() {
result1 := IsAscending([]int{1, 2, 3, 4, 5})
result2 := IsAscending([]int{5, 4, 3, 2, 1})
result3 := IsAscending([]int{2, 1, 3, 4, 5})
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// true
// false
// false
}
func ExampleIsdescending() {
result1 := Isdescending([]int{5, 4, 3, 2, 1})
result2 := Isdescending([]int{1, 2, 3, 4, 5})
result3 := Isdescending([]int{2, 1, 3, 4, 5})
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// true
// false
// false
}
func ExampleSort() {
nums := []int{1, 4, 3, 2, 5}